Skip to content

Commit 0750365

Browse files
committed
[lldb] Replace IRExecutionUnit::GetSectionTypeFromSectionName with Ob… (llvm#157192)
…jectFile API This avoids code duplication. (cherry picked from commit 7c5b535)
1 parent 033960d commit 0750365

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
@@ -582,62 +582,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
582582
else if (name.starts_with("__debug_") || name.starts_with(".debug_")) {
583583
const uint32_t name_idx = name[0] == '_' ? 8 : 7;
584584
llvm::StringRef dwarf_name(name.substr(name_idx));
585-
switch (dwarf_name[0]) {
586-
case 'a':
587-
if (dwarf_name == "abbrev")
588-
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
589-
else if (dwarf_name == "aranges")
590-
sect_type = lldb::eSectionTypeDWARFDebugAranges;
591-
else if (dwarf_name == "addr")
592-
sect_type = lldb::eSectionTypeDWARFDebugAddr;
593-
break;
594-
595-
case 'f':
596-
if (dwarf_name == "frame")
597-
sect_type = lldb::eSectionTypeDWARFDebugFrame;
598-
break;
599-
600-
case 'i':
601-
if (dwarf_name == "info")
602-
sect_type = lldb::eSectionTypeDWARFDebugInfo;
603-
break;
604-
605-
case 'l':
606-
if (dwarf_name == "line")
607-
sect_type = lldb::eSectionTypeDWARFDebugLine;
608-
else if (dwarf_name == "loc")
609-
sect_type = lldb::eSectionTypeDWARFDebugLoc;
610-
else if (dwarf_name == "loclists")
611-
sect_type = lldb::eSectionTypeDWARFDebugLocLists;
612-
break;
613-
614-
case 'm':
615-
if (dwarf_name == "macinfo")
616-
sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
617-
break;
618-
619-
case 'p':
620-
if (dwarf_name == "pubnames")
621-
sect_type = lldb::eSectionTypeDWARFDebugPubNames;
622-
else if (dwarf_name == "pubtypes")
623-
sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
624-
break;
625-
626-
case 's':
627-
if (dwarf_name == "str")
628-
sect_type = lldb::eSectionTypeDWARFDebugStr;
629-
else if (dwarf_name == "str_offsets")
630-
sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
631-
break;
632-
633-
case 'r':
634-
if (dwarf_name == "ranges")
635-
sect_type = lldb::eSectionTypeDWARFDebugRanges;
636-
break;
637-
638-
default:
639-
break;
640-
}
585+
sect_type = ObjectFile::GetDWARFSectionTypeFromName(dwarf_name);
641586
} else if (name.starts_with("__apple_") || name.starts_with(".apple_"))
642587
sect_type = lldb::eSectionTypeInvalid;
643588
else if (name == "__objc_imageinfo")

lldb/source/Symbol/ObjectFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
672672
.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
673673
.Case("str", eSectionTypeDWARFDebugStr)
674674
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
675-
.Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
675+
.Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets)
676676
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
677677
.Case("tu_index", eSectionTypeDWARFDebugTuIndex)
678678
.Case("types", eSectionTypeDWARFDebugTypes)

0 commit comments

Comments
 (0)