aboutsummaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-22 13:57:15 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:33 -0600
commitd25e87199327846e42b5a23f4365d75e75517ab3 (patch)
tree78c9a15317d99e16229021085b82c275d93e2ef5 /gdb/minsyms.c
parent873a915e0ad44cb303b071638536f27569491030 (diff)
downloadgdb-d25e87199327846e42b5a23f4365d75e75517ab3.zip
gdb-d25e87199327846e42b5a23f4365d75e75517ab3.tar.gz
gdb-d25e87199327846e42b5a23f4365d75e75517ab3.tar.bz2
Change minimal_symbol_reader to store objfile
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.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r--gdb/minsyms.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a100d4c..9de5722 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -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);
}
}