Skip to content

Commit 9bb2cce

Browse files
jeffmahoneyosandov
authored andcommitted
Enable DWARF indexing to work with partial units
Loading debuginfo from a kernel with separate or re-combined debuginfo results in the following failure: Traceback (most recent call last): File "/home/jeffm/.local/bin/drgn", line 11, in <module> load_entry_point('drgn==0.0.3+39.gbf05d9bf', 'console_scripts', 'drgn')() File "/home/jeffm/.local/lib/python3.6/site-packages/drgn-0.0.3+39.gbf05d9bf-py3.6-linux-x86_64.egg/drgn/internal/cli.py", line 121, in main prog.load_debug_info(args.symbols, **args.default_symbols) Exception: invalid DW_AT_decl_file 10 A typical kernel build results in DWARF information with DW_TAG_compile_unit tags but the objcopy --only-keep-debug and eu-unstrip commands use DW_TAG_partial_unit tags. The DWARF indexer only handles the former, so the file table isn't populated and we get the exception. Fortunately, the two are more or less interchangeable. (See http://dwarfstd.org/doc/Dwarf3.pdf, section E.2.3). Accepting both for indexing compile units results in a working session.
1 parent 1376674 commit 9bb2cce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libdrgn/dwarf_index.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,8 @@ static struct drgn_error *read_abbrev_decl(const char **ptr, const char *end,
14101410
break;
14111411
}
14121412

1413-
if (should_index || tag == DW_TAG_compile_unit)
1413+
if (should_index || tag == DW_TAG_compile_unit ||
1414+
tag == DW_TAG_partial_unit)
14141415
die_flags = tag;
14151416
else
14161417
die_flags = 0;
@@ -1470,7 +1471,8 @@ static struct drgn_error *read_abbrev_decl(const char **ptr, const char *end,
14701471
break;
14711472
}
14721473
} else if (name == DW_AT_stmt_list &&
1473-
tag == DW_TAG_compile_unit &&
1474+
(tag == DW_TAG_compile_unit ||
1475+
tag == DW_TAG_partial_unit) &&
14741476
cu->sections[SECTION_DEBUG_LINE]) {
14751477
switch (form) {
14761478
case DW_FORM_data4:
@@ -2100,7 +2102,7 @@ static struct drgn_error *index_cu(struct drgn_dwarf_index *dindex,
21002102
}
21012103

21022104
tag = die.flags & TAG_MASK;
2103-
if (tag == DW_TAG_compile_unit) {
2105+
if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit) {
21042106
if (depth == 0 && die.stmt_list != SIZE_MAX &&
21052107
(err = read_file_name_table(dindex, cu,
21062108
die.stmt_list,

0 commit comments

Comments
 (0)