diff options
author | Tom Tromey <tromey@redhat.com> | 2013-10-15 11:37:19 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-02-26 12:11:17 -0700 |
commit | 34643a32c6b17041b7ebc13ac3077f6eaec7ec80 (patch) | |
tree | 5febf13c3c8c850bc9a8303ab20ab871981023e6 /gdb/objfiles.h | |
parent | 2273f0ac95a79ce29ef42025c63f90e82cf907d7 (diff) | |
download | gdb-34643a32c6b17041b7ebc13ac3077f6eaec7ec80.zip gdb-34643a32c6b17041b7ebc13ac3077f6eaec7ec80.tar.gz gdb-34643a32c6b17041b7ebc13ac3077f6eaec7ec80.tar.bz2 |
move minimal symbols to per-bfd
Now that minimal symbols are independent of the program space, we can
move them to the per-BFD object. This lets us save memory in the
multi-inferior case; and, once the symbol readers are updated, time.
The other prerequisite for this move is that all the objects referred
to by the minimal symbols have a lifetime at least as long as the
per-BFD object. I think this is satisfied partially by this patch
(moving the copied names there) and partially by earlier patches
moving the demangled name hash.
This patch contains a bit of logic to avoid creating new minimal
symbols if they have already been read for a given BFD. This allows
us to avoid trying to update all the symbol readers for this
condition. At first glance this may seem like a hack, but some symbol
readers mix psym and minsym reading, and would require logic just like
this regardless -- and it is simpler and less error-prone to just do
the work in a central spot.
2014-02-26 Tom Tromey <tromey@redhat.com>
* minsyms.c (lookup_minimal_symbol, iterate_over_minimal_symbols)
(lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name)
(lookup_minimal_symbol_solib_trampoline)
(lookup_minimal_symbol_by_pc_section_1)
(lookup_minimal_symbol_and_objfile): Update.
(prim_record_minimal_symbol_full): Use the per-BFD obstack.
Don't allocate a minimal symbol if minsyms have already been read.
(build_minimal_symbol_hash_tables): Update.
(install_minimal_symbols): Do nothing if minsyms already read.
Use the per-BFD obstack.
(terminate_minimal_symbol_table): Use the per-BFD obstack.
* objfiles.c (allocate_objfile): Call
terminate_minimal_symbol_table later.
(have_minimal_symbols): Update.
* objfiles.h (struct objfile_per_bfd_storage) <msymbols,
minimal_symbol_count, msymbol_hash, msymbol_demangled_hash>:
Move from struct objfile.
<minsyms_read>: New field.
(struct objfile) <msymbols, minimal_symbol_count,
msymbol_hash, msymbol_demangled_hash>: Move.
(ALL_OBJFILE_MSYMBOLS): Update.
* symfile.c (read_symbols): Set minsyms_read.
(reread_symbols): Update.
* symmisc.c (dump_objfile, dump_msymbols): Update.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r-- | gdb/objfiles.h | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 64a371d..d585bc4 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -210,6 +210,38 @@ struct objfile_per_bfd_storage const char *name_of_main; enum language language_of_main; + + /* Each file contains a pointer to an array of minimal symbols for all + global symbols that are defined within the file. The array is + terminated by a "null symbol", one that has a NULL pointer for the + name and a zero value for the address. This makes it easy to walk + through the array when passed a pointer to somewhere in the middle + of it. There is also a count of the number of symbols, which does + not include the terminating null symbol. The array itself, as well + as all the data that it points to, should be allocated on the + objfile_obstack for this file. */ + + struct minimal_symbol *msymbols; + int minimal_symbol_count; + + /* This is true if minimal symbols have already been read. Symbol + readers can use this to bypass minimal symbol reading. Also, the + minimal symbol table management code in minsyms.c uses this to + suppress new minimal symbols. You might think that MSYMBOLS or + MINIMAL_SYMBOL_COUNT could be used for this, but it is possible + for multiple readers to install minimal symbols into a given + per-BFD. */ + + unsigned int minsyms_read : 1; + + /* This is a hash table used to index the minimal symbols by name. */ + + struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE]; + + /* This hash table is used to index the minimal symbols by their + demangled names. */ + + struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE]; }; /* Master structure for keeping track of each file from which @@ -303,28 +335,6 @@ struct objfile struct psymbol_allocation_list global_psymbols; struct psymbol_allocation_list static_psymbols; - /* Each file contains a pointer to an array of minimal symbols for all - global symbols that are defined within the file. The array is - terminated by a "null symbol", one that has a NULL pointer for the - name and a zero value for the address. This makes it easy to walk - through the array when passed a pointer to somewhere in the middle - of it. There is also a count of the number of symbols, which does - not include the terminating null symbol. The array itself, as well - as all the data that it points to, should be allocated on the - objfile_obstack for this file. */ - - struct minimal_symbol *msymbols; - int minimal_symbol_count; - - /* This is a hash table used to index the minimal symbols by name. */ - - struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE]; - - /* This hash table is used to index the minimal symbols by their - demangled names. */ - - struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE]; - /* Structure which keeps track of functions that manipulate objfile's of the same type as this objfile. I.e. the function to read partial symbols for example. Note that this structure is in statically @@ -588,8 +598,10 @@ extern void default_iterate_over_objfiles_in_search_order /* Traverse all minimal symbols in one objfile. */ -#define ALL_OBJFILE_MSYMBOLS(objfile, m) \ - for ((m) = (objfile) -> msymbols; MSYMBOL_LINKAGE_NAME(m) != NULL; (m)++) +#define ALL_OBJFILE_MSYMBOLS(objfile, m) \ + for ((m) = (objfile)->per_bfd->msymbols; \ + MSYMBOL_LINKAGE_NAME (m) != NULL; \ + (m)++) /* Traverse all symtabs in all objfiles in the current symbol space. */ |