Skip to content

Commit dfb6f7b

Browse files
committed
Revert "[lldb] [DWARF-5] Be lazier about loading .dwo files"
This reverts commit 8dfd6ca. This change broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/8842
1 parent 66d92ef commit dfb6f7b

File tree

10 files changed

+97
-225
lines changed

10 files changed

+97
-225
lines changed

lldb/include/lldb/Symbol/CompileUnit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ class CompileUnit : public std::enable_shared_from_this<CompileUnit>,
442442

443443
CompileUnit(const CompileUnit &) = delete;
444444
const CompileUnit &operator=(const CompileUnit &) = delete;
445-
const char *GetCachedLanguage() const;
446445
};
447446

448447
} // namespace lldb_private

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

Lines changed: 53 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
3535
DIERef::Section section, bool is_dwo)
3636
: UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
3737
m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo),
38-
m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.GetDWOId()) {}
38+
m_dwo_id(header.GetDWOId()) {}
3939

4040
DWARFUnit::~DWARFUnit() = default;
4141

42-
// Parses first DIE of a compile unit, excluding DWO.
43-
void DWARFUnit::ExtractUnitDIENoDwoIfNeeded() {
42+
// Parses first DIE of a compile unit.
43+
void DWARFUnit::ExtractUnitDIEIfNeeded() {
4444
{
4545
llvm::sys::ScopedReader lock(m_first_die_mutex);
4646
if (m_first_die)
@@ -50,8 +50,7 @@ void DWARFUnit::ExtractUnitDIENoDwoIfNeeded() {
5050
if (m_first_die)
5151
return; // Already parsed
5252

53-
LLDB_SCOPED_TIMERF("%8.8x: DWARFUnit::ExtractUnitDIENoDwoIfNeeded()",
54-
GetOffset());
53+
LLDB_SCOPED_TIMERF("%8.8x: DWARFUnit::ExtractUnitDIEIfNeeded()", GetOffset());
5554

5655
// Set the offset to that of the first DIE and calculate the start of the
5756
// next compilation unit header.
@@ -67,58 +66,6 @@ void DWARFUnit::ExtractUnitDIENoDwoIfNeeded() {
6766
}
6867
}
6968

70-
// Parses first DIE of a compile unit including DWO.
71-
void DWARFUnit::ExtractUnitDIEIfNeeded() {
72-
ExtractUnitDIENoDwoIfNeeded();
73-
74-
if (m_has_parsed_non_skeleton_unit)
75-
return;
76-
77-
m_has_parsed_non_skeleton_unit = true;
78-
79-
std::shared_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
80-
m_dwarf.GetDwoSymbolFileForCompileUnit(*this, m_first_die);
81-
if (!dwo_symbol_file)
82-
return;
83-
84-
DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(m_dwo_id);
85-
86-
if (!dwo_cu)
87-
return; // Can't fetch the compile unit from the dwo file.
88-
dwo_cu->SetUserData(this);
89-
90-
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
91-
if (!dwo_cu_die.IsValid())
92-
return; // Can't fetch the compile unit DIE from the dwo file.
93-
94-
// Here for DWO CU we want to use the address base set in the skeleton unit
95-
// (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
96-
// otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
97-
// attributes which were applicable to the DWO units. The corresponding
98-
// DW_AT_* attributes standardized in DWARF v5 are also applicable to the
99-
// main unit in contrast.
100-
if (m_addr_base)
101-
dwo_cu->SetAddrBase(*m_addr_base);
102-
else if (m_gnu_addr_base)
103-
dwo_cu->SetAddrBase(*m_gnu_addr_base);
104-
105-
if (GetVersion() <= 4 && m_gnu_ranges_base)
106-
dwo_cu->SetRangesBase(*m_gnu_ranges_base);
107-
else if (dwo_symbol_file->GetDWARFContext()
108-
.getOrLoadRngListsData()
109-
.GetByteSize() > 0)
110-
dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
111-
112-
if (GetVersion() >= 5 &&
113-
dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
114-
0)
115-
dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
116-
117-
dwo_cu->SetBaseAddress(GetBaseAddress());
118-
119-
m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
120-
}
121-
12269
// Parses a compile unit and indexes its DIEs if it hasn't already been done.
12370
// It will leave this compile unit extracted forever.
12471
void DWARFUnit::ExtractDIEsIfNeeded() {
@@ -344,12 +291,14 @@ void DWARFUnit::SetDwoStrOffsetsBase() {
344291
}
345292

346293
uint64_t DWARFUnit::GetDWOId() {
347-
ExtractUnitDIENoDwoIfNeeded();
294+
ExtractUnitDIEIfNeeded();
348295
return m_dwo_id;
349296
}
350297

351298
// m_die_array_mutex must be already held as read/write.
352299
void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
300+
llvm::Optional<uint64_t> addr_base, gnu_addr_base, gnu_ranges_base;
301+
353302
DWARFAttributes attributes;
354303
size_t num_attributes = cu_die.GetAttributes(this, attributes);
355304

@@ -359,7 +308,8 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
359308
continue;
360309
DWARFFormValue form_value;
361310
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
362-
SetAddrBase(form_value.Unsigned());
311+
addr_base = form_value.Unsigned();
312+
SetAddrBase(*addr_base);
363313
break;
364314
}
365315
}
@@ -391,10 +341,10 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
391341
m_line_table_offset = form_value.Unsigned();
392342
break;
393343
case DW_AT_GNU_addr_base:
394-
m_gnu_addr_base = form_value.Unsigned();
344+
gnu_addr_base = form_value.Unsigned();
395345
break;
396346
case DW_AT_GNU_ranges_base:
397-
m_gnu_ranges_base = form_value.Unsigned();
347+
gnu_ranges_base = form_value.Unsigned();
398348
break;
399349
case DW_AT_GNU_dwo_id:
400350
m_dwo_id = form_value.Unsigned();
@@ -403,10 +353,50 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
403353
}
404354

405355
if (m_is_dwo) {
406-
m_has_parsed_non_skeleton_unit = true;
407356
SetDwoStrOffsetsBase();
408357
return;
409358
}
359+
360+
std::shared_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
361+
m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
362+
if (!dwo_symbol_file)
363+
return;
364+
365+
DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(m_dwo_id);
366+
367+
if (!dwo_cu)
368+
return; // Can't fetch the compile unit from the dwo file.
369+
dwo_cu->SetUserData(this);
370+
371+
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
372+
if (!dwo_cu_die.IsValid())
373+
return; // Can't fetch the compile unit DIE from the dwo file.
374+
375+
// Here for DWO CU we want to use the address base set in the skeleton unit
376+
// (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
377+
// otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
378+
// attributes which were applicable to the DWO units. The corresponding
379+
// DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
380+
// unit in contrast.
381+
if (addr_base)
382+
dwo_cu->SetAddrBase(*addr_base);
383+
else if (gnu_addr_base)
384+
dwo_cu->SetAddrBase(*gnu_addr_base);
385+
386+
if (GetVersion() <= 4 && gnu_ranges_base)
387+
dwo_cu->SetRangesBase(*gnu_ranges_base);
388+
else if (dwo_symbol_file->GetDWARFContext()
389+
.getOrLoadRngListsData()
390+
.GetByteSize() > 0)
391+
dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
392+
393+
if (GetVersion() >= 5 &&
394+
dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
395+
0)
396+
dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
397+
dwo_cu->SetBaseAddress(GetBaseAddress());
398+
399+
m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
410400
}
411401

412402
size_t DWARFUnit::GetDebugInfoSize() const {
@@ -422,7 +412,7 @@ dw_offset_t DWARFUnit::GetAbbrevOffset() const {
422412
}
423413

424414
dw_offset_t DWARFUnit::GetLineTableOffset() {
425-
ExtractUnitDIENoDwoIfNeeded();
415+
ExtractUnitDIEIfNeeded();
426416
return m_line_table_offset;
427417
}
428418

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class DWARFUnit : public lldb_private::UserID {
9292
uint64_t GetDWOId();
9393

9494
void ExtractUnitDIEIfNeeded();
95-
void ExtractUnitDIENoDwoIfNeeded();
9695
void ExtractDIEsIfNeeded();
9796

9897
class ScopedExtractDIEs {
@@ -152,7 +151,7 @@ class DWARFUnit : public lldb_private::UserID {
152151
const DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
153152
dw_offset_t GetAbbrevOffset() const;
154153
uint8_t GetAddressByteSize() const { return m_header.GetAddressByteSize(); }
155-
dw_addr_t GetAddrBase() const { return m_addr_base ? *m_addr_base : 0; }
154+
dw_addr_t GetAddrBase() const { return m_addr_base; }
156155
dw_addr_t GetBaseAddress() const { return m_base_addr; }
157156
dw_offset_t GetLineTableOffset();
158157
dw_addr_t GetRangesBase() const { return m_ranges_base; }
@@ -269,7 +268,7 @@ class DWARFUnit : public lldb_private::UserID {
269268
// Get the DWARF unit DWARF debug information entry. Parse the single DIE
270269
// if needed.
271270
const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
272-
ExtractUnitDIENoDwoIfNeeded();
271+
ExtractUnitDIEIfNeeded();
273272
// m_first_die_mutex is not required as m_first_die is never cleared.
274273
if (!m_first_die)
275274
return NULL;
@@ -316,11 +315,9 @@ class DWARFUnit : public lldb_private::UserID {
316315
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
317316
llvm::Optional<lldb_private::FileSpec> m_comp_dir;
318317
llvm::Optional<lldb_private::FileSpec> m_file_spec;
319-
llvm::Optional<dw_addr_t> m_addr_base; ///< Value of DW_AT_addr_base.
320-
dw_addr_t m_loclists_base = 0; ///< Value of DW_AT_loclists_base.
321-
dw_addr_t m_ranges_base = 0; ///< Value of DW_AT_rnglists_base.
322-
llvm::Optional<uint64_t> m_gnu_addr_base;
323-
llvm::Optional<uint64_t> m_gnu_ranges_base;
318+
dw_addr_t m_addr_base = 0; ///< Value of DW_AT_addr_base.
319+
dw_addr_t m_loclists_base = 0; ///< Value of DW_AT_loclists_base.
320+
dw_addr_t m_ranges_base = 0; ///< Value of DW_AT_rnglists_base.
324321

325322
/// Value of DW_AT_stmt_list.
326323
dw_offset_t m_line_table_offset = DW_INVALID_OFFSET;
@@ -333,7 +330,6 @@ class DWARFUnit : public lldb_private::UserID {
333330

334331
const DIERef::Section m_section;
335332
bool m_is_dwo;
336-
bool m_has_parsed_non_skeleton_unit;
337333
/// Value of DW_AT_GNU_dwo_id (v4) or dwo_id from CU header (v5).
338334
uint64_t m_dwo_id;
339335

0 commit comments

Comments
 (0)