mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 01:33:06 +00:00
26291647eb
We currently handle DIEs with a DW_AT_specification attribute by parsing the corresponding declaration to get the name and inserting the DIE as usual. This has a couple of problems: 1. It only works if DW_AT_specification refers to the same compilation unit, which is true for DW_FORM_ref{1,2,4,8,_udata}, but not DW_FORM_ref_addr. As a result, drgn doesn't support the latter. 2. It assumes that the DIE with DW_AT_specification is in the correct "scope". Unfortunately, this is not true for g++: for a variable definition in a C++ namespace, it generates a DIE with DW_AT_declaration as a child of the DW_TAG_namespace DIE and a DIE which refers to the declaration with DW_AT_specification _outside_ of the DW_TAG_namespace as a child of the DW_TAG_compilation_unit DIE. Supporting both of these cases requires reworking how we handle DW_AT_specification. This commit takes an approach of parsing the DWARF data in two passes: the first pass reads the abbrevation and file name tables and builds a map of instances of DW_AT_specification; the second pass indexes DIEs as before, but ignores DIEs with DW_AT_specification and handles DIEs with DW_AT_declaration by looking them up in the map built by the first pass. This approach is a 10-20% regression in indexing time in the benchmarks I ran. Thankfully, it is not 100% slower for a couple of reasons. The first is that the two passes are simpler than the original combined pass. The second is that a decent part of the indexing time is spent faulting in the mapped debugging information, which only needs to happen once (even if the file is cached, minor page faults add non-negligible overhead). This doesn't handle DW_AT_specification "chains" yet, but neither did the original code. If it is necessary, it shouldn't be too difficult to add. Signed-off-by: Omar Sandoval <osandov@osandov.com> |
||
---|---|---|
.. | ||
build-aux | ||
elfutils | ||
examples | ||
include | ||
m4 | ||
python | ||
.gitignore | ||
arch_x86_64.c.in | ||
binary_search_tree.h | ||
cityhash.h | ||
configure.ac | ||
Doxyfile | ||
drgn.h.in | ||
dwarf_index.c | ||
dwarf_index.h | ||
dwarf_info_cache.c | ||
dwarf_info_cache.h | ||
error.c | ||
error.h | ||
hash_table.c | ||
hash_table.h | ||
helpers.h | ||
internal.c | ||
internal.h | ||
kdump.c | ||
language_c.c | ||
language.c | ||
language.h | ||
lexer.c | ||
lexer.h | ||
linux_kernel_helpers.c | ||
linux_kernel.c | ||
linux_kernel.h | ||
Makefile.am | ||
memory_reader.c | ||
memory_reader.h | ||
object_index.c | ||
object_index.h | ||
object.c | ||
object.h | ||
path.c | ||
platform.c | ||
platform.h | ||
program.c | ||
program.h | ||
read.h | ||
serialize.c | ||
serialize.h | ||
siphash.h | ||
splay_tree.c | ||
stack_trace.c | ||
string_builder.c | ||
string_builder.h | ||
symbol.c | ||
symbol.h | ||
type.c | ||
type.h | ||
util.h | ||
vector.c | ||
vector.h |