[Lldb-commits] [lldb] 7c5b535 - [lldb] Replace IRExecutionUnit::GetSectionTypeFromSectionName with Ob… (#157192)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 5 15:47:07 PDT 2025
Author: Adrian Prantl
Date: 2025-09-05T15:47:04-07:00
New Revision: 7c5b535d8c50e52ba13439ce52b9fe6fa34afcab
URL: https://github.com/llvm/llvm-project/commit/7c5b535d8c50e52ba13439ce52b9fe6fa34afcab
DIFF: https://github.com/llvm/llvm-project/commit/7c5b535d8c50e52ba13439ce52b9fe6fa34afcab.diff
LOG: [lldb] Replace IRExecutionUnit::GetSectionTypeFromSectionName with Ob… (#157192)
…jectFile API
This avoids code duplication.
Added:
Modified:
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Symbol/ObjectFile.cpp
Removed:
################################################################################
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index d557084acb745..998f03b098562 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -543,62 +543,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
else if (name.starts_with("__debug_") || name.starts_with(".debug_")) {
const uint32_t name_idx = name[0] == '_' ? 8 : 7;
llvm::StringRef dwarf_name(name.substr(name_idx));
- switch (dwarf_name[0]) {
- case 'a':
- if (dwarf_name == "abbrev")
- sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
- else if (dwarf_name == "aranges")
- sect_type = lldb::eSectionTypeDWARFDebugAranges;
- else if (dwarf_name == "addr")
- sect_type = lldb::eSectionTypeDWARFDebugAddr;
- break;
-
- case 'f':
- if (dwarf_name == "frame")
- sect_type = lldb::eSectionTypeDWARFDebugFrame;
- break;
-
- case 'i':
- if (dwarf_name == "info")
- sect_type = lldb::eSectionTypeDWARFDebugInfo;
- break;
-
- case 'l':
- if (dwarf_name == "line")
- sect_type = lldb::eSectionTypeDWARFDebugLine;
- else if (dwarf_name == "loc")
- sect_type = lldb::eSectionTypeDWARFDebugLoc;
- else if (dwarf_name == "loclists")
- sect_type = lldb::eSectionTypeDWARFDebugLocLists;
- break;
-
- case 'm':
- if (dwarf_name == "macinfo")
- sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
- break;
-
- case 'p':
- if (dwarf_name == "pubnames")
- sect_type = lldb::eSectionTypeDWARFDebugPubNames;
- else if (dwarf_name == "pubtypes")
- sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
- break;
-
- case 's':
- if (dwarf_name == "str")
- sect_type = lldb::eSectionTypeDWARFDebugStr;
- else if (dwarf_name == "str_offsets")
- sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
- break;
-
- case 'r':
- if (dwarf_name == "ranges")
- sect_type = lldb::eSectionTypeDWARFDebugRanges;
- break;
-
- default:
- break;
- }
+ sect_type = ObjectFile::GetDWARFSectionTypeFromName(dwarf_name);
} else if (name.starts_with("__apple_") || name.starts_with(".apple_"))
sect_type = lldb::eSectionTypeInvalid;
else if (name == "__objc_imageinfo")
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 7efce2a035505..9a79b3c627623 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -663,7 +663,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
.Case("str", eSectionTypeDWARFDebugStr)
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
- .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
+ .Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets)
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
.Case("tu_index", eSectionTypeDWARFDebugTuIndex)
.Case("types", eSectionTypeDWARFDebugTypes)
More information about the lldb-commits
mailing list