This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 07/22] Change scoped_minimal_symbol_reader to store objfile


This changes scoped_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-09-26  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Update.
	* mipsread.c (mipscoff_symfile_read): Update.
	* minsyms.c (scoped_minimal_symbol_reader): Add obj argument.
	Initialize member.
	(install): Remove objfile argument.
	* 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 (scoped_minimal_symbol_reader): Add objfile member.
	(constructor): Add objfile argument.
	(scoped_minimal_symbol_reader::install): Remove objfile argument.
---
 gdb/ChangeLog    | 16 ++++++++++++++++
 gdb/coffread.c   |  4 ++--
 gdb/dbxread.c    |  4 ++--
 gdb/elfread.c    |  4 ++--
 gdb/machoread.c  |  4 ++--
 gdb/mdebugread.c |  4 ++--
 gdb/minsyms.c    |  5 +++--
 gdb/minsyms.h    |  6 ++++--
 gdb/mipsread.c   |  4 ++--
 gdb/xcoffread.c  |  4 ++--
 10 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 81aeec9..dac71f3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
 2016-09-26  Tom Tromey  <tom@tromey.com>
 
+	* xcoffread.c (xcoff_initial_scan): Update.
+	* mipsread.c (mipscoff_symfile_read): Update.
+	* minsyms.c (scoped_minimal_symbol_reader): Add obj argument.
+	Initialize member.
+	(install): Remove objfile argument.
+	* 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 (scoped_minimal_symbol_reader): Add objfile member.
+	(constructor): Add objfile argument.
+	(scoped_minimal_symbol_reader::install): Remove objfile argument.
+
+2016-09-26  Tom Tromey  <tom@tromey.com>
+
 	* xcoffread.c (xcoff_initial_scan): Use
 	scoped_minimal_symbol_reader.
 	* mipsread.c (mipscoff_symfile_read): Use
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e504cde..a86f223 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -645,7 +645,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
   if (val < 0)
     error (_("\"%s\": can't get string table"), name);
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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)
     {
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index a0e1cac..59c809a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -558,7 +558,7 @@ dbx_symfile_read (struct objfile *objfile, int symfile_flags)
   free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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);
 }
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e1ae92a..98574ca 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1049,7 +1049,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
       return;
     }
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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)
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 19a2f42..0eb438a 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -861,7 +861,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
 	  symbol_table = (asymbol **) xmalloc (storage_needed);
 	  make_cleanup (xfree, symbol_table);
 
-          scoped_minimal_symbol_reader reader;
+          scoped_minimal_symbol_reader reader (objfile);
 
 	  symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
 
@@ -872,7 +872,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.  */
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index d07e683..b93024b 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -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.  */
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 7b316ce..b6f306b 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -921,7 +921,8 @@ get_symbol_leading_char (bfd *abfd)
 
 /* See minsyms.h.  */
 
-scoped_minimal_symbol_reader::scoped_minimal_symbol_reader ()
+scoped_minimal_symbol_reader::scoped_minimal_symbol_reader (struct objfile *obj)
+: 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
-scoped_minimal_symbol_reader::install (struct objfile *objfile)
+scoped_minimal_symbol_reader::install ()
 {
   int bindex;
   int mcount;
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 5ea3610..7ba5991 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -64,14 +64,14 @@ class scoped_minimal_symbol_reader
      Currently, minimal symbol table creation is not reentrant; it
      relies on global (static) variables in minsyms.c.  */
 
-  explicit scoped_minimal_symbol_reader ();
+  explicit scoped_minimal_symbol_reader (struct objfile *);
 
   ~scoped_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 scoped_minimal_symbol_reader
   scoped_minimal_symbol_reader &operator=
     (const scoped_minimal_symbol_reader &);
   scoped_minimal_symbol_reader (const scoped_minimal_symbol_reader &);
+
+  struct objfile *objfile;
 };
 
 /* Record a new minimal symbol.  This is the "full" entry point;
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index da09c03..e5285d2 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -70,7 +70,7 @@ mipscoff_symfile_read (struct objfile *objfile, int symfile_flags)
 {
   bfd *abfd = objfile->obfd;
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 81b323c..6545e94 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3006,7 +3006,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
   free_pending_blocks ();
   back_to = make_cleanup (really_free_pendings, 0);
 
-  scoped_minimal_symbol_reader reader;
+  scoped_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.  */
 
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]