diff options
author | nerix <nerixdev@outlook.de> | 2025-06-09 10:46:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-09 09:46:50 +0100 |
commit | c6670fa20d434a85e167e88aa6a4f56bfc02af2f (patch) | |
tree | af183d2ac93af37b5c6c157f7ee0fb96a4f68c78 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | |
parent | 62c9b0cab614f2d408929f9ee4280fc3c0084e08 (diff) | |
download | llvm-c6670fa20d434a85e167e88aa6a4f56bfc02af2f.zip llvm-c6670fa20d434a85e167e88aa6a4f56bfc02af2f.tar.gz llvm-c6670fa20d434a85e167e88aa6a4f56bfc02af2f.tar.bz2 |
[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.
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 389339a..4984445 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -976,25 +976,14 @@ SectionType ObjectFilePECOFF::GetSectionType(llvm::StringRef sect_name, return eSectionTypeData; } + if (sect_name.consume_front(".debug_")) + return GetDWARFSectionTypeFromName(sect_name); + SectionType section_type = llvm::StringSwitch<SectionType>(sect_name) .Case(".debug", eSectionTypeDebug) .Case(".stabstr", eSectionTypeDataCString) .Case(".reloc", eSectionTypeOther) - .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev) - .Case(".debug_aranges", eSectionTypeDWARFDebugAranges) - .Case(".debug_frame", eSectionTypeDWARFDebugFrame) - .Case(".debug_info", eSectionTypeDWARFDebugInfo) - .Case(".debug_line", eSectionTypeDWARFDebugLine) - .Case(".debug_loc", eSectionTypeDWARFDebugLoc) - .Case(".debug_loclists", eSectionTypeDWARFDebugLocLists) - .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo) - .Case(".debug_names", eSectionTypeDWARFDebugNames) - .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames) - .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes) - .Case(".debug_ranges", eSectionTypeDWARFDebugRanges) - .Case(".debug_str", eSectionTypeDWARFDebugStr) - .Case(".debug_types", eSectionTypeDWARFDebugTypes) // .eh_frame can be truncated to 8 chars. .Cases(".eh_frame", ".eh_fram", eSectionTypeEHFrame) .Case(".gosymtab", eSectionTypeGoSymtab) |