gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 16ebe4d39f41d7c3cf84e8d131078c014ede174d..791ce11a7372c11583eec384b5d44bf13d4366ea 100644 (file)
@@ -595,7 +595,7 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   struct fn_field *method = &f[signature_id];
   const char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
   const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
-  const char *newname = TYPE_NAME (type);
+  const char *newname = type->name ();
 
   /* Does the form of physname indicate that it is the full mangled name
      of a constructor (not just the args)?  */
@@ -807,7 +807,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
     {
       const struct language_defn *lang = language_def (gsymbol->language ());
 
-      language_sniff_from_mangled_name (lang, mangled, &demangled);
+      lang->sniff_from_mangled_name (mangled, &demangled);
       return demangled;
     }
 
@@ -816,7 +816,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
       enum language l = (enum language) i;
       const struct language_defn *lang = language_def (l);
 
-      if (language_sniff_from_mangled_name (lang, mangled, &demangled))
+      if (lang->sniff_from_mangled_name (mangled, &demangled))
        {
          gsymbol->m_language = l;
          return demangled;
@@ -1855,7 +1855,7 @@ demangle_for_lookup (const char *name, enum language lang,
 unsigned int
 search_name_hash (enum language language, const char *search_name)
 {
-  return language_def (language)->la_search_name_hash (search_name);
+  return language_def (language)->search_name_hash (search_name);
 }
 
 /* See symtab.h.
@@ -1917,7 +1917,7 @@ lookup_language_this (const struct language_defn *lang,
 
   if (symbol_lookup_debug > 1)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = block_objfile (block);
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_language_this (%s, %s (objfile %s))",
@@ -1966,14 +1966,14 @@ check_field (struct type *type, const char *name,
   /* The type may be a stub.  */
   type = check_typedef (type);
 
-  for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
+  for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--)
     {
       const char *t_field_name = TYPE_FIELD_NAME (type, i);
 
       if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
        {
          is_a_field_of_this->type = type;
-         is_a_field_of_this->field = &TYPE_FIELD (type, i);
+         is_a_field_of_this->field = &type->field (i);
          return 1;
        }
     }
@@ -2012,7 +2012,8 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
 
   if (symbol_lookup_debug)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_aux (%s, %s (objfile %s), %s, %s)\n",
@@ -2157,32 +2158,6 @@ lookup_local_symbol (const char *name,
 
 /* See symtab.h.  */
 
-struct objfile *
-lookup_objfile_from_block (const struct block *block)
-{
-  if (block == NULL)
-    return NULL;
-
-  block = block_global_block (block);
-  /* Look through all blockvectors.  */
-  for (objfile *obj : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *cust : obj->compunits ())
-       if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
-                                       GLOBAL_BLOCK))
-         {
-           if (obj->separate_debug_objfile_backlink)
-             obj = obj->separate_debug_objfile_backlink;
-
-           return obj;
-         }
-    }
-
-  return NULL;
-}
-
-/* See symtab.h.  */
-
 struct symbol *
 lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
                        const struct block *block,
@@ -2192,7 +2167,8 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 
   if (symbol_lookup_debug > 1)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_in_block (%s, %s (objfile %s), %s)",
@@ -2482,7 +2458,8 @@ lookup_symbol_in_static_block (const char *name,
 
   if (symbol_lookup_debug)
     {
-      struct objfile *objfile = lookup_objfile_from_block (static_block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_in_static_block (%s, %s (objfile %s),"
@@ -2704,7 +2681,14 @@ lookup_global_symbol (const char *name,
        return { sym, global_block };
     }
 
-  struct objfile *objfile = lookup_objfile_from_block (block);
+  struct objfile *objfile = nullptr;
+  if (block != nullptr)
+    {
+      objfile = block_objfile (block);
+      if (objfile->separate_debug_objfile_backlink != nullptr)
+       objfile = objfile->separate_debug_objfile_backlink;
+    }
+
   block_symbol bs
     = lookup_global_or_static_symbol (name, GLOBAL_BLOCK, objfile, domain);
   if (better_symbol (sym, bs.symbol, domain) == sym)
@@ -2738,7 +2722,7 @@ symbol_matches_domain (enum language symbol_language,
 struct type *
 lookup_transparent_type (const char *name)
 {
-  return current_language->la_lookup_transparent_type (name);
+  return current_language->lookup_transparent_type (name);
 }
 
 /* A helper for basic_lookup_transparent_type that interfaces with the
@@ -5276,7 +5260,7 @@ compare_symbol_name (const char *symbol_name, language symbol_language,
 
 /*  See symtab.h.  */
 
-void
+bool
 completion_list_add_name (completion_tracker &tracker,
                          language symbol_language,
                          const char *symname,
@@ -5288,7 +5272,7 @@ completion_list_add_name (completion_tracker &tracker,
 
   /* Clip symbols that cannot match.  */
   if (!compare_symbol_name (symname, symbol_language, lookup_name, match_res))
-    return;
+    return false;
 
   /* Refresh SYMNAME from the match string.  It's potentially
      different depending on language.  (E.g., on Ada, the match may be
@@ -5312,6 +5296,8 @@ completion_list_add_name (completion_tracker &tracker,
     tracker.add_completion (std::move (completion),
                            &match_res.match_for_lcd, text, word);
   }
+
+  return true;
 }
 
 /* completion_list_add_name wrapper for struct symbol.  */
@@ -5322,9 +5308,10 @@ completion_list_add_symbol (completion_tracker &tracker,
                            const lookup_name_info &lookup_name,
                            const char *text, const char *word)
 {
-  completion_list_add_name (tracker, sym->language (),
-                           sym->natural_name (),
-                           lookup_name, text, word);
+  if (!completion_list_add_name (tracker, sym->language (),
+                                sym->natural_name (),
+                                lookup_name, text, word))
+    return;
 
   /* C++ function symbols include the parameters within both the msymbol
      name and the symbol name.  The problem is that the msymbol name will
@@ -5488,7 +5475,7 @@ completion_list_add_fields (completion_tracker &tracker,
       int j;
 
       if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
-       for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+       for (j = TYPE_N_BASECLASSES (t); j < t->num_fields (); j++)
          if (TYPE_FIELD_NAME (t, j))
            completion_list_add_name (tracker, sym->language (),
                                      TYPE_FIELD_NAME (t, j),
This page took 0.029344 seconds and 4 git commands to generate.