From: Omar Sandoval <osan...@fb.com> Hi,
This patch series adds support for DWARF package files to libdw and the elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1] and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package Files"). It supports both automatically opening the .dwp file for a skeleton unit and examining the .dwp file alone, just like for .dwo files. Patch 1 is a trivial cleanup I found while developing this. Patches 2-6 are fixes for unrelated bugs in split DWARF and/or DWARF 5 that I encountered while adding test cases for this series. I didn't add test cases explicitly for those fixes because they are covered by the dwp tests later in the series. The actual dwp support is in patches 7-10 and 13, including test cases. Patches 11 and 12 enable testing macro information in dwp files. Patch 14 adds support and tests for an LLVM extension to the dwp format. More details in the individual commit messages. Thanks! Omar P.S. drgn's dwp branch [2] demonstrates how the new dwarf_cu_dwp_section_info function will be used. With this patch series, drgn's test suite passes against a Linux kernel build using .dwp. 1: https://gcc.gnu.org/wiki/DebugFissionDWP 2: https://github.com/osandov/drgn/tree/dwp Omar Sandoval (14): libdw: Make try_split_file static libdw: Handle split DWARF in dwarf_entrypc libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges libdw: Handle other string forms in dwarf_macro_param2 libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 libdw: Handle split DWARF in dwarf_macro_getsrcfiles libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin libdw: Parse DWARF package file index sections libdw, libdwfl: Save original path of ELF file libdw: Try .dwp file in __libdw_find_split_unit() tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros tests: Optionally dump all units in dwarf-getmacros libdw: Apply DWARF package file section offsets where appropriate libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes libdw/ChangeLog | 72 + libdw/Makefile.am | 2 +- libdw/dwarf_begin_elf.c | 88 +- libdw/dwarf_cu_dwp_section_info.c | 529 ++++++ libdw/dwarf_end.c | 27 +- libdw/dwarf_entrypc.c | 12 +- libdw/dwarf_error.c | 1 + libdw/dwarf_getlocation.c | 6 + libdw/dwarf_getmacros.c | 54 +- libdw/dwarf_macro_getsrcfiles.c | 8 +- libdw/dwarf_macro_param2.c | 21 +- libdw/dwarf_ranges.c | 4 +- libdw/libdw.h | 23 + libdw/libdw.map | 5 + libdw/libdwP.h | 112 +- libdw/libdw_find_split_unit.c | 77 +- libdw/libdw_findcu.c | 8 + libdwfl/ChangeLog | 9 + libdwfl/dwfl_module.c | 2 +- libdwfl/dwfl_module_getdwarf.c | 11 +- libdwfl/libdwflP.h | 2 +- libdwfl/offline.c | 4 +- tests/.gitignore | 1 + tests/ChangeLog | 36 + tests/Makefile.am | 15 +- tests/cu-dwp-section-info.c | 74 + tests/dwarf-getmacros.c | 55 +- tests/run-all-dwarf-ranges.sh | 114 ++ tests/run-cu-dwp-section-info.sh | 168 ++ tests/run-dwarf-getmacros.sh | 1412 +++++++++++++++++ tests/run-get-units-split.sh | 18 + tests/run-large-elf-file.sh | 174 ++ tests/run-varlocs.sh | 126 +- tests/testfile-dwp-4-cu-index-overflow.bz2 | Bin 0 -> 4490 bytes .../testfile-dwp-4-cu-index-overflow.dwp.bz2 | Bin 0 -> 5584 bytes tests/testfile-dwp-4-strict.bz2 | Bin 0 -> 4169 bytes tests/testfile-dwp-4-strict.dwp.bz2 | Bin 0 -> 6871 bytes tests/testfile-dwp-4.bz2 | Bin 0 -> 4194 bytes tests/testfile-dwp-4.dwp.bz2 | Bin 0 -> 10098 bytes tests/testfile-dwp-5-cu-index-overflow.bz2 | Bin 0 -> 4544 bytes .../testfile-dwp-5-cu-index-overflow.dwp.bz2 | Bin 0 -> 5790 bytes tests/testfile-dwp-5.bz2 | Bin 0 -> 4223 bytes tests/testfile-dwp-5.dwp.bz2 | Bin 0 -> 10313 bytes tests/testfile-dwp-cu-index-overflow.source | 86 + tests/testfile-dwp.source | 102 ++ 45 files changed, 3337 insertions(+), 121 deletions(-) create mode 100644 libdw/dwarf_cu_dwp_section_info.c create mode 100644 tests/cu-dwp-section-info.c create mode 100755 tests/run-cu-dwp-section-info.sh create mode 100755 tests/testfile-dwp-4-cu-index-overflow.bz2 create mode 100644 tests/testfile-dwp-4-cu-index-overflow.dwp.bz2 create mode 100755 tests/testfile-dwp-4-strict.bz2 create mode 100644 tests/testfile-dwp-4-strict.dwp.bz2 create mode 100755 tests/testfile-dwp-4.bz2 create mode 100644 tests/testfile-dwp-4.dwp.bz2 create mode 100755 tests/testfile-dwp-5-cu-index-overflow.bz2 create mode 100644 tests/testfile-dwp-5-cu-index-overflow.dwp.bz2 create mode 100755 tests/testfile-dwp-5.bz2 create mode 100644 tests/testfile-dwp-5.dwp.bz2 create mode 100644 tests/testfile-dwp-cu-index-overflow.source create mode 100644 tests/testfile-dwp.source -- 2.41.0