From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA v2 05/17] Change minimal_symbol_reader to store objfile
Date: Thu, 13 Oct 2016 21:11:00 -0000 [thread overview]
Message-ID: <1476393012-29987-6-git-send-email-tom@tromey.com> (raw)
In-Reply-To: <1476393012-29987-1-git-send-email-tom@tromey.com>
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-09-26 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 | 16 ++++++++++++++++
gdb/coffread.c | 4 ++--
gdb/dbxread.c | 4 ++--
gdb/elfread.c | 4 ++--
gdb/machoread.c | 4 ++--
gdb/mdebugread.c | 4 ++--
gdb/minsyms.c | 35 ++++++++++++++++++-----------------
gdb/minsyms.h | 6 ++++--
gdb/mipsread.c | 4 ++--
gdb/xcoffread.c | 4 ++--
10 files changed, 52 insertions(+), 33 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 840831c..790be41 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 (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-09-26 Tom Tromey <tom@tromey.com>
+
* xcoffread.c (xcoff_initial_scan): Use
minimal_symbol_reader.
* mipsread.c (mipscoff_symfile_read): Use
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 67b9cb7..b4de08e 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);
- 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)
{
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 4f2852b..446813b 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);
- 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);
}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 4f55e37..58e0cbc 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -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)
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 45ae67b..1f82f2b 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -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. */
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 358ee70..1285db4 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. */
- 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
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 32146dc..e614ff0 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -916,7 +916,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;
@@ -1227,7 +1228,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;
@@ -1235,7 +1236,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)
@@ -1244,7 +1245,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
@@ -1252,17 +1253,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
@@ -1270,7 +1271,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)
{
@@ -1287,12 +1288,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
@@ -1308,14 +1309,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);
}
}
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index d75bd41..b83e2d0 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -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;
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index dff1cb1..256b262 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;
- 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
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 76d6d79..2656d4c 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);
- 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. */
--
2.7.4
next prev parent reply other threads:[~2016-10-13 21:11 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-13 21:11 [RFA v2 00/17] more C++ Tom Tromey
2016-10-13 21:11 ` [RFA v2 04/17] Introduce minimal_symbol_reader Tom Tromey
2016-10-13 22:20 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 08/17] Remove some cleanups in MI Tom Tromey
2016-10-13 22:38 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 15/17] Convert DWARF expr functions to methods Tom Tromey
2016-10-13 23:01 ` Pedro Alves
2016-10-20 21:47 ` Tom Tromey
2016-10-20 22:01 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 12/17] Remove make_cleanup_restore_current_uiout Tom Tromey
2016-10-13 22:49 ` Pedro Alves
2016-10-14 21:30 ` Tom Tromey
2016-10-20 21:46 ` Tom Tromey
2016-10-20 21:57 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 06/17] Record minimal symbols directly in reader Tom Tromey
2016-10-13 22:34 ` Pedro Alves
2016-10-14 21:22 ` Tom Tromey
2016-10-20 21:47 ` Tom Tromey
2016-10-20 22:13 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 16/17] Convert dwarf_expr_context_funcs to methods Tom Tromey
2016-10-13 23:05 ` Pedro Alves
2016-10-18 2:50 ` Tom Tromey
2016-10-18 10:51 ` Pedro Alves
2016-10-18 14:55 ` Tom Tromey
2016-10-18 17:38 ` Pedro Alves
2016-10-19 22:29 ` Tom Tromey
2016-10-20 21:48 ` Tom Tromey
2016-10-20 21:56 ` Pedro Alves
2016-10-28 13:36 ` Pedro Alves
2016-10-31 2:48 ` Tom Tromey
2016-11-01 22:07 ` Tom Tromey
2016-11-02 16:12 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 14/17] Initial conversion of dwarf_expr_ctx Tom Tromey
2016-10-13 22:54 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 01/17] Use RAII to save and restore scalars Tom Tromey
2016-10-13 22:03 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 11/17] Use gdb::unique_ptr in elf_read_minimal_symbols Tom Tromey
2016-10-13 22:44 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 07/17] Remove make_cleanup_restore_current_ui Tom Tromey
2016-10-13 22:37 ` Pedro Alves
2016-10-13 21:11 ` Tom Tromey [this message]
2016-10-13 22:21 ` [RFA v2 05/17] Change minimal_symbol_reader to store objfile Pedro Alves
2016-10-13 21:11 ` [RFA v2 03/17] Use scoped_restore for current_ui Tom Tromey
2016-10-13 22:16 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 10/17] Replace two xmallocs with unique_ptr Tom Tromey
2016-10-13 22:44 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 02/17] Use scoped_restore for ui_file Tom Tromey
2016-10-13 22:07 ` Pedro Alves
2016-10-14 21:33 ` Tom Tromey
2016-10-13 21:13 ` [RFA v2 13/17] Some cleanup removal in dwarf2loc.c Tom Tromey
2016-10-13 22:52 ` Pedro Alves
2016-10-13 21:14 ` [RFA v2 09/17] Change command stats reporting to use class Tom Tromey
2016-10-13 22:43 ` Pedro Alves
2016-10-13 21:18 ` [RFA v2 17/17] Remove last cleanup from captured_main_1 Tom Tromey
2016-10-13 23:13 ` Pedro Alves
2016-10-13 21:39 ` [RFA v2 00/17] more C++ Pedro Alves
2016-10-14 16:26 ` Pedro Alves
2016-10-20 21:49 ` Tom Tromey
2016-10-20 22:27 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476393012-29987-6-git-send-email-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).