From c6670fa20d434a85e167e88aa6a4f56bfc02af2f Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 9 Jun 2025 10:46:50 +0200 Subject: [LLDB] Unify DWARF section name matching (#141344) Different object file formats support DWARF sections (COFF, ELF, MachO, PE/COFF, WASM). COFF and PE/COFF only matched a subset. This caused some GCC executables produced on MinGW to have issue later on when debugging. One example is that `.debug_rnglists` was not matched, which caused range-extraction to fail when printing a backtrace. This unifies the parsing of section names in `ObjectFile::GetDWARFSectionTypeFromName`, so all file formats can use the same naming convention. Since the prefixes are different, `GetDWARFSectionTypeFromName` only matches the suffixes (i.e. `.debug_` needs to be stripped before). I added two tests to ensure the sections are correctly identified on Windows executables. --- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 36 ++-------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp') diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 13e1198..f69358d 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1653,39 +1653,9 @@ lldb::user_id_t ObjectFileELF::GetSectionIndexByName(const char *name) { } static SectionType GetSectionTypeFromName(llvm::StringRef Name) { - if (Name.consume_front(".debug_")) { - return llvm::StringSwitch(Name) - .Case("abbrev", eSectionTypeDWARFDebugAbbrev) - .Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo) - .Case("addr", eSectionTypeDWARFDebugAddr) - .Case("aranges", eSectionTypeDWARFDebugAranges) - .Case("cu_index", eSectionTypeDWARFDebugCuIndex) - .Case("frame", eSectionTypeDWARFDebugFrame) - .Case("info", eSectionTypeDWARFDebugInfo) - .Case("info.dwo", eSectionTypeDWARFDebugInfoDwo) - .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine) - .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr) - .Case("loc", eSectionTypeDWARFDebugLoc) - .Case("loc.dwo", eSectionTypeDWARFDebugLocDwo) - .Case("loclists", eSectionTypeDWARFDebugLocLists) - .Case("loclists.dwo", eSectionTypeDWARFDebugLocListsDwo) - .Case("macinfo", eSectionTypeDWARFDebugMacInfo) - .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro) - .Case("names", eSectionTypeDWARFDebugNames) - .Case("pubnames", eSectionTypeDWARFDebugPubNames) - .Case("pubtypes", eSectionTypeDWARFDebugPubTypes) - .Case("ranges", eSectionTypeDWARFDebugRanges) - .Case("rnglists", eSectionTypeDWARFDebugRngLists) - .Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo) - .Case("str", eSectionTypeDWARFDebugStr) - .Case("str.dwo", eSectionTypeDWARFDebugStrDwo) - .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets) - .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo) - .Case("tu_index", eSectionTypeDWARFDebugTuIndex) - .Case("types", eSectionTypeDWARFDebugTypes) - .Case("types.dwo", eSectionTypeDWARFDebugTypesDwo) - .Default(eSectionTypeOther); - } + if (Name.consume_front(".debug_")) + return ObjectFile::GetDWARFSectionTypeFromName(Name); + return llvm::StringSwitch(Name) .Case(".ARM.exidx", eSectionTypeARMexidx) .Case(".ARM.extab", eSectionTypeARMextab) -- cgit v1.1