Skip to content

Commit 4b5bc38

Browse files
committed
[lldb/DWARF] Move location list sections into DWARFContext
These are the last sections not managed by the DWARFContext object. I also introduce separate SectionType enums for dwo section variants, as this is necessary for proper handling of single-file split dwarf.
1 parent e1f524e commit 4b5bc38

File tree

12 files changed

+70
-19
lines changed

12 files changed

+70
-19
lines changed

lldb/include/lldb/lldb-enumerations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ enum SectionType {
692692
eSectionTypeDWARFDebugStrOffsetsDwo,
693693
eSectionTypeDWARFDebugTypesDwo,
694694
eSectionTypeDWARFDebugRngListsDwo,
695+
eSectionTypeDWARFDebugLocDwo,
696+
eSectionTypeDWARFDebugLocListsDwo,
695697
};
696698

697699
FLAGS_ENUM(EmulateInstructionOptions){

lldb/source/Core/Section.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ const char *Section::GetTypeAsCString() const {
8080
return "dwarf-line-str";
8181
case eSectionTypeDWARFDebugLoc:
8282
return "dwarf-loc";
83+
case eSectionTypeDWARFDebugLocDwo:
84+
return "dwarf-loc-dwo";
8385
case eSectionTypeDWARFDebugLocLists:
8486
return "dwarf-loclists";
87+
case eSectionTypeDWARFDebugLocListsDwo:
88+
return "dwarf-loclists-dwo";
8589
case eSectionTypeDWARFDebugMacInfo:
8690
return "dwarf-macinfo";
8791
case eSectionTypeDWARFDebugMacro:

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,10 @@ static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
15721572
.Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
15731573
.Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
15741574
.Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
1575-
.Cases("loc", "loc.dwo", eSectionTypeDWARFDebugLoc)
1576-
.Cases("loclists", "loclists.dwo", eSectionTypeDWARFDebugLocLists)
1575+
.Case("loc", eSectionTypeDWARFDebugLoc)
1576+
.Case("loc.dwo", eSectionTypeDWARFDebugLocDwo)
1577+
.Case("loclists", eSectionTypeDWARFDebugLocLists)
1578+
.Case("loclists.dwo", eSectionTypeDWARFDebugLocListsDwo)
15771579
.Case("macinfo", eSectionTypeDWARFDebugMacInfo)
15781580
.Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
15791581
.Case("names", eSectionTypeDWARFDebugNames)

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,9 @@ AddressClass ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) {
11331133
case eSectionTypeDWARFDebugLine:
11341134
case eSectionTypeDWARFDebugLineStr:
11351135
case eSectionTypeDWARFDebugLoc:
1136+
case eSectionTypeDWARFDebugLocDwo:
11361137
case eSectionTypeDWARFDebugLocLists:
1138+
case eSectionTypeDWARFDebugLocListsDwo:
11371139
case eSectionTypeDWARFDebugMacInfo:
11381140
case eSectionTypeDWARFDebugMacro:
11391141
case eSectionTypeDWARFDebugNames:

lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() {
7070
m_data_debug_line_str);
7171
}
7272

73+
const DWARFDataExtractor &DWARFContext::getOrLoadLocData() {
74+
return LoadOrGetSection(eSectionTypeDWARFDebugLoc,
75+
eSectionTypeDWARFDebugLocDwo, m_data_debug_loc);
76+
}
77+
78+
const DWARFDataExtractor &DWARFContext::getOrLoadLocListsData() {
79+
return LoadOrGetSection(eSectionTypeDWARFDebugLocLists,
80+
eSectionTypeDWARFDebugLocListsDwo,
81+
m_data_debug_loclists);
82+
}
83+
7384
const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
7485
return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
7586
m_data_debug_macro);

lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class DWARFContext {
3434
SectionData m_data_debug_info;
3535
SectionData m_data_debug_line;
3636
SectionData m_data_debug_line_str;
37+
SectionData m_data_debug_loc;
38+
SectionData m_data_debug_loclists;
3739
SectionData m_data_debug_macro;
3840
SectionData m_data_debug_ranges;
3941
SectionData m_data_debug_rnglists;
@@ -58,6 +60,8 @@ class DWARFContext {
5860
const DWARFDataExtractor &getOrLoadDebugInfoData();
5961
const DWARFDataExtractor &getOrLoadLineData();
6062
const DWARFDataExtractor &getOrLoadLineStrData();
63+
const DWARFDataExtractor &getOrLoadLocData();
64+
const DWARFDataExtractor &getOrLoadLocListsData();
6165
const DWARFDataExtractor &getOrLoadMacroData();
6266
const DWARFDataExtractor &getOrLoadRangesData();
6367
const DWARFDataExtractor &getOrLoadRngListsData();

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
380380
.GetByteSize() > 0)
381381
dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
382382

383-
if (GetVersion() >= 5 &&
384-
m_dwo_symbol_file->get_debug_loclists_data().GetByteSize() > 0)
383+
if (GetVersion() >= 5 && m_dwo_symbol_file->GetDWARFContext()
384+
.getOrLoadLocListsData()
385+
.GetByteSize() > 0)
385386
dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
386387
dwo_cu->SetBaseAddress(GetBaseAddress());
387388

@@ -455,7 +456,8 @@ void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
455456
m_loclist_table_header.emplace(".debug_loclists", "locations");
456457
uint64_t offset = loclists_base - header_size;
457458
if (llvm::Error E = m_loclist_table_header->extract(
458-
m_dwarf.get_debug_loclists_data().GetAsLLVM(), &offset)) {
459+
m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVM(),
460+
&offset)) {
459461
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
460462
"Failed to extract location list table at offset 0x%" PRIx64 ": %s",
461463
loclists_base, toString(std::move(E)).c_str());
@@ -474,8 +476,9 @@ DWARFUnit::GetLocationTable(const DataExtractor &data) const {
474476
}
475477

476478
const DWARFDataExtractor &DWARFUnit::GetLocationData() const {
477-
return GetVersion() >= 5 ? GetSymbolFileDWARF().get_debug_loclists_data()
478-
: GetSymbolFileDWARF().get_debug_loc_data();
479+
DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext();
480+
return GetVersion() >= 5 ? Ctx.getOrLoadLocListsData()
481+
: Ctx.getOrLoadLocData();
479482
}
480483

481484
void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,15 +597,6 @@ void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type,
597597
m_objfile_sp->ReadSectionData(section_sp.get(), data);
598598
}
599599

600-
const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() {
601-
return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc);
602-
}
603-
604-
const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() {
605-
return GetCachedSectionData(eSectionTypeDWARFDebugLocLists,
606-
m_data_debug_loclists);
607-
}
608-
609600
DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
610601
if (m_abbr)
611602
return m_abbr.get();

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
222222

223223
uint32_t GetPluginVersion() override;
224224

225-
const lldb_private::DWARFDataExtractor &get_debug_loc_data();
226-
const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
227-
228225
DWARFDebugAbbrev *DebugAbbrev();
229226

230227
const DWARFDebugAbbrev *DebugAbbrev() const;

lldb/source/Symbol/ObjectFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
352352
case eSectionTypeDWARFDebugLine:
353353
case eSectionTypeDWARFDebugLineStr:
354354
case eSectionTypeDWARFDebugLoc:
355+
case eSectionTypeDWARFDebugLocDwo:
355356
case eSectionTypeDWARFDebugLocLists:
357+
case eSectionTypeDWARFDebugLocListsDwo:
356358
case eSectionTypeDWARFDebugMacInfo:
357359
case eSectionTypeDWARFDebugMacro:
358360
case eSectionTypeDWARFDebugNames:

lldb/test/Shell/ObjectFile/ELF/section-types.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
# CHECK-LABEL: Name: .debug_types.dwo
1414
# CHECK-NEXT: Type: dwarf-types-dwo
1515

16+
# CHECK-LABEL: Name: .debug_loc
17+
# CHECK-NEXT: Type: dwarf-loc
18+
19+
# CHECK-LABEL: Name: .debug_loc.dwo
20+
# CHECK-NEXT: Type: dwarf-loc-dwo
21+
22+
# CHECK-LABEL: Name: .debug_loclists
23+
# CHECK-NEXT: Type: dwarf-loclists
24+
25+
# CHECK-LABEL: Name: .debug_loclists.dwo
26+
# CHECK-NEXT: Type: dwarf-loclists-dwo
27+
1628
# CHECK-LABEL: Name: .debug_rnglists
1729
# CHECK-NEXT: Type: dwarf-rnglists
1830

@@ -64,6 +76,22 @@ Sections:
6476
Type: SHT_PROGBITS
6577
AddressAlign: 0x0000000000000001
6678
Content: DEADBEEFBAADF00D
79+
- Name: .debug_loc
80+
Type: SHT_PROGBITS
81+
AddressAlign: 0x0000000000000001
82+
Content: DEADBEEFBAADF00D
83+
- Name: .debug_loc.dwo
84+
Type: SHT_PROGBITS
85+
AddressAlign: 0x0000000000000001
86+
Content: DEADBEEFBAADF00D
87+
- Name: .debug_loclists
88+
Type: SHT_PROGBITS
89+
AddressAlign: 0x0000000000000001
90+
Content: DEADBEEFBAADF00D
91+
- Name: .debug_loclists.dwo
92+
Type: SHT_PROGBITS
93+
AddressAlign: 0x0000000000000001
94+
Content: DEADBEEFBAADF00D
6795
- Name: .debug_rnglists
6896
Type: SHT_PROGBITS
6997
AddressAlign: 0x0000000000000001

lldb/test/Shell/SymbolFile/DWARF/debug_loclists-dwo.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ lookup_loclists:
8282
.quad .Ltmp1
8383
.Ldebug_addr_end0:
8484

85+
# The presence of an extra non-dwo loclists section should not confuse us.
86+
# .debug_info.dwo always refers to .debug_loclists.dwo
87+
.section .debug_loclists,"",@progbits
88+
.quad 0xdeadbeefbaadf00d
89+
8590
.section .debug_loclists.dwo,"e",@progbits
8691
.long .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
8792
.Ldebug_loclist_table_start0:

0 commit comments

Comments
 (0)