summaryrefslogtreecommitdiffstats
path: root/libdw/dwarf_macro_getsrcfiles.c
diff options
context:
space:
mode:
authorOmar Sandoval <[email protected]>2023-09-27 11:20:55 -0700
committerMark Wielaard <[email protected]>2023-10-03 23:36:05 +0200
commitefedcaa3415cf1305bb4d20a42aae3b60d341122 (patch)
treec1c7682e3643d4443380d62825dae7118f2231d3 /libdw/dwarf_macro_getsrcfiles.c
parent4bddabc1e7f3020b83a5abd98901146c58da403e (diff)
libdw: Handle split DWARF in dwarf_macro_getsrcfiles
Macro information references file names from the line number information table, which is tricky in split DWARF for a couple of reasons. First, the line number information for a macro unit comes from the .debug_line.dwo section in the split file, not the .debug_line section in the skeleton file. This was not specified in the GNU DebugFission design document [1] or the DWARF 5 standard, but it is how GCC and Clang behave in practice and was clarified in DWARF standard issue 200602.1 [2] for the upcoming DWARF 6 standard. dwarf_macro_getsrcfiles uses the line number information from whichever Dwarf handle it was passed. This is error-prone, since the most natural thing to do is to pass the skeleton Dwarf handle. Fix this by storing the appropriate Dwarf handle in Dwarf_Macro_Op_Table and using that one. Second, for .debug_macinfo.dwo in GNU DebugFission (generated by gcc -gdwarf-4 -gstrict-dwarf -gsplit-dwarf), the offset into .debug_line.dwo is implicitly 0. Again, this isn't in any specification, but it's how GCC behaves in practice (Clang never generates macro information for DWARF 4 split DWARF). Make get_macinfo_table default to 0 for split DWARF when it can't find DW_AT_stmt_list. 1: https://gcc.gnu.org/wiki/DebugFission 2: https://dwarfstd.org/issues/200602.1.html Signed-off-by: Omar Sandoval <[email protected]>
Diffstat (limited to 'libdw/dwarf_macro_getsrcfiles.c')
-rw-r--r--libdw/dwarf_macro_getsrcfiles.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c
index 4e8deeeb..11c587af 100644
--- a/libdw/dwarf_macro_getsrcfiles.c
+++ b/libdw/dwarf_macro_getsrcfiles.c
@@ -36,6 +36,9 @@ int
dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
Dwarf_Files **files, size_t *nfiles)
{
+ /* This was needed before Dwarf_Macro_Op_Table stored the Dwarf handle. */
+ (void)dbg;
+
/* macro is declared NN */
Dwarf_Macro_Op_Table *const table = macro->table;
if (table->files == NULL)
@@ -71,7 +74,7 @@ dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
the same unit through dwarf_getsrcfiles, and the file names
will be broken. */
- if (__libdw_getsrclines (dbg, line_offset, table->comp_dir,
+ if (__libdw_getsrclines (table->dbg, line_offset, table->comp_dir,
table->address_size, NULL, &table->files) < 0)
table->files = (void *) -1;
}