]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make minimal symbol range adapter a method on objfile
authorTom Tromey <tom@tromey.com>
Wed, 16 Jan 2019 14:18:58 +0000 (07:18 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 17 Jan 2019 22:43:37 +0000 (15:43 -0700)
This removes class objfile_msymbols in favor of a method on the
objfile.

2019-01-16  Tom Tromey  <tom@tromey.com>

* objfiles.h (struct minimal_symbol_iterator): Rename.  Move
earlier.
(struct objfile) <msymbols_range>: Move from top level.
<msymbols>: New method.
(class objfile_msymbols): Remove.
* symtab.c (default_collect_symbol_completion_matches_break_on):
Update.
* symmisc.c (dump_msymbols): Update.
* stabsread.c (scan_file_globals): Update.
* objc-lang.c (info_selectors_command, info_classes_command)
(find_methods): Update.
* minsyms.c (find_solib_trampoline_target): Update.
* hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update.
* coffread.c (coff_symfile_read): Update.
* ada-lang.c (ada_lookup_simple_minsym)
(ada_collect_symbol_completion_matches): Update.

gdb/ChangeLog
gdb/ada-lang.c
gdb/coffread.c
gdb/hppa-tdep.c
gdb/minsyms.c
gdb/objc-lang.c
gdb/objfiles.h
gdb/stabsread.c
gdb/symmisc.c
gdb/symtab.c

index 7d1ed3fac1a5a28812eb04aa9a49d7f30010f3d5..ac3cf075216b444b0b3699fa81d05a79549577cf 100644 (file)
@@ -1,3 +1,22 @@
+2019-01-16  Tom Tromey  <tom@tromey.com>
+
+       * objfiles.h (struct minimal_symbol_iterator): Rename.  Move
+       earlier.
+       (struct objfile) <msymbols_range>: Move from top level.
+       <msymbols>: New method.
+       (class objfile_msymbols): Remove.
+       * symtab.c (default_collect_symbol_completion_matches_break_on):
+       Update.
+       * symmisc.c (dump_msymbols): Update.
+       * stabsread.c (scan_file_globals): Update.
+       * objc-lang.c (info_selectors_command, info_classes_command)
+       (find_methods): Update.
+       * minsyms.c (find_solib_trampoline_target): Update.
+       * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update.
+       * coffread.c (coff_symfile_read): Update.
+       * ada-lang.c (ada_lookup_simple_minsym)
+       (ada_collect_symbol_completion_matches): Update.
+
 2019-01-16  Tom Tromey  <tom@tromey.com>
 
        * objfiles.h (class objfile_msymbols) <iterator>: Change argument
index 7d997543c2630514be3e4e5f3a9b5adf0d5b527c..944a729bc431301b928484868861e2142bebffaf 100644 (file)
@@ -4924,7 +4924,7 @@ ada_lookup_simple_minsym (const char *name)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+      for (minimal_symbol *msymbol : objfile->msymbols ())
        {
          if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL)
              && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline)
@@ -6411,7 +6411,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+      for (minimal_symbol *msymbol : objfile->msymbols ())
        {
          QUIT;
 
index 2b75d8189fb7fe956f78d3a1e4bbf834a8e8f0b7..6381cd3f370978b7465d332cd44afade18654b16 100644 (file)
@@ -661,7 +661,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
   if (pe_file)
     {
-      for (minimal_symbol *msym : objfile_msymbols (objfile))
+      for (minimal_symbol *msym : objfile->msymbols ())
        {
          const char *name = MSYMBOL_LINKAGE_NAME (msym);
 
index 46deeac90c85bc73d5bbf5e4cdff15f960738f68..866e6cf6dea3dc5cc8e9fb7a4dd2dc9cbb75b7c8 100644 (file)
@@ -2544,7 +2544,7 @@ hppa_lookup_stub_minimal_symbol (const char *name,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (minimal_symbol *msym : objfile_msymbols (objfile))
+      for (minimal_symbol *msym : objfile->msymbols ())
        {
          if (strcmp (MSYMBOL_LINKAGE_NAME (msym), name) == 0)
            {
index 053c93ece8eaa3b0d58b268416adfbbf2a415c6f..7cd7ba9f676de3f93f6d98c03f4206e763eecc16 100644 (file)
@@ -1494,7 +1494,7 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
     {
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              /* Also handle minimal symbols pointing to function
                 descriptors.  */
index accd378816f672061c5d68845a0b6e9e07b5d13a..ceef482ae35a3f426c0986675d15c11c4d7542d3 100644 (file)
@@ -607,7 +607,7 @@ info_selectors_command (const char *regexp, int from_tty)
   /* First time thru is JUST to get max length and count.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+      for (minimal_symbol *msymbol : objfile->msymbols ())
        {
          QUIT;
          name = MSYMBOL_NATURAL_NAME (msymbol);
@@ -647,7 +647,7 @@ info_selectors_command (const char *regexp, int from_tty)
       matches = 0;
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              QUIT;
              name = MSYMBOL_NATURAL_NAME (msymbol);
@@ -761,7 +761,7 @@ info_classes_command (const char *regexp, int from_tty)
   /* First time thru is JUST to get max length and count.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+      for (minimal_symbol *msymbol : objfile->msymbols ())
        {
          QUIT;
          name = MSYMBOL_NATURAL_NAME (msymbol);
@@ -788,7 +788,7 @@ info_classes_command (const char *regexp, int from_tty)
       matches = 0;
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              QUIT;
              name = MSYMBOL_NATURAL_NAME (msymbol);
@@ -1008,7 +1008,7 @@ find_methods (char type, const char *theclass, const char *category,
        /* There are no ObjC symbols in this objfile.  Skip it entirely.  */
        continue;
 
-      for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+      for (minimal_symbol *msymbol : objfile->msymbols ())
        {
          QUIT;
 
index 2e0fad69c0018cec79bee179e5c47b5dec2c0059..5f106d98358d6d1f4fb56d39eca2e93f1aed1f81 100644 (file)
@@ -182,6 +182,47 @@ extern void print_symbol_bcache_statistics (void);
 /* Number of entries in the minimal symbol hash table.  */
 #define MINIMAL_SYMBOL_HASH_SIZE 2039
 
+/* An iterator for minimal symbols.  */
+
+struct minimal_symbol_iterator
+{
+  typedef minimal_symbol_iterator self_type;
+  typedef struct minimal_symbol *value_type;
+  typedef struct minimal_symbol *&reference;
+  typedef struct minimal_symbol **pointer;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef int difference_type;
+
+  explicit minimal_symbol_iterator (struct minimal_symbol *msym)
+    : m_msym (msym)
+  {
+  }
+
+  value_type operator* () const
+  {
+    return m_msym;
+  }
+
+  bool operator== (const self_type &other) const
+  {
+    return m_msym == other.m_msym;
+  }
+
+  bool operator!= (const self_type &other) const
+  {
+    return m_msym != other.m_msym;
+  }
+
+  self_type &operator++ ()
+  {
+    ++m_msym;
+    return *this;
+  }
+
+private:
+  struct minimal_symbol *m_msym;
+};
+
 /* Some objfile data is hung off the BFD.  This enables sharing of the
    data across all objfiles using the BFD.  The data is stored in an
    instance of this structure, and associated with the BFD using the
@@ -319,6 +360,44 @@ struct objfile
     return compunits_range (compunit_symtabs);
   }
 
+  /* A range adapter that makes it possible to iterate over all
+     minimal symbols of an objfile.  */
+
+  class msymbols_range
+  {
+  public:
+
+    explicit msymbols_range (struct objfile *objfile)
+      : m_objfile (objfile)
+    {
+    }
+
+    minimal_symbol_iterator begin () const
+    {
+      return minimal_symbol_iterator (m_objfile->per_bfd->msymbols);
+    }
+
+    minimal_symbol_iterator end () const
+    {
+      return minimal_symbol_iterator
+       (m_objfile->per_bfd->msymbols
+        + m_objfile->per_bfd->minimal_symbol_count);
+    }
+
+  private:
+
+    struct objfile *m_objfile;
+  };
+
+  /* Return a range adapter for iterating over all minimal
+     symbols.  */
+
+  msymbols_range msymbols ()
+  {
+    return msymbols_range (this);
+  }
+
+
   /* All struct objfile's are chained together by their next pointers.
      The program space field "objfiles"  (frequently referenced via
      the macro "object_files") points to the first link in this chain.  */
@@ -570,73 +649,6 @@ extern void default_iterate_over_objfiles_in_search_order
    void *cb_data, struct objfile *current_objfile);
 \f
 
-/* A range adapter that makes it possible to iterate over all
-   minimal symbols of an objfile.  */
-
-class objfile_msymbols
-{
-public:
-
-  explicit objfile_msymbols (struct objfile *objfile)
-    : m_objfile (objfile)
-  {
-  }
-
-  struct iterator
-  {
-    typedef iterator self_type;
-    typedef struct minimal_symbol *value_type;
-    typedef struct minimal_symbol *&reference;
-    typedef struct minimal_symbol **pointer;
-    typedef std::forward_iterator_tag iterator_category;
-    typedef int difference_type;
-
-    explicit iterator (struct minimal_symbol *msym)
-      : m_msym (msym)
-    {
-    }
-
-    value_type operator* () const
-    {
-      return m_msym;
-    }
-
-    bool operator== (const self_type &other) const
-    {
-      return m_msym == other.m_msym;
-    }
-
-    bool operator!= (const self_type &other) const
-    {
-      return m_msym != other.m_msym;
-    }
-
-    self_type &operator++ ()
-    {
-      ++m_msym;
-      return *this;
-    }
-
-  private:
-    struct minimal_symbol *m_msym;
-  };
-
-  iterator begin () const
-  {
-    return iterator (m_objfile->per_bfd->msymbols);
-  }
-
-  iterator end () const
-  {
-    return iterator (m_objfile->per_bfd->msymbols
-                    + m_objfile->per_bfd->minimal_symbol_count);
-  }
-
-private:
-
-  struct objfile *m_objfile;
-};
-
 #define ALL_OBJFILE_OSECTIONS(objfile, osect)  \
   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
     if (osect->the_bfd_section == NULL)                                        \
index daba7cb98b6946ed6d832eab97728db8aa36c881..fc41c8fc86f156c60af12a173b5f47fc9393da04 100644 (file)
@@ -4598,7 +4598,7 @@ scan_file_globals (struct objfile *objfile)
       if (hash >= HASHSIZE)
        return;
 
-      for (minimal_symbol *msymbol : objfile_msymbols (resolve_objfile))
+      for (minimal_symbol *msymbol : resolve_objfile->msymbols ())
        {
          QUIT;
 
index ac5c392dc5d823fc33d7022ee2aca44cab907c50..bb4fdfd1ed92e54ceb21eaeda1a276f481e3eef7 100644 (file)
@@ -197,7 +197,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       return;
     }
   index = 0;
-  for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+  for (minimal_symbol *msymbol : objfile->msymbols ())
     {
       struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
 
index b8ebbc2e1a04119ed69dbc554ab5b171fcb81876..a2bd4dd54de805c29c7d9866e51f768cdee82867 100644 (file)
@@ -4455,7 +4455,7 @@ search_symbols (const char *regexp, enum search_domain kind,
     {
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              QUIT;
 
@@ -4558,7 +4558,7 @@ search_symbols (const char *regexp, enum search_domain kind,
     {
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              QUIT;
 
@@ -5274,7 +5274,7 @@ default_collect_symbol_completion_matches_break_on
     {
       for (objfile *objfile : current_program_space->objfiles ())
        {
-         for (minimal_symbol *msymbol : objfile_msymbols (objfile))
+         for (minimal_symbol *msymbol : objfile->msymbols ())
            {
              QUIT;