Skip to content

Commit 04363ba

Browse files
committed
After merge, address review comments and remove dead code.
1 parent 843e0be commit 04363ba

File tree

8 files changed

+27
-43
lines changed

8 files changed

+27
-43
lines changed

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,6 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section section,
222222
return result;
223223
}
224224

225-
// DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
226-
// // Make sure we get the correct SymbolFileDWARF from the DIERef before
227-
// // asking for information from a debug info object. We might start with the
228-
// // DWARFDebugInfo for the main executable in a split DWARF and the DIERef
229-
// // might be pointing to a specific .dwo file or to the .dwp file. So this
230-
// // makes sure we get the right SymbolFileDWARF instance before finding the
231-
// // DWARFUnit that contains the offset. If we just use this object to do the
232-
// // search, we might be using the wrong .debug_info section from the wrong
233-
// // file with an offset meant for a different section.
234-
// SymbolFileDWARF *dwarf = m_dwarf.GetDIERefSymbolFile(die_ref);
235-
// return dwarf->DebugInfo().GetUnitContainingDIEOffset(die_ref.section(),
236-
// die_ref.die_offset());
237-
// }
238-
239225
DWARFUnit *
240226
DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
241227
dw_offset_t die_offset) {
@@ -246,7 +232,7 @@ DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
246232
return result;
247233
}
248234

249-
const std::shared_ptr<SymbolFileDWARFDwo> DWARFDebugInfo::GetDwpSymbolFile() {
235+
const std::shared_ptr<SymbolFileDWARFDwo> &DWARFDebugInfo::GetDwpSymbolFile() {
250236
return m_dwarf.GetDwpSymbolFile();
251237
}
252238

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DWARFDebugInfo {
5252

5353
const DWARFDebugAranges &GetCompileUnitAranges();
5454

55-
const std::shared_ptr<SymbolFileDWARFDwo> GetDwpSymbolFile();
55+
const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile();
5656

5757
protected:
5858
typedef std::vector<DWARFUnitSP> UnitColl;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
3737

3838

3939
llvm::DenseSet<uint64_t>
40-
DebugNamesDWARFIndex::GetTypeUnitSigs(const DebugNames &debug_names) {
40+
DebugNamesDWARFIndex::GetTypeUnitSignatures(const DebugNames &debug_names) {
4141
llvm::DenseSet<uint64_t> result;
4242
for (const DebugNames::NameIndex &ni : debug_names) {
4343
const uint32_t num_tus = ni.getForeignTUCount();

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class DebugNamesDWARFIndex : public DWARFIndex {
7171
m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
7272
m_debug_names_up(std::move(debug_names_up)),
7373
m_fallback(module, dwarf, GetUnits(*m_debug_names_up),
74-
GetTypeUnitSigs(*m_debug_names_up)) {}
74+
GetTypeUnitSignatures(*m_debug_names_up)) {}
7575

7676
DWARFDebugInfo &m_debug_info;
7777

@@ -87,15 +87,14 @@ class DebugNamesDWARFIndex : public DWARFIndex {
8787
DWARFUnit *GetNonSkeletonUnit(const DebugNames::Entry &entry) const;
8888
DWARFDIE GetDIE(const DebugNames::Entry &entry) const;
8989

90-
// std::optional<DIERef> ToDIERef(const DebugNames::Entry &entry) const;
91-
9290
/// Checks if an entry is a foreign TU and fetch the type unit.
9391
///
9492
/// This function checks if the DebugNames::Entry refers to a foreign TU and
95-
/// returns true or false to indicate this. The \a foreign_tu pointer will be
96-
/// filled in if this entry matches the type unit's originating .dwo file by
97-
/// verifying that the DW_TAG_type_unit DIE has a DW_AT_dwo_name that matches
98-
/// the DWO name from the originating skeleton compile unit.
93+
/// returns an optional with a value of the \a entry is a foreign type unit
94+
/// entry. A valid pointer will be returned if this entry is from a .dwo file
95+
/// or if it is from a .dwp file and it matches the type unit's originating
96+
/// .dwo file by verifying that the DW_TAG_type_unit DIE has a DW_AT_dwo_name
97+
/// that matches the DWO name from the originating skeleton compile unit.
9998
///
10099
/// \param[in] entry
101100
/// The accelerator table entry to check.
@@ -112,9 +111,6 @@ class DebugNamesDWARFIndex : public DWARFIndex {
112111
std::optional<DWARFTypeUnit *>
113112
IsForeignTypeUnit(const DebugNames::Entry &entry) const;
114113

115-
DWARFTypeUnit *GetForeignTypeUnit(const DebugNames::Entry &entry) const;
116-
117-
std::optional<DIERef> ToDIERef(const DebugNames::Entry &entry) const;
118114
bool ProcessEntry(const DebugNames::Entry &entry,
119115
llvm::function_ref<bool(DWARFDIE die)> callback);
120116

@@ -127,7 +123,7 @@ class DebugNamesDWARFIndex : public DWARFIndex {
127123
llvm::StringRef name);
128124

129125
static llvm::DenseSet<dw_offset_t> GetUnits(const DebugNames &debug_names);
130-
static llvm::DenseSet<uint64_t> GetTypeUnitSigs(const DebugNames &debug_names);
126+
static llvm::DenseSet<uint64_t> GetTypeUnitSignatures(const DebugNames &debug_names);
131127
};
132128

133129
} // namespace dwarf

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void ManualDWARFIndex::Index() {
6161
if (dwp_info && dwp_info->ContainsTypeUnits()) {
6262
for (size_t U = 0; U < dwp_info->GetNumUnits(); ++U) {
6363
if (auto *tu = llvm::dyn_cast<DWARFTypeUnit>(dwp_info->GetUnitAtIndex(U))) {
64-
if (m_type_sigs_to_avoid.count(tu->GetTypeHash()) == 0)
64+
if (!m_type_sigs_to_avoid.contains(tu->GetTypeHash()))
6565
units_to_index.push_back(tu);
6666
}
6767
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ManualDWARFIndex : public DWARFIndex {
2525
llvm::DenseSet<uint64_t> type_sigs_to_avoid = {})
2626
: DWARFIndex(module), m_dwarf(&dwarf),
2727
m_units_to_avoid(std::move(units_to_avoid)),
28-
m_type_sigs_to_avoid(type_sigs_to_avoid) {}
28+
m_type_sigs_to_avoid(std::move(type_sigs_to_avoid)) {}
2929

3030
void Preload() override { Index(); }
3131

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ llvm::DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
693693
if (debug_abbrev_data.GetByteSize() == 0)
694694
return nullptr;
695695

696+
ElapsedTime elapsed(m_parse_time);
696697
auto abbr =
697698
std::make_unique<llvm::DWARFDebugAbbrev>(debug_abbrev_data.GetAsLLVM());
698699
llvm::Error error = abbr->parse();
@@ -2735,6 +2736,7 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27352736
die_context = die.GetDeclContext();
27362737
else
27372738
die_context = die.GetTypeLookupContext();
2739+
assert(!die_context.empty());
27382740
if (!query.ContextMatches(die_context))
27392741
return true; // Keep iterating over index types, context mismatch.
27402742

lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
// This test will make a type that will be compiled differently into two
44
// different .dwo files in a type unit with the same type hash, but with
5-
// differing contents. I have discovered that the hash for the type unit is
6-
// simply based off of the typename and doesn't seem to differ when the contents
7-
// differ, so that will help us test foreign type units in the .debug_names
8-
// section of the main executable. When a DWP file is made, only one type unit
9-
// will be kept and the type unit that is kept has the .dwo file name that it
10-
// came from. When LLDB loads the foreign type units, it needs to verify that
11-
// any entries from foreign type units come from the right .dwo file. We test
12-
// this since the contents of type units are not always the same even though
13-
// they have the same type hash. We don't want invalid accelerator table entries
14-
// to come from one .dwo file and be used on a type unit from another since this
15-
// could cause invalid lookups to happen. LLDB knows how to track down which
16-
// .dwo file a type unit comes from by looking at the DW_AT_dwo_name attribute
17-
// in the DW_TAG_type_unit.
5+
// differing contents. Clang's type unit signature is based only on the mangled
6+
// name of the type, regardless of the contents of the type, so that will help
7+
// us test foreign type units in the .debug_names section of the main
8+
// executable. When a DWP file is made, only one type unit will be kept and the
9+
// type unit that is kept has the .dwo file name that it came from. When LLDB
10+
// loads the foreign type units, it needs to verify that any entries from
11+
// foreign type units come from the right .dwo file. We test this since the
12+
// contents of type units are not always the same even though they have the same
13+
// type hash. We don't want invalid accelerator table entries to come from one
14+
// .dwo file and be used on a type unit from another since this could cause
15+
// invalid lookups to happen. LLDB knows how to track down which .dwo file a
16+
// type unit comes from by looking at the DW_AT_dwo_name attribute in the
17+
// DW_TAG_type_unit.
1818

1919
// Now test with DWARF5
2020
// RUN: %clang -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf \

0 commit comments

Comments
 (0)