Skip to content

Commit 7c5b535

Browse files
[lldb] Replace IRExecutionUnit::GetSectionTypeFromSectionName with Ob… (#157192)
…jectFile API This avoids code duplication.
1 parent 1307e72 commit 7c5b535

File tree

2 files changed

+2
-57
lines changed

2 files changed

+2
-57
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -543,62 +543,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
543543
else if (name.starts_with("__debug_") || name.starts_with(".debug_")) {
544544
const uint32_t name_idx = name[0] == '_' ? 8 : 7;
545545
llvm::StringRef dwarf_name(name.substr(name_idx));
546-
switch (dwarf_name[0]) {
547-
case 'a':
548-
if (dwarf_name == "abbrev")
549-
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
550-
else if (dwarf_name == "aranges")
551-
sect_type = lldb::eSectionTypeDWARFDebugAranges;
552-
else if (dwarf_name == "addr")
553-
sect_type = lldb::eSectionTypeDWARFDebugAddr;
554-
break;
555-
556-
case 'f':
557-
if (dwarf_name == "frame")
558-
sect_type = lldb::eSectionTypeDWARFDebugFrame;
559-
break;
560-
561-
case 'i':
562-
if (dwarf_name == "info")
563-
sect_type = lldb::eSectionTypeDWARFDebugInfo;
564-
break;
565-
566-
case 'l':
567-
if (dwarf_name == "line")
568-
sect_type = lldb::eSectionTypeDWARFDebugLine;
569-
else if (dwarf_name == "loc")
570-
sect_type = lldb::eSectionTypeDWARFDebugLoc;
571-
else if (dwarf_name == "loclists")
572-
sect_type = lldb::eSectionTypeDWARFDebugLocLists;
573-
break;
574-
575-
case 'm':
576-
if (dwarf_name == "macinfo")
577-
sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
578-
break;
579-
580-
case 'p':
581-
if (dwarf_name == "pubnames")
582-
sect_type = lldb::eSectionTypeDWARFDebugPubNames;
583-
else if (dwarf_name == "pubtypes")
584-
sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
585-
break;
586-
587-
case 's':
588-
if (dwarf_name == "str")
589-
sect_type = lldb::eSectionTypeDWARFDebugStr;
590-
else if (dwarf_name == "str_offsets")
591-
sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
592-
break;
593-
594-
case 'r':
595-
if (dwarf_name == "ranges")
596-
sect_type = lldb::eSectionTypeDWARFDebugRanges;
597-
break;
598-
599-
default:
600-
break;
601-
}
546+
sect_type = ObjectFile::GetDWARFSectionTypeFromName(dwarf_name);
602547
} else if (name.starts_with("__apple_") || name.starts_with(".apple_"))
603548
sect_type = lldb::eSectionTypeInvalid;
604549
else if (name == "__objc_imageinfo")

lldb/source/Symbol/ObjectFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
663663
.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
664664
.Case("str", eSectionTypeDWARFDebugStr)
665665
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
666-
.Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
666+
.Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets)
667667
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
668668
.Case("tu_index", eSectionTypeDWARFDebugTuIndex)
669669
.Case("types", eSectionTypeDWARFDebugTypes)

0 commit comments

Comments
 (0)