Age | Commit message (Collapse) | Author | Files | Lines |
|
While working on some changes to 'info sources' I ran into a situation
where I was seeing the same source files reported twice in the output
of the 'info sources' command when using either .gdb_index or the
.debug_name index.
I traced the problem back to some caching in
dwarf2_base_index_functions::map_symbol_filenames; when called GDB
caches the set of filenames, but, filesnames are not removed as the
index entries are expanded into full symtabs. As a result we can end
up seeing filenames reported both from a full symtab _and_ from
a (stale) previously cached index entry.
Now, obviously, when seeing a problem like this the "correct" fix is
to remove the stale entries from the cache, however, I ran a few
experiments to see why this wasn't really hitting us anywhere, and, as
far as I can tell, ::map_symbol_filenames is only called from three
places:
1. The mi command -file-list-exec-source-files,
2. The 'info sources' command, and
3. Filename completion
However, the result of this "bug" is that we will see duplicate
filenames, and readline's completion mechanism already removes
duplicates, so for case #3 we will never see any problems.
Cases #1 and #2 are basically the same, and in each case, to see a
problem we need to ensure we craft the test in a particular way, start
up ensuring we have some unexpected symtabs, then run one of the
commands to populate the cache, then expand one of the symtabs, and
list the sources again. At this point you'll see duplicate entries in
the results. Hardly surprising we haven't randomly hit this situation
in testing.
So, considering that use cases #1 and #2 are certainly not "high
performance" code (i.e. I don't think these justify the need for
caching) this leaves use case #3. Does this use justify the need for
caching? Well the psymbol_functions::map_symbol_filenames function
doesn't seem to do any extra caching, and within
dwarf2_base_index_functions::map_symbol_filenames, the only expensive
bit appears to be the call to dw2_get_file_names, and this already
does its own caching via this_cu->v.quick->file_names.
The upshot of all this analysis was that I'm not convinced the need
for the additional caching is justified, and so, I propose that to fix
the bug in GDB, I just remove the extra caching (for now).
If we later find that the caching _was_ useful, then we can
reintroduce it, but add it back such that it doesn't reintroduce this
bug.
As I was changing dwarf2_base_index_functions::map_symbol_filenames I
replaced the use of htab_up with std::unordered_set.
Tested using target_boards cc-with-debug-names and dwarf4-gdb-index.
gdb/ChangeLog:
* dwarf2/read.c: Add 'unordered_set' include.
(dwarf2_base_index_functions::map_symbol_filenames): Replace
'visited' hash table with 'qfn_cache' unordered_set. Remove use
of per_Bfd->filenames_cache cache, and use function local
filenames_cache instead. Reindent.
* dwarf2/read.h (struct dwarf2_per_bfd) <filenames_cache>: Delete.
gdb/testsuite/ChangeLog:
* gdb.base/info_sources.exp: Add new tests.
|
|
I noticed some holes in struct dwarf2_per_cu_data. This patch
rearranges the type slightly, and shrinks the size of some fields.
This reduces it from 136 bytes to 112 bytes (on x86-64).
I also reduced the size of the DWARF "version" fields in a couple of
spots. It seemed needless to use a short to hold a value that ranges
from 2 to 5, and this also helped the goal of shrinking
dwarf2_per_cu_data.
2021-04-21 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (struct dwarf2_per_cu_data) <dwarf_version>: Now
unsigned char.
(struct dwarf2_per_cu_data): Rearrange.
* dwarf2/comp-unit.h (struct comp_unit_head) <version>: Now
unsigned char.
(struct comp_unit_head): Rearrange.
* dwarf2/comp-unit.c (read_comp_unit_head): Update.
|
|
The .gdb_index was designed such that all data would be aligned.
Unfortunately, we neglected to require this alignment in the objcopy
instructions in the manual. As a result, in many cases, a .gdb_index
in the wild will not be properly aligned by mmap. This yields
undefined behavior, which is PR gdb/23743.
This patch fixes the bug by always assuming that the mapping is
unaligned, and using extract_unsigned_integer when needed. A new
helper class is introduced to make this less painful.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
PR gdb/23743:
* dwarf2/read.c (class offset_view): New.
(struct symbol_table_slot): Remove.
(struct mapped_index) <symbol_table, constant_pool>: Change type.
<symbol_name_index, symbol_vec_index>: New methods.
<symbol_name_slot_invalid, symbol_name_at, symbol_name_count>:
Rewrite.
(read_gdb_index_from_buffer): Update.
(struct dw2_symtab_iterator) <vec>: Change type.
(dw2_symtab_iter_init_common, dw2_symtab_iter_init)
(dw2_symtab_iter_next, dw2_expand_marked_cus): Update.
* dwarf2/index-write.c (class data_buf) <append_data>: Remove.
<append_array, append_offset>: New methods.
(write_hash_table, add_address_entry, write_gdbindex_1)
(write_debug_names): Update.
* dwarf2/index-common.h (byte_swap, MAYBE_SWAP): Remove.
|
|
If I try "save gdb-index" using the executable from
gdb.cp/cmpd-minsyms.exp, gdb will crash. This happens due to a
missing NULL check.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (write_psymtabs_to_index): Check
partial_symtabs.
gdb/testsuite/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/gdb-index-nodebug.exp: New file.
|
|
quick_symbol_functions::map_matching_symbols is only used by the Ada
code. Currently, it both expands certain psymtabs and then walks over
the full symtabs -- including any already-expanded ones -- calling a
callback.
It appears to work lazily as well, in that if the callback returns
false, iteration stops. However, only the psymtab implementation does
this; the DWARF index implementations are not lazy. It turns out,
though, that the only callback that is ever passed here never returns
false.
This patch simplifies this method by removing the callback. The
method is also renamed. In the new scheme, the caller is responsible
for walking the full symtabs, which removes some redundancy as well.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* psymtab.c (psymbol_functions::expand_matching_symbols): Rename
from map_matching_symbols. Change parameters.
* psympriv.h (struct psymbol_functions) <expand_matching_symbols>:
Rename from map_matching_symbols. Change parameters.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_matching_symbols>: Rename from map_matching_symbols.
Change parameters.
(struct dwarf2_debug_names_index) <expand_matching_symbols>:
Rename from map_matching_symbols. Change parameters.
(dwarf2_gdb_index::expand_matching_symbols): Rename from
dw2_map_matching_symbols. Change parameters.
(dwarf2_gdb_index::expand_matching_symbols): Remove old
implementation.
(dwarf2_debug_names_index::expand_matching_symbols): Rename from
map_matching_symbols. Change parameters.
* objfiles.h (struct objfile) <expand_matching_symbols>: Rename
from map_matching_symbols. Change parameters.
* symfile-debug.c (objfile::expand_matching_symbols): Rename from
map_matching_symbols. Change parameters.
* ada-lang.c (map_matching_symbols): New function.
(add_nonlocal_symbols): Update.
|
|
This removes quick_symbol_functions::expand_symtabs_with_fullname,
replacing it with a call to expand_symtabs_matching. As with the
previous patches, the implementation is consolidated in the objfile
method.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_with_fullname>: Remove.
* psymtab.c (psymbol_functions::expand_symtabs_with_fullname):
Remove.
* psympriv.h (struct psymbol_functions)
<expand_symtabs_with_fullname>: Remove.
* dwarf2/read.c (struct dwarf2_base_index_functions)
<expand_symtabs_with_fullname>: Remove.
(dwarf2_base_index_functions::expand_symtabs_with_fullname):
Remove.
* objfiles.h (struct objfile) <expand_symtabs_with_fullname>:
Update comment.
* symfile-debug.c (objfile::expand_symtabs_with_fullname):
Rewrite.
|
|
This removes quick_symbol_functions::expand_symtabs_for_function,
replacing it with a call to expand_symtabs_matching. As with the
previous patches, the implementation is consolidated in the objfile
method.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::expand_symtabs_for_function):
Rewrite.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_for_function>: Remove.
* psymtab.c (psymbol_functions::expand_symtabs_for_function):
Remove.
* psympriv.h (struct psymbol_functions)
<expand_symtabs_for_function>: Remove.
* objfiles.h (struct objfile) <expand_symtabs_for_function>:
Update comment.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_for_function>: Remove.
(struct dwarf2_debug_names_index) <expand_symtabs_for_function>:
Remove.
(find_slot_in_mapped_hash): Remove.
(dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init.
(dw2_symtab_iter_init): Remove one overload.
(dwarf2_gdb_index::expand_symtabs_for_function)
(dwarf2_debug_names_index::expand_symtabs_for_function): Remove.
|
|
This replaces quick_symbol_functions::map_symtabs_matching_filename
with a call to expand_symtabs_matching. As with the previous patch,
rather than update all callers, the implementation is consolidated in
objfile::map_symtabs_matching_filename.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::map_symtabs_matching_filename):
Rewrite.
* quick-symbol.h (struct quick_symbol_functions)
<map_symtabs_matching_filename>: Remove.
* psymtab.c (partial_map_expand_apply)
(psymbol_functions::map_symtabs_matching_filename): Remove.
* psympriv.h (struct psymbol_functions)
<map_symtabs_matching_filename>: Remove.
* objfiles.h (struct objfile) <map_symtabs_matching_filename>:
Update comment.
* dwarf2/read.c (struct dwarf2_base_index_functions)
<map_symtabs_matching_filename>: Remove.
(dw2_map_expand_apply)
(dwarf2_base_index_functions::map_symtabs_matching_filename):
Remove.
|
|
This removes quick_symbol_functions, replacing it with calls to
expand_symtabs_matching. Because the replacement is somewhat verbose,
objfile::lookup_symbol is not removed. This consolidates some
duplicated code into this one spot.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::lookup_symbol): Rewrite.
* quick-symbol.h (struct quick_symbol_functions) <lookup_symbol>:
Remove.
* psymtab.c (psymbol_functions::lookup_symbol): Remove.
* psympriv.h (struct psymbol_functions) <lookup_symbol>: Remove.
* objfiles.h (struct objfile) <lookup_symbol>: Add comment.
* dwarf2/read.c (struct dwarf2_gdb_index) <lookup_symbol>:
Remove.
(struct dwarf2_debug_names_index) <lookup_symbol>: Remove.
(dwarf2_gdb_index::lookup_symbol)
(dwarf2_debug_names_index::lookup_symbol): Remove.
|
|
Currently, expand_symtabs_matching only accepts a search_domain
parameter. However, lookup_symbol uses a domain_enum instead, and the
two, confusingly, do quite different things -- one cannot emulate the
other. So, this patch adds a domain_enum parameter to
expand_symtabs_matching, with UNDEF_DOMAIN used as a wildcard.
This is another step toward replacing lookup_symbol with
expand_symtabs_matching.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symtab.c (global_symbol_searcher::expand_symtabs): Update.
* symmisc.c (maintenance_expand_symtabs): Update.
* symfile.c (expand_symtabs_matching): Update.
* symfile-debug.c (objfile::expand_symtabs_matching): Add 'domain'
parameter.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_matching>: Add 'domain' parameter.
* psymtab.c (recursively_search_psymtabs)
(psymbol_functions::expand_symtabs_matching): Add 'domain'
parameter.
* psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
Add 'domain' parameter.
* objfiles.h (struct objfile) <expand_symtabs_matching>: Add
'domain' parameter.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_matching>: Add 'domain' parameter.
(struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
'domain' parameter.
(dw2_expand_symtabs_matching)
(dwarf2_gdb_index::expand_symtabs_matching)
(dw2_debug_names_iterator)
(dwarf2_debug_names_index::expand_symtabs_matching): Add 'domain'
parameter.
|
|
This adds a block search flags parameter to expand_symtabs_matching.
All callers are updated to search both the static and global blocks,
as that was the implied behavior before this patch.
This is a step toward replacing lookup_symbol with
expand_symtabs_matching.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symtab.c (global_symbol_searcher::expand_symtabs)
(default_collect_symbol_completion_matches_break_on): Update.
* symmisc.c (maintenance_expand_symtabs): Update.
* symfile.h (expand_symtabs_matching): Add search_flags
parameter.
* symfile.c (expand_symtabs_matching): Add search_flags
parameter.
* symfile-debug.c (objfile::expand_symtabs_matching): Add
search_flags parameter.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_matching>: Add search_flags parameter.
* python/py-symbol.c (gdbpy_lookup_static_symbols): Update.
* psymtab.c (recursively_search_psymtabs)
(psymbol_functions::expand_symtabs_matching): Add search_flags
parameter.
* psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
Add search_flags parameter.
* objfiles.h (struct objfile) <expand_symtabs_matching>: Add
search_flags parameter.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_matching>: Add search_flags parameter.
(struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
search_flags parameter.
(dw2_map_matching_symbols): Update.
(dw2_expand_marked_cus, dw2_expand_symtabs_matching)
(dwarf2_gdb_index::expand_symtabs_matching): Add search_flags
parameter.
(dw2_debug_names_iterator): Change block_index to search flags.
<m_block_index>: Likewise.
(dw2_debug_names_iterator::next)
(dwarf2_debug_names_index::lookup_symbol)
(dwarf2_debug_names_index::expand_symtabs_for_function)
(dwarf2_debug_names_index::map_matching_symbols)
(dwarf2_debug_names_index::map_matching_symbols): Update.
(dwarf2_debug_names_index::expand_symtabs_matching): Add
search_flags parameter.
* ada-lang.c (ada_add_global_exceptions)
(collect_symbol_completion_matches): Update.
|
|
This changes expand_symtabs_exp_notify_ftype to return bool, and
updates all the uses. Now, if the notification function returns
false, the call is short-circuited and stops examining symtabs. This
is a step toward replacing map_symtabs_matching_filename with
expand_symtabs_matching.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symtab.c (default_collect_symbol_completion_matches_break_on):
Update.
* symfile.h (expand_symtabs_matching): Return bool.
* symfile.c (expand_symtabs_matching): Return bool.
* symfile-debug.c (objfile::expand_symtabs_matching): Return
bool.
* quick-symbol.h (expand_symtabs_exp_notify_ftype): Return bool.
(struct quick_symbol_functions) <expand_symtabs_matching>: Return
bool.
* psymtab.c (psymbol_functions::expand_symtabs_matching): Return
bool.
* psympriv.h (struct psymbol_functions)
<expand_symtabs_matching>: Return bool.
* objfiles.h (struct objfile) <expand_symtabs_matching>: Return
bool.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_matching>: Return bool.
(struct dwarf2_debug_names_index) <expand_symtabs_matching>:
Return bool.
(dw2_expand_symtabs_matching_symbol): Return bool.
(dw2_expand_symtabs_matching_one, dw2_expand_marked_cus)
(dw2_expand_symtabs_matching)
(dwarf2_gdb_index::expand_symtabs_matching)
(dwarf2_debug_names_index::expand_symtabs_matching)
(dwarf2_debug_names_index::expand_symtabs_matching): Return bool.
|
|
GDB reports duplicate local vars with "<optimized out>" values for
inlined functions that are compiled with Clang.
Suppose we have
__attribute__((always_inline))
static void aFunction() {
int a = 42;
if(a > 2) {
int value = a;
value += 10; /* break here */
}
}
The "info locals" command at the "break here" line gives the following
output:
...
Breakpoint 1, aFunction () at test.c:6
6 value += 10; /* break here */
(gdb) info locals
value = 42
a = 42
value = <optimized out>
(gdb)
The reason is, inlined functions that are compiled by Clang do not
contain DW_AT_abstract_origin attributes in the DW_TAG_lexical_block
entries. See
https://bugs.llvm.org/show_bug.cgi?id=49953
E.g. the DIE of the inlined function above is
0x00000087: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x0000002a "aFunction")
DW_AT_low_pc (0x00000000004004b2)
DW_AT_high_pc (0x00000000004004d2)
DW_AT_call_file ("/tmp/test.c")
DW_AT_call_line (11)
DW_AT_call_column (0x03)
0x0000009b: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -4)
DW_AT_abstract_origin (0x00000032 "a")
0x000000a3: DW_TAG_lexical_block
DW_AT_low_pc (0x00000000004004c3)
DW_AT_high_pc (0x00000000004004d2)
0x000000b0: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -8)
DW_AT_abstract_origin (0x0000003e "value")
This causes GDB to fail matching the concrete lexical scope with the
corresponding abstract entry. Hence, the local vars of the abstract
function that are contained in the lexical scope are read separately
(and thus, in addition to) the local vars of the concrete scope.
Because the abstract definitions of the vars do not contain location
information, we see the extra 'value = <optimized out>' above.
This bug is highly related to PR gdb/25695, but the root cause is not
exactly the same. In PR gdb/25695, GCC emits an extra
DW_TAG_lexical_block without an DW_AT_abstract_origin that wraps the
body of the inlined function. That is, the trees of the abstract DIE
for the function and its concrete instance are structurally not the
same. In the case of using Clang, the trees have the same structure.
To tackle the Clang case, when traversing the children of the concrete
instance root, keep a reference to the child of the abstract DIE that
corresponds to the concrete child, so that we can match the two DIEs
heuristically in case of missing DW_AT_abstract_origin attributes.
The updated gdb.opt/inline-locals.exp test has been checked with GCC
5-10 and Clang 5-11.
gdb/ChangeLog:
2021-04-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* dwarf2/read.c (inherit_abstract_dies): Keep a reference to the
corresponding child of the abstract DIE when iterating the
children of the concrete DIE.
gdb/testsuite/ChangeLog:
2021-04-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.opt/inline-locals.c (scoped): New function.
(main): Call 'scoped'.
* gdb.opt/inline-locals.exp: Update with "info locals" tests
for scoped variables.
* gdb.dwarf2/dw2-inline-with-lexical-scope.c: New file.
* gdb.dwarf2/dw2-inline-with-lexical-scope.exp: New file.
|
|
DWARF allows .dwo file paths to be relative rather than absolute.
When they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative.
In this case, GDB currently searches relative to its current working
directory, i.e. the directory from which the debugger was launched,
but not relative to the directory containing the built binary. This
cannot be right, as the compiler, when generating the relative paths,
knows where it's building the binary but can have no idea where the
debugger will be launched.
The correct thing is to add the directory containing the binary to the
search paths used for resolving relative locations of dwo files. That
is what this patch does.
gdb/ChangeLog:
* dwarf2/read.c (try_open_dwop_file): Add path for the binary to
the search paths used resolve relative location of .dwo file.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/fission-relative-dwo.c: New file.
* gdb.dwarf2/fission-relative-dwo.exp: New file.
|
|
While messing with the Dwarf assembler (gdb/testsuite/lib/dwarf.exp) I
managed to create an ELF which made use of DW_FORM_strp, but didn't
include a .debug_str section.
When I started GDB on this ELF, GDB crashed. I would have expected to
get an error instead.
I tracked this down to an unfortunate design choice in
dwarf2_section_info, a class which wraps around a bfd section, and is
used for reading in debug information. GBB creates many
dwarf2_section_info objects, one for each debug section that might
need to be read, then as we find the input bfd sections we associate
them with the corresponding dwarf2_section_info.
If no matching input bfd section is found then the dwarf2_section_info
is left in an unassociated state, its internal bfd section pointer is
null.
If later GDB tries to read content from the dwarf2_section_info, for
example, which trying to read the string associated with DW_FORM_strp,
we spot that there is no associated bfd section and issue an error
message.
To make the users life easier, the error message includes the section
name being looked for, and the bfd from which the section was
obtained.
However, we get the section name by calling bfd_section_name on the
associated section, and we get the bfd filename by calling
bfd_get_filename on the owner of the associated section.
Of course, if there is no associated section then both the calls
bfd_section_name and dwarf2_section_info::get_bfd_owner will result in
undefined behaviour (e.g. a crash).
The solution I propose in this patch is, I know, not ideal. I simply
spot the case where there is no associated section, and print a
simpler error message, leaving out the section name and filename.
A better solution would involve redesigning dwarf2_section_info, we
could associate each dwarf2_section_info with the initial bfd being
parsed. We would then display this filename if there's nothing better
to display (e.g. if we find a section in a dwo/dwp split dwarf file
then we would probably use that filename in preference).
Each dwarf2_section_info could also have the concept of the default
section name that would be read for that section, for example, string
data might appear in ".debug_str" or ".zdebug_str", but if neither is
found, then it would probably be OK to just say ".debug_str" is
missing.
Anyway, I didn't do any of that redesign, I just wanted to stop GDB
crashing for now, so instead we get this:
Dwarf Error: DW_FORM_strp used without required section
Which isn't the best, but in context, isn't too bad:
Reading symbols from /path/to/executable...
Dwarf Error: DW_FORM_strp used without required section
(No debugging symbols found in /path/to/executable)
I also added some asserts into dwarf2_section_info which should
trigger before GDB crashes in future, if we trigger any other bad
paths through this code.
And there's a test for the specific issue I hit.
gdb/ChangeLog:
* dwarf2/section.c (dwarf2_section_info::get_bfd_owner): Add an
assert.
(dwarf2_section_info::get_file_name): Add an assert.
(dwarf2_section_info::read_string): Display a minimal, sane error
when the dwarf2_section_info is not associated with a bfd section.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-using-debug-str.exp: Add an additional test.
|
|
Since partial_symtab is supposed to be objfile-independent (since series
[1]), I think it would make sense for partial_symtab to not take an
objfile as a parameter in its constructor.
This patch replaces that parameter with an objfile_per_bfd_storage
parameter.
The objfile is used for two things:
- to get the objfile_name, for debug messages. We can get that name
from the bfd instead.
- to intern the partial symtab filename. Even though it goes through
an objfile method, the request is actually forwarded to the
underlying objfile_per_bfd_storage. So we can ask the new
objfile_per_bfd_storage instead.
In order to get a reference to the BFD from the objfile_per_bfd_storage,
the BFD is saved in the objfile_per_bfd_storage object.
[1] https://sourceware.org/pipermail/gdb-patches/2021-February/176625.html
gdb/ChangeLog:
* psympriv.h (struct partial_symtab) <partial_symtab>: Change
objfile parameter for objfile_per_bfd_storage, adjust callers.
(struct standard_psymtab) <standard_psymtab>: Likewise.
(struct legacy_psymtab) <legacy_psymtab>: Likewise.
* psymtab.c (partial_symtab::partial_symtab): Likewise.
* ctfread.c (struct ctf_psymtab): Likewise.
* dwarf2/read.h (struct dwarf2_psymtab): Likewise.
* dwarf2/read.c (struct dwarf2_include_psymtab): Likewise.
(dwarf2_create_include_psymtab): Likewise.
* objfiles.h (struct objfile_per_bfd_storage)
<objfile_per_bfd_storage>: Add bfd parameter, adjust callers.
<get_bfd>: New method.
<m_bfd>: New field.
* objfiles.c (get_objfile_bfd_data): Adjust.
Change-Id: I2ed3ab5d2e6f27d034bd4dc26ae2fae7b0b8a2b9
|
|
Add the `is_flag_enum` and `set_is_flag_enum` methods on `struct type`,
in order to remove the `TYPE_FLAG_ENUM` macro. In this patch, the macro
is changed to use the getter, so all the call sites of the macro that
are used as a setter are changed to use the setter method directly. The
next patch will remove the macro completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <is_flag_enum,
set_is_flag_enum>: New methods.
(TYPE_FLAG_ENUM): Use type::is_flag_enum, change all
write call sites to use type::set_is_flag_enum.
Change-Id: I9c56c91626c8d784947ba94fcb97818526b81d1c
|
|
gdb/ChangeLog:
* gdbtypes.h (TYPE_DECLARED_CLASS): Remove, replace all uses
with type::is_declared_class.
Change-Id: Ifecb2342417ecd7bf570c3205344b09d706daab2
|
|
Add the `is_declared_class` and `set_is_declared_class` methods on
`struct type`, in order to remove the `TYPE_DECLARED_CLASS` macro. In
this patch, the macro is changed to use the getter, so all the call
sites of the macro that are used as a setter are changed to use the
setter method directly. The next patch will remove the macro
completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <is_declared_class,
set_is_declared_class>: New methods.
(TYPE_DECLARED_CLASS): Use type::is_declared_class, change all
write call sites to use type::set_is_declared_class.
Change-Id: Idf08d32e137c885a0aba0a18f556a899c1cbfd68
|
|
This removes dw2_map_matching_symbols and dw2_expand_symtabs_matching,
merging them with their sole trivial callers.
gdb/ChangeLog
2021-03-31 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_gdb_index::map_matching_symbols): Merge
with dw2_map_matching_symbols.
(dwarf2_gdb_index::expand_symtabs_matching): Merge with
dw2_expand_symtabs_matching.
|
|
Pedro pointed out a typo in a comment in dwarf2/stringify.h. This
fixes it.
gdb/ChangeLog
2021-03-31 Tom Tromey <tromey@adacore.com>
* dwarf2/stringify.h: Fix typo.
|
|
New in v2:
- Disable sharing only for -readnow objfiles, not all objfiles.
As described in PR 27541, we hit an internal error when loading a binary
the standard way and then loading it with the -readnow option:
$ ./gdb -nx -q --data-directory=data-directory ~/a.out -ex "set confirm off" -ex "file -readnow ~/a.out"
Reading symbols from /home/simark/a.out...
Reading symbols from ~/a.out...
/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8098: internal-error: void create_all_comp_units(dwarf2_per_objfile*): Assertion `per_objfile->per_bfd->all_comp_units.empty ()' failed.
This is a recurring problem that exposes a design issue in the DWARF
per-BFD sharing feature. Things work well when loading a binary with
the same method (with/without index, with/without readnow) twice in a
row. But they don't work so well when loading a binary with different
methods. See this previous fix, for example:
efb763a5ea35 ("gdb: check for partial symtab presence in dwarf2_initialize_objfile")
That one handled the case where the first load is normal (uses partial
symbols) and the second load uses an index.
The problem is that when loading an objfile with a method A, we create a
dwarf2_per_bfd and some dwarf2_per_cu_data and initialize them with the
data belonging to that method. When loading another obfile sharing the
same BFD but with a different method B, it's not clear how to re-use the
dwarf2_per_bfd/dwarf2_per_cu_data previously created, because they
contain the data specific to method A.
I think the most sensible fix would be to not share a dwarf2_per_bfd
between two objfiles loaded with different methods. That means that two
objfiles sharing the same BFD and loaded the same way would share a
dwarf2_per_bfd. Two objfiles sharing the same BFD but loaded with
different methods would use two different dwarf2_per_bfd structures.
However, this isn't a trivial change. So to fix the known issue quickly
(including in the gdb 10 branch), this patch just disables all
dwarf2_per_bfd sharing for objfiles using READNOW.
Generalize the gdb.base/index-cache-load-twice.exp test to test all
the possible combinations of loading a file with partial symtabs, index
and readnow. Move it to gdb.dwarf2, since it really exercises features
of the DWARF reader.
gdb/ChangeLog:
PR gdb/27541
* dwarf2/read.c (dwarf2_has_info): Don't share dwarf2_per_bfd
with objfiles using READNOW.
gdb/testsuite/ChangeLog:
PR gdb/27541
* gdb.base/index-cache-load-twice.exp: Remove.
* gdb.base/index-cache-load-twice.c: Remove.
* gdb.dwarf2/per-bfd-sharing.exp: New.
* gdb.dwarf2/per-bfd-sharing.c: New.
Change-Id: I9ffcf1e136f3e75242f70e4e58e4ba1fd3083389
|
|
Now that the quick functions are separate from the object file format,
there's no need to have elfread.c push a new entry on the objfile 'qf'
list. Instead, this detail can be pushed into the DWARF reader. That
is what this patch implements.
I wasn't sure whether lazy reading still makes sense or not. It's
still only used by ELF, and only in certain situations (like vfork, I
think). It may not be carrying its weight, so we may want to consider
removing this in the future.
Also, I'm unclear on why the various indices are only used for ELF.
This seems sub-optimal. However, I haven't tried to address that
here.
gdb/ChangeLog
2021-03-28 Tom Tromey <tom@tromey.com>
* elfread.c (can_lazily_read_symbols): Move to dwarf2/read.c.
(elf_symfile_read): Simplify.
* dwarf2/read.c (struct lazy_dwarf_reader): Move from elfread.c.
(make_lazy_dwarf_reader): New function.
(make_dwarf_gdb_index, make_dwarf_debug_names): Now static.
(dwarf2_initialize_objfile): Return void. Remove index_kind
parameter. Push on 'qf' list.
* dwarf2/public.h (dwarf2_initialize_objfile): Change return
type. Remove 'index_kind' parameter.
(make_dwarf_gdb_index, make_dwarf_debug_names): Don't declare.
|
|
This changes quick_symbol_functions::map_symbol_filenames to use a
function_view, and updates all the uses. It also changes the final
parameter to 'bool'. A couple of spots are further updated to use
operator() rather than a lambda.
gdb/ChangeLog
2021-03-26 Tom Tromey <tom@tromey.com>
* symtab.c (struct output_source_filename_data): Add 'output'
method and operator().
(output_source_filename_data::output): Rename from
output_source_filename.
(output_partial_symbol_filename): Remove.
(info_sources_command): Update.
(struct add_partial_filename_data): Add operator().
(add_partial_filename_data::operator()): Rename from
maybe_add_partial_symtab_filename.
(make_source_files_completion_list): Update.
* symfile.c (quick_symbol_functions): Update.
* symfile-debug.c (objfile::map_symbol_filenames): Update.
* quick-symbol.h (symbol_filename_ftype): Change type of 'fun' and
'need_fullname'. Remove 'data' parameter.
(struct quick_symbol_functions) <map_symbol_filenames>: Likewise.
* psymtab.c (psymbol_functions::map_symbol_filenames): Update.
* psympriv.h (struct psymbol_functions) <map_symbol_filenames>:
Change type of 'fun' and 'need_fullname'. Remove 'data'
parameter.
* objfiles.h (struct objfile) <map_symbol_filenames>: Change type
of 'fun' and 'need_fullname'. Remove 'data' parameter.
* mi/mi-cmd-file.c (print_partial_file_name): Remove 'ignore'
parameter.
(mi_cmd_file_list_exec_source_files): Update.
* dwarf2/read.c
(dwarf2_base_index_functions::map_symbol_filenames): Update.
|
|
I noticed a spot in the DWARF reader using "per_objfile->per_bfd",
where a local per_bfd variable had already been created. Looking
through the file, I found a number of such spots. This patch changes
them to use the already-existing local, avoiding a bit of excess
pointer chasing.
gdb/ChangeLog
2021-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_read_debug_names)
(dwarf2_build_psymtabs_hard, create_addrmap_from_aranges)
(dw2_debug_names_iterator::next, create_type_unit_group):
Simplify.
|
|
I noticed that dw2_map_matching_symbols does not use its 'kind'
parameter. This patch removes it. Tested by rebuilding.
2021-03-24 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dw2_map_matching_symbols): Update.
(dw2_expand_symtabs_matching_symbol): Remove 'kind' parameter.
(check_match, dw2_expand_symtabs_matching)
(dwarf2_debug_names_index::map_matching_symbols)
(dwarf2_debug_names_index::expand_symtabs_matching): Update.
|
|
Replace an abort call in process_psymtab_comp_unit with a real error,
and add a test to cover this case. The case is question is when badly
formed DWARF is missing a DW_TAG_compile_unit, DW_TAG_partial_unit, or
DW_TAG_type_unit as its top level tag.
I then tested with --target_board=readnow and added additional code to
also validate the top-level tag in this case.
I added an assert that would trigger for the readnow case before I
added the fix. I suspect there's lots of places where badly formed
DWARF could result in the builder being nullptr when it shouldn't be,
but I only added this one assert, as this is the one that would have
helped me in this case.
gdb/ChangeLog:
* dwarf2/read.c (process_psymtab_comp_unit): Replace abort with an
error.
(process_full_comp_unit): Validate the top-level tag before
processing the first DIE.
(read_func_scope): Ensure we have a valid builder.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-missing-cu-tag.c: New file.
* gdb.dwarf2/dw2-missing-cu-tag.exp: New file.
|
|
This patch finally changes gdb so that an objfile can have multiple
sources of partial symbols (or mixed partial symbols and other kinds
of indices).
This is done by having each symbol reader create its own
psymbol_functions object and add it to the 'qf' list in the objfile.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_initial_scan): Create partial symtabs.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* psymtab.h (make_psymbol_functions): Don't declare.
* psymtab.c (make_psymbol_functions): Remove.
(maintenance_print_psymbols): Update.
* psympriv.h (struct psymbol_functions): Add no-argument
constructor.
* objfiles.h (struct objfile) <reset_psymtabs>: Remove.
<partial_symtabs>: Remove.
* mdebugread.c (mdebug_build_psymtabs): Create partial symtabs.
* elfread.c (read_partial_symbols): Update.
(elf_symfile_read): Remove check for existing partial symbols.
Don't clear "qf".
* dwarf2/read.c (dwarf2_has_info): Remove check for existing
partial symbols.
(dwarf2_build_psymtabs): Add psymbol_functions parameter. Create
partial symtabs.
* dwarf2/public.h (dwarf2_build_psymtabs): Add psymbol_functions
parameter.
* dbxread.c (dbx_symfile_read): Create partial symtabs.
* ctfread.c (elfctf_build_psymtabs): Create partial symtabs.
|
|
This changes objfile::qf to be a forward_list, and then updates all
the uses to iterate over the list. Note that there is still only ever
a single element in the list; this is handled by clearing the list
whenever an object is added.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language)
(objfile::require_partial_symbols): Update.
* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
* objfiles.h (struct objfile) <qf>: Now a forward_list.
* objfiles.c (objfile_relocate1): Update.
* elfread.c (elf_symfile_read): Update.
|
|
This adds a partial_symtabs parameter to the psymtab constructors and
to add_psymbol. This helps with the overall project of removing the
partial symtabs from the objfile.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter.
(xcoff_end_psymtab, scan_xcoff_symtab): Update.
* psymtab.c (partial_symtab::partial_symtab): Add partial_symtabs
parameter.
(add_psymbol_to_bcache): Remove.
(partial_symtab::add_psymbol): Add partial_symtabs parameter.
(partial_symtab::add_psymbol, partial_symtab::partial_symtab):
Likewise.
* psympriv.h (partial_symtab): Add partial_symtabs parameter.
<add_psymbol>: Likewise.
(standard_psymtab, legacy_psymtab): Likewise.
* mdebugread.c (parse_partial_symbols): Update.
(handle_psymbol_enumerators): Add partial_symtabs parameter.
(handle_psymbol_enumerators): Update.
(new_psymtab): Add partial_symtabs parameter.
* dwarf2/read.h (dwarf2_psymtab): Add partial_symtabs parameter.
* dwarf2/read.c (dwarf2_include_psymtab): Add partial_symtabs
parameter.
(dwarf2_create_include_psymtab): Add partial_symtabs parameter.
(create_partial_symtab, add_partial_symbol, dwarf_decode_lines):
Update.
* dbxread.c (read_dbx_symtab): Update.
(start_psymtab): Add partial_symtabs parameter.
(dbx_end_psymtab): Update.
* ctfread.c (struct ctf_context) <partial_symtabs>: New member.
(ctf_psymtab): Add partial_symtabs parameter.
(create_partial_symtab, ctf_psymtab_type_cb, ctf_psymtab_var_cb):
Update.
(scan_partial_symbols): Add partial_symtabs parameter.
(scan_partial_symbols, elfctf_build_psymtabs)
(ctf_psymtab_add_enums): Update.
|
|
Currently, the storage for partial symtabs is attached to the objfile.
Ultimately, though, this direct assocation will be removed, and the
storage will be owned by the psymbol_functions object.
This patch is a step toward this goal. The storage is already managed
as a shared_ptr, to enable cross-objfile sharing, so this adds a
reference from the psymbol_functions, and changes some code in
psymtab.c to use this reference instead.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Call
set_partial_symtabs.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* psymtab.h (make_psymbol_functions): Add partial_symtabs
parameter.
* psymtab.c (find_pc_sect_psymtab): Add partial_symtabs
parameter.
(psymbol_functions::find_pc_sect_compunit_symtab)
(psymbol_functions::print_stats, psymbol_functions::dump)
(psymbol_functions::has_symbols): Update.
(make_psymbol_functions, dump_psymtab_addrmap): Add
partial_symtabs parameter.
(maintenance_print_psymbols): Update.
(psymbol_functions::expand_symtabs_matching): Update.
* psympriv.h (struct psymbol_functions): Add constructor.
<m_partial_symtabs>: New member.
<set_partial_symtabs>: New method.
|
|
This changes the DWARF reader to reference the psymtabs via the
per_bfd object, rather than via the objfile. This helps isolate the
partial symtabs from the objfile.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_create_include_psymtab): Add per_bfd
parameter.
(process_psymtab_comp_unit_reader)
(build_type_psymtab_dependencies, dwarf2_build_psymtabs_hard)
(add_partial_subprogram, dwarf2_ranges_read, dwarf_decode_lines):
Reference psymtabs via per_bfd.
|
|
This changes the DWARF index writer to find the psymtab address map in
the per_bfd object, rather than go via the objfile.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (struct addrmap_index_data) <objfile>:
Remove.
(add_address_entry): Remove objfile parameter.
(add_address_entry_worker): Update.
(write_address_map): Replace objfile parameter with per_bfd.
(write_gdbindex, write_psymtabs_to_index): Update.
|
|
This moves all the psymtab statistics printing code form symmisc.c to
psymtab.c. This changes the formatting of the output a little, but
considering that it is a maint command (and, I assume, a rarely used
one), this seems fine to me.
This change helps further dissociate the psymtab from the objfile. In
the end there will be no direct connect -- only via the
quick_symbol_functions interface.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_base_index_functions::print_stats): Add
print_bcache parameter.
* symfile-debug.c (objfile::print_stats): Add print_bcache
parameter.
* quick-symbol.h (struct quick_symbol_functions)
<print_stats>: Add print_bcache parameter.
* symmisc.c (print_symbol_bcache_statistics, count_psyms): Move
code to psymtab.c.
(print_objfile_statistics): Move psymtab code to psymtab.c.
* psymtab.c (count_psyms): Move from symmisc.c.
(psymbol_functions::print_stats): Print partial symbol and bcache
statistics. Add print_bcache parameter.
* objfiles.h (print_symbol_bcache_statistics): Don't declare.
(struct objfile) <print_stats>: Add print_bcache parameter.
* maint.c (maintenance_print_statistics): Update.
gdb/testsuite/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* gdb.base/maint.exp: Update "maint print statistics" output.
|
|
Currently the DWARF index readers reuse the objfile's partial symbol
table in order to store an addrmap. We're going to be remove the
partial symbol object, so this patch changes the DWARF reader to store
this addrmap in the per_bfd object. This object is chosen, rather
than the quick_symbol_functions subclass, because the addrmap can be
shared across objfiles.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (struct dwarf2_per_bfd) <psymtabs_addrmap>: New
member.
* dwarf2/read.c (create_addrmap_from_index)
(create_addrmap_from_aranges): Set per_bfd addrmap.
(dwarf2_read_gdb_index): Don't set partial_symtabs.
(dwarf2_base_index_functions::find_pc_sect_compunit_symtab): Use
per_bfd addrmap.
(dwarf2_read_debug_names): Don't set partial_symtabs.
(dwarf2_initialize_objfile): Likewise.
|
|
dwarf2_build_psymtabs sets per_bfd->partial_symtabs at its end, in
order to facilitate sharing.
However, in order to diassociate partial symtabs from the objfile, we
want to change the DWARF reader to reference partial symtabs via the
per_bfd. So, we want to set this reference before reading psymtabs.
This is safe to do because the assignment is done unconditionally.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Set partial_symtabs
earlier.
|
|
This changes the psymtab_discarder to not assume that partial symtabs
are attached to the objfile. Instead, a psymtab_storage object is
passed directly to it.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* psympriv.h (psymtab_discarder): Take psymtab_storage parameter.
(~psymtab_discarder, keep): Update.
<m_objfile>: Remove.
<m_partial_symtabs>: New member.
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
|
|
This changes quick_symbol_functions to be a base class with pure
virtual methods, rather than a struct holding function pointers.
Then, objfile is changed to hold a unique_ptr to an instance of this
class.
struct psymbol_functions is put into psympriv.h, and not psymtab.c,
because that is convenient later in the series.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* psympriv.h (struct psymbol_functions): New.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* symfile-debug.c (objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): Update.
* quick-symbol.h (struct quick_symbol_functions): Convert function
pointers to methods. Add virtual destructor.
(quick_symbol_functions_up): New typedef.
* psymtab.h (psym_functions, dwarf2_gdb_index_functions)
(dwarf2_debug_names_functions): Don't declare.
(make_psymbol_functions): Declare.
* psymtab.c (psymbol_functions::map_symtabs_matching_filename)
(psymbol_functions::find_pc_sect_compunit_symtab)
(psymbol_functions::lookup_symbol)
(psymbol_functions::lookup_global_symbol_language)
(psymbol_functions::find_last_source_symtab)
(psymbol_functions::forget_cached_source_info)
(psymbol_functions::print_stats, psymbol_functions::dump)
(psymbol_functions::expand_symtabs_for_function)
(psymbol_functions::expand_all_symtabs)
(psymbol_functions::expand_symtabs_with_fullname)
(psymbol_functions::map_symbol_filenames)
(psymbol_functions::map_matching_symbols)
(psymbol_functions::expand_symtabs_matching)
(psymbol_functions::has_symbols)
(psymbol_functions::find_compunit_symtab_by_address): Rename.
(psym_functions): Remove.
(make_psymbol_functions): New function.
* objfiles.h (struct objfile) <qf>: Change type.
* elfread.c (elf_symfile_read): Update.
* dwarf2/read.c (struct dwarf2_base_index_functions)
(struct dwarf2_gdb_index, struct dwarf2_debug_names_index): New.
(make_dwarf_gdb_index, make_dwarf_debug_names): New functions.
(dwarf2_base_index_functions::find_last_source_symtab)
(dwarf2_base_index_functions::forget_cached_source_info)
(dwarf2_base_index_functions::map_symtabs_matching_filename)
(dwarf2_gdb_index::lookup_symbol)
(dwarf2_base_index_functions::print_stats)
(dwarf2_gdb_index::dump)
(dwarf2_gdb_index::expand_symtabs_for_function)
(dwarf2_base_index_functions::expand_all_symtabs)
(dwarf2_base_index_functions::expand_symtabs_with_fullname):
Rename.
(dwarf2_gdb_index::map_matching_symbols): New method.
(dwarf2_gdb_index::expand_symtabs_matching): New method.
(dwarf2_base_index_functions::find_pc_sect_compunit_symtab)
(dwarf2_base_index_functions::map_symbol_filenames)
(dwarf2_base_index_functions::has_symbols): Rename.
(dwarf2_gdb_index_functions): Remove.
(dwarf2_debug_names_index::lookup_symbol)
(dwarf2_debug_names_index::dump)
(dwarf2_debug_names_index::expand_symtabs_for_function)
(dwarf2_debug_names_index::map_matching_symbols)
(dwarf2_debug_names_index::expand_symtabs_matching): Rename.
(dwarf2_debug_names_functions): Remove.
* dwarf2/public.h (make_dwarf_gdb_index, make_dwarf_debug_names):
Declare.
|
|
This changes objfile::has_partial_symbols and
quick_symbol_functions::has_symbols to return bool.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* objfiles.h (struct objfile) <has_partial_symbols>: Return bool.
* symfile.h (struct quick_symbol_functions) <has_symbols>: Return
bool.
* symfile-debug.c (debug_qf_has_symbols): Return bool.
* psymtab.c (psym_has_symbols): Return bool.
* objfiles.c (objfile::has_partial_symbols): Return bool.
* dwarf2/read.c (dw2_has_symbols): Return bool.
|
|
This changes objfile_has_partial_symbols to be a method on objfile.
There are some other functions that could benefit from this sort of
change, but this was the only one that was relevant to this series.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symfile.c (read_symbols): Update.
* objfiles.h (struct objfile) <has_partial_symbols>: New method.
(objfile_has_partial_symbols): Don't declare.
* objfiles.c (objfile::has_partial_symbols): Rename from
objfile_has_partial_symbols.
(objfile_has_symbols, have_partial_symbols): Update.
* elfread.c (elf_symfile_read): Update.
* dwarf2/read.c (dwarf2_has_info): Update.
* coffread.c (coff_symfile_read): Update.
|
|
This moves some more DWARF code out of symfile.h and into a new
header, dwarf2/public.h. This header is intended to describe the
public API of the DWARF reader.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* coffread.c: Include dwarf2/public.h.
* dwarf2/frame.c: Include dwarf2/public.h.
* dwarf2/index-write.h: Include dwarf2/public.h, not symfile.h.
* dwarf2/public.h: New file.
* dwarf2/read.c: Include dwarf2/public.h.
* elfread.c: Include dwarf2/public.h.
* machoread.c: Include dwarf2/public.h.
* symfile.h (dwarf2_has_info, enum dw_index_kind)
(dwarf2_initialize_objfile, dwarf2_build_psymtabs)
(dwarf2_build_frame_info): Move to dwarf2/public.h.
* xcoffread.c: Include dwarf2/public.h.
|
|
This moves a bit of the DWARF-specific code out of symfile.h and into
dwarf2/read.h.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symfile.h (enum dwarf2_section_enum)
(dwarf2_get_section_info): Move to dwarf2/read.h.
* dwarf2/read.h (enum dwarf2_section_enum)
(dwarf2_get_section_info): Move from symfile.h.
|
|
I noticed that dwarf_unit_type_name is nearly identical to
get_DW_UT_name from libiberty; but rather than simply replacing it, it
seemed better to have it work like the other DWARF constant
stringification functions -- return a string showing unrecognized
numeric forms rather than nullptr. (The previous code did include
numeric values for the recognized constants, but this seems to be not
that useful to me.)
2021-03-18 Tom Tromey <tromey@adacore.com>
* dwarf2/stringify.c (dwarf_unit_type_name): New function. Use
get_DW_UT_name.
* dwarf2/stringify.h (dwarf_unit_type_name): Declare.
* dwarf2/comp-unit.c (dwarf_unit_type_name): Remove.
|
|
This printout in create_debug_type_hash_table has an unexpected colon at
the end, remove it:
[dwarf-read] create_debug_type_hash_table: Reading .debug_info for /home/simark/build/binutils-gdb/gdb/a.out:
gdb/ChangeLog:
* dwarf2/read.c (create_debug_type_hash_table): Remove colon at
end of debug print.
Change-Id: I2d707248249daf4d8b6fa8e7064acdc56c90f2dd
|
|
I added these printouts while working on 27541. I won't have a fix for
that right now, but I thought that it would be useful to merge them
upstream, as they help understand what happens in that function.
gdb/ChangeLog:
* dwarf2/read.c (dwarf2_initialize_objfile): Add debug prints.
Change-Id: I790c0d53383327038cb5dd705f74c8c978e0a7ec
|
|
I noticed that this parameter was unused, remove it.
gdb/ChangeLog:
* dwarf2/read.c (dw2_get_file_names_reader): Remove info_ptr
parameter, adjust caller.
Change-Id: I2a741766a0c658c22c512590aeffdd07391c869c
|
|
read_attribute_value has a local cu_header variable, but then some
spots in the function use cu->header instead. It seems better to me
to prefer the local everywhere, so this patch makes this change.
gdb/ChangeLog
2021-03-14 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_attribute_value): Use cu_header
consistently.
|
|
For an experiment I'm working on, it would be convenient if
die_reader_specs::cu could be NULL. This is fairly involved to
implement, but I did notice one spot that could conveniently be
updated. While making this trivial change, I also noticed a small,
related formatting error.
2021-03-14 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (struct die_reader_specs) <abfd>: Fix formatting.
(peek_die_abbrev): Use reader.abfd.
|
|
I noticed that nothing in dwarf2/read.c sets
dwarf2_per_cu_data::m_header_read_in. This patch adds the appropriate
assignment.
gdb/ChangeLog
2021-03-14 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_per_cu_data::get_header): Set
m_header_read_in.
|
|
This changes abbrev_table::lookup_abbrev to return a pointer to const,
then fixes up the affected code.
gdb/ChangeLog
2021-03-13 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (struct partial_die_info): Update.
(peek_die_abbrev, skip_children, skip_one_die, read_full_die_1)
(load_partial_dies, partial_die_info::partial_die_info): Update.
* dwarf2/abbrev.h (lookup_abbrev): Constify.
|