Use scoped_switch_to_sym_language_if_auto in symtab.c to switch language.
[external/binutils.git] / gdb / symtab.c
index 2e9e632..f8c755f 100644 (file)
@@ -4288,15 +4288,12 @@ treg_matches_sym_type_name (const compiled_regex &treg,
   if (sym_type == NULL)
     return false;
 
-  if (language_mode == language_mode_auto)
-    {
-      scoped_restore_current_language l;
+  {
+    scoped_switch_to_sym_language_if_auto l (sym);
 
-      set_language (SYMBOL_LANGUAGE (sym));
-      printed_sym_type_name = type_to_string (sym_type);
-    }
-  else
     printed_sym_type_name = type_to_string (sym_type);
+  }
+
 
   if (symbol_lookup_debug > 1)
     {
@@ -4544,9 +4541,12 @@ search_symbols (const char *regexp, enum search_domain kind,
     sort_search_symbols_remove_dups (&result);
 
   /* If there are no eyes, avoid all contact.  I mean, if there are
-     no debug symbols, then add matching minsyms.  */
+     no debug symbols, then add matching minsyms.  But if the user wants
+     to see symbols matching a type regexp, then never give a minimal symbol,
+     as we assume that a minimal symbol does not have a type.  */
 
-  if (found_misc || (nfiles == 0 && kind != FUNCTIONS_DOMAIN))
+  if ((found_misc || (nfiles == 0 && kind != FUNCTIONS_DOMAIN))
+      && !treg.has_value ())
     {
       ALL_MSYMBOLS (objfile, msymbol)
       {
@@ -4560,13 +4560,9 @@ search_symbols (const char *regexp, enum search_domain kind,
            || MSYMBOL_TYPE (msymbol) == ourtype3
            || MSYMBOL_TYPE (msymbol) == ourtype4)
          {
-           /* If the user wants to see var matching a type regexp,
-              then never give a minimal symbol.  */
-           if (kind != VARIABLES_DOMAIN
-               && !treg.has_value () /* minimal symbol has never a type ???? */
-               && (!preg.has_value ()
-                   || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
-                                  NULL, 0) == 0))
+           if (!preg.has_value ()
+               || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0,
+                              NULL, 0) == 0)
              {
                /* For functions we can do a quick check of whether the
                   symbol might be found via find_pc_symtab.  */
@@ -4601,6 +4597,7 @@ print_symbol_info (enum search_domain kind,
                   struct symbol *sym,
                   int block, const char *last)
 {
+  scoped_switch_to_sym_language_if_auto l (sym);
   struct symtab *s = symbol_symtab (sym);
 
   if (last != NULL)