Change minimal_symbol_reader to store objfile
authorTom Tromey <tom@tromey.com>
Thu, 22 Sep 2016 19:57:15 +0000 (13:57 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 21 Oct 2016 20:17:33 +0000 (14:17 -0600)
This changes minimal_symbol_reader to require the objfile to be
passed to the constructor.  The class now records the objfile and
automatically uses it later in "install".

This is a minor cleanup that will come in useful in the next patch.
It is separate from the first patch to keep that one a bit simpler to
understand.

2016-10-21  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_initial_scan): Update.
* mipsread.c (mipscoff_symfile_read): Update.
* minsyms.c (minimal_symbol_reader): Add obj argument.
Initialize member.
(install): Remove objfile argument.  Update.
* mdebugread.c (elfmdebug_build_psymtabs): Update.
* machoread.c (macho_symfile_read): Update.
* elfread.c (elf_read_minimal_symbols): Update.
* dbxread.c (dbx_symfile_read): Update.
* coffread.c (coff_symfile_read): Update.
* minsyms.h (minimal_symbol_reader): Add m_objfile member.
(constructor): Add objfile argument.
(minimal_symbol_reader::install): Remove objfile argument.

gdb/ChangeLog
gdb/coffread.c
gdb/dbxread.c
gdb/elfread.c
gdb/machoread.c
gdb/mdebugread.c
gdb/minsyms.c
gdb/minsyms.h
gdb/mipsread.c
gdb/xcoffread.c

index 017396c36c5867044682b07d691247764c1cf2c4..e8a997acc33443b3f27abf3966a2ea824e0b9aa2 100644 (file)
@@ -1,3 +1,19 @@
+2016-10-21  Tom Tromey  <tom@tromey.com>
+
+       * xcoffread.c (xcoff_initial_scan): Update.
+       * mipsread.c (mipscoff_symfile_read): Update.
+       * minsyms.c (minimal_symbol_reader): Add obj argument.
+       Initialize member.
+       (install): Remove objfile argument.  Update.
+       * mdebugread.c (elfmdebug_build_psymtabs): Update.
+       * machoread.c (macho_symfile_read): Update.
+       * elfread.c (elf_read_minimal_symbols): Update.
+       * dbxread.c (dbx_symfile_read): Update.
+       * coffread.c (coff_symfile_read): Update.
+       * minsyms.h (minimal_symbol_reader): Add m_objfile member.
+       (constructor): Add objfile argument.
+       (minimal_symbol_reader::install): Remove objfile argument.
+
 2016-10-21  Tom Tromey  <tom@tromey.com>
 
        * xcoffread.c (xcoff_initial_scan): Use
index 67b9cb7eb7716fb00d8525d90d254e18c4a79bea..b4de08e76ff0cd06ad7ed11487ff7b5caa657964 100644 (file)
@@ -645,7 +645,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
   if (val < 0)
     error (_("\"%s\": can't get string table"), name);
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
 
   /* Now that the executable file is positioned at symbol table,
      process it and define symbols accordingly.  */
@@ -655,7 +655,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
   /* Install any minimal symbols that have been collected as the
      current minimal symbols for this objfile.  */
 
-  reader.install (objfile);
+  reader.install ();
 
   if (pe_file)
     {
index 26d50e10007e9bbda7cc27e725f5864e895fc3d8..a5bb2e05c63843d0f9ccb23fc870ff77d729bfa2 100644 (file)
@@ -558,7 +558,7 @@ dbx_symfile_read (struct objfile *objfile, int symfile_flags)
   free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
 
   /* Read stabs data from executable file and define symbols.  */
 
@@ -571,7 +571,7 @@ dbx_symfile_read (struct objfile *objfile, int symfile_flags)
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile.  */
 
-  reader.install (objfile);
+  reader.install ();
 
   do_cleanups (back_to);
 }
index 4f55e379616d9be3c1259d2bf2dc7eef32390ba2..58e0cbc1da11410c45f1985f31fe746c8555b105 100644 (file)
@@ -1049,7 +1049,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
       return;
     }
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
   back_to = make_cleanup (null_cleanup, NULL);
 
   /* Allocate struct to keep track of the symfile.  */
@@ -1149,7 +1149,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
      responsibility to install them.  "mdebug" appears to be the only one
      which will do this.  */
 
-  reader.install (objfile);
+  reader.install ();
   do_cleanups (back_to);
 
   if (symtab_create_debug)
index 45ae67b071274e2576c5ce334d6478bbbddc5daa..1f82f2bb856101d47e2a36152e9a7f275e1d87eb 100644 (file)
@@ -855,7 +855,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
          symbol_table = (asymbol **) xmalloc (storage_needed);
          make_cleanup (xfree, symbol_table);
 
-          minimal_symbol_reader reader;
+          minimal_symbol_reader reader (objfile);
 
          symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
 
@@ -866,7 +866,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
 
          macho_symtab_read (objfile, symcount, symbol_table, &oso_vector);
 
-          reader.install (objfile);
+          reader.install ();
        }
 
       /* Try to read .eh_frame / .debug_frame.  */
index 358ee70fd23abf9d358d2b7eff0e19ac63e99cc4..1285db4fca6261297c19473e8909259d4aa1c6da 100644 (file)
@@ -4875,7 +4875,7 @@ elfmdebug_build_psymtabs (struct objfile *objfile,
      information from .mdebug in an ELF file, or whether we will.
      Re-initialize the minimal symbol reader in case we do.  */
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
 
   info = ((struct ecoff_debug_info *)
          obstack_alloc (&objfile->objfile_obstack,
@@ -4887,7 +4887,7 @@ elfmdebug_build_psymtabs (struct objfile *objfile,
 
   mdebug_build_psymtabs (objfile, swap, info);
 
-  reader.install (objfile);
+  reader.install ();
 }
 
 void
index a100d4ca5cc3a1d5a48aa231fffd55d4aaf21f23..9de572295e1fbf461d109dd8c3789daa99cbbe0e 100644 (file)
@@ -921,7 +921,8 @@ get_symbol_leading_char (bfd *abfd)
 
 /* See minsyms.h.  */
 
-minimal_symbol_reader::minimal_symbol_reader ()
+minimal_symbol_reader::minimal_symbol_reader (struct objfile *obj)
+: m_objfile (obj)
 {
   msym_count = 0;
   msym_bunch = NULL;
@@ -1232,7 +1233,7 @@ build_minimal_symbol_hash_tables (struct objfile *objfile)
    attempts to demangle them if we later add more minimal symbols.  */
 
 void
-minimal_symbol_reader::install (struct objfile *objfile)
+minimal_symbol_reader::install ()
 {
   int bindex;
   int mcount;
@@ -1240,7 +1241,7 @@ minimal_symbol_reader::install (struct objfile *objfile)
   struct minimal_symbol *msymbols;
   int alloc_count;
 
-  if (objfile->per_bfd->minsyms_read)
+  if (m_objfile->per_bfd->minsyms_read)
     return;
 
   if (msym_count > 0)
@@ -1249,7 +1250,7 @@ minimal_symbol_reader::install (struct objfile *objfile)
        {
          fprintf_unfiltered (gdb_stdlog,
                              "Installing %d minimal symbols of objfile %s.\n",
-                             msym_count, objfile_name (objfile));
+                             msym_count, objfile_name (m_objfile));
        }
 
       /* Allocate enough space in the obstack, into which we will gather the
@@ -1257,17 +1258,17 @@ minimal_symbol_reader::install (struct objfile *objfile)
          compact out the duplicate entries.  Once we have a final table,
          we will give back the excess space.  */
 
-      alloc_count = msym_count + objfile->per_bfd->minimal_symbol_count + 1;
-      obstack_blank (&objfile->per_bfd->storage_obstack,
+      alloc_count = msym_count + m_objfile->per_bfd->minimal_symbol_count + 1;
+      obstack_blank (&m_objfile->per_bfd->storage_obstack,
                     alloc_count * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
-       obstack_base (&objfile->per_bfd->storage_obstack);
+       obstack_base (&m_objfile->per_bfd->storage_obstack);
 
       /* Copy in the existing minimal symbols, if there are any.  */
 
-      if (objfile->per_bfd->minimal_symbol_count)
-       memcpy ((char *) msymbols, (char *) objfile->per_bfd->msymbols,
-           objfile->per_bfd->minimal_symbol_count * sizeof (struct minimal_symbol));
+      if (m_objfile->per_bfd->minimal_symbol_count)
+       memcpy ((char *) msymbols, (char *) m_objfile->per_bfd->msymbols,
+           m_objfile->per_bfd->minimal_symbol_count * sizeof (struct minimal_symbol));
 
       /* Walk through the list of minimal symbol bunches, adding each symbol
          to the new contiguous array of symbols.  Note that we start with the
@@ -1275,7 +1276,7 @@ minimal_symbol_reader::install (struct objfile *objfile)
          msym_bunch_index for the first bunch we copy over), and thereafter
          each bunch is full.  */
 
-      mcount = objfile->per_bfd->minimal_symbol_count;
+      mcount = m_objfile->per_bfd->minimal_symbol_count;
 
       for (bunch = msym_bunch; bunch != NULL; bunch = bunch->next)
        {
@@ -1292,12 +1293,12 @@ minimal_symbol_reader::install (struct objfile *objfile)
       /* Compact out any duplicates, and free up whatever space we are
          no longer using.  */
 
-      mcount = compact_minimal_symbols (msymbols, mcount, objfile);
+      mcount = compact_minimal_symbols (msymbols, mcount, m_objfile);
 
-      obstack_blank_fast (&objfile->per_bfd->storage_obstack,
+      obstack_blank_fast (&m_objfile->per_bfd->storage_obstack,
               (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
-       obstack_finish (&objfile->per_bfd->storage_obstack);
+       obstack_finish (&m_objfile->per_bfd->storage_obstack);
 
       /* We also terminate the minimal symbol table with a "null symbol",
          which is *not* included in the size of the table.  This makes it
@@ -1313,14 +1314,14 @@ minimal_symbol_reader::install (struct objfile *objfile)
          The strings themselves are also located in the storage_obstack
          of this objfile.  */
 
-      objfile->per_bfd->minimal_symbol_count = mcount;
-      objfile->per_bfd->msymbols = msymbols;
+      m_objfile->per_bfd->minimal_symbol_count = mcount;
+      m_objfile->per_bfd->msymbols = msymbols;
 
       /* Now build the hash tables; we can't do this incrementally
          at an earlier point since we weren't finished with the obstack
         yet.  (And if the msymbol obstack gets moved, all the internal
         pointers to other msymbols need to be adjusted.)  */
-      build_minimal_symbol_hash_tables (objfile);
+      build_minimal_symbol_hash_tables (m_objfile);
     }
 }
 
index d75bd41755832cad94d3fd6bdcb12ccc0222c144..b83e2d08b56032b2874406a2c80a33bb03eb666b 100644 (file)
@@ -64,14 +64,14 @@ class minimal_symbol_reader
      Currently, minimal symbol table creation is not reentrant; it
      relies on global (static) variables in minsyms.c.  */
 
-  explicit minimal_symbol_reader ();
+  explicit minimal_symbol_reader (struct objfile *);
 
   ~minimal_symbol_reader ();
 
   /* Install the minimal symbols that have been collected into the
      given objfile.  */
 
-  void install (struct objfile *);
+  void install ();
 
  private:
 
@@ -79,6 +79,8 @@ class minimal_symbol_reader
   minimal_symbol_reader &operator=
     (const minimal_symbol_reader &);
   minimal_symbol_reader (const minimal_symbol_reader &);
+
+  struct objfile *m_objfile;
 };
 
 /* Record a new minimal symbol.  This is the "full" entry point;
index dff1cb19333c8c044947df4be5c1a9da8591914a..256b26222c893c9993211aab43eae03462ebdbcc 100644 (file)
@@ -70,7 +70,7 @@ mipscoff_symfile_read (struct objfile *objfile, int symfile_flags)
 {
   bfd *abfd = objfile->obfd;
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
 
   /* Now that the executable file is positioned at symbol table,
      process it and define symbols accordingly.  */
@@ -89,7 +89,7 @@ mipscoff_symfile_read (struct objfile *objfile, int symfile_flags)
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile.  */
 
-  reader.install (objfile);
+  reader.install ();
 }
 
 /* Perform any local cleanups required when we are done with a
index 3c843a0a4115db7a0a6c2ebc42bc4bce4d8e14a7..ccd6149a8521f0e3bbca13f5479dedafc93b45df 100644 (file)
@@ -3006,7 +3006,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
   free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
-  minimal_symbol_reader reader;
+  minimal_symbol_reader reader (objfile);
 
   /* Now that the symbol table data of the executable file are all in core,
      process them and define symbols accordingly.  */
@@ -3016,7 +3016,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile.  */
 
-  reader.install (objfile);
+  reader.install ();
 
   /* DWARF2 sections.  */
 
This page took 0.038031 seconds and 4 git commands to generate.