Skip to content

Commit 9289f34

Browse files
committed
Revert "[nfc] [lldb] Introduce DWARF callbacks"
This reverts commit bd47c47. It broke Green Dragon, reason is unknown to me so far: http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/15323/consoleFull Differential Revision: https://reviews.llvm.org/D77327
1 parent ef2cb8d commit 9289f34

18 files changed

+528
-586
lines changed

lldb/include/lldb/Core/UniqueCStringMap.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ template <typename T> class UniqueCStringMap {
3232
T value;
3333
};
3434

35-
typedef std::vector<Entry> collection;
36-
typedef typename collection::iterator iterator;
37-
typedef typename collection::const_iterator const_iterator;
38-
3935
// Call this function multiple times to add a bunch of entries to this map,
4036
// then later call UniqueCStringMap<T>::Sort() before doing any searches by
4137
// name.
@@ -179,18 +175,6 @@ template <typename T> class UniqueCStringMap {
179175
}
180176
}
181177

182-
iterator begin() { return m_map.begin(); }
183-
iterator end() { return m_map.end(); }
184-
const_iterator begin() const { return m_map.begin(); }
185-
const_iterator end() const { return m_map.end(); }
186-
187-
// Range-based for loop for all entries of the specified ConstString name.
188-
llvm::iterator_range<const_iterator>
189-
equal_range(ConstString unique_cstr) const {
190-
return llvm::make_range(
191-
std::equal_range(m_map.begin(), m_map.end(), unique_cstr, Compare()));
192-
};
193-
194178
protected:
195179
struct Compare {
196180
bool operator()(const Entry &lhs, const Entry &rhs) {
@@ -212,6 +196,9 @@ template <typename T> class UniqueCStringMap {
212196
return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString());
213197
}
214198
};
199+
typedef std::vector<Entry> collection;
200+
typedef typename collection::iterator iterator;
201+
typedef typename collection::const_iterator const_iterator;
215202
collection m_map;
216203
};
217204

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

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,60 +52,57 @@ std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create(
5252
return nullptr;
5353
}
5454

55-
void AppleDWARFIndex::GetGlobalVariables(
56-
ConstString basename, llvm::function_ref<bool(DIERef ref)> callback) {
55+
void AppleDWARFIndex::GetGlobalVariables(ConstString basename, DIEArray &offsets) {
5756
if (!m_apple_names_up)
5857
return;
59-
m_apple_names_up->FindByName(basename.GetStringRef(), callback);
58+
m_apple_names_up->FindByName(basename.GetStringRef(), offsets);
6059
}
6160

62-
void AppleDWARFIndex::GetGlobalVariables(
63-
const RegularExpression &regex,
64-
llvm::function_ref<bool(DIERef ref)> callback) {
61+
void AppleDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
62+
DIEArray &offsets) {
6563
if (!m_apple_names_up)
6664
return;
6765

6866
DWARFMappedHash::DIEInfoArray hash_data;
69-
m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data);
70-
DWARFMappedHash::ExtractDIEArray(hash_data, callback);
67+
if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data))
68+
DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
7169
}
7270

73-
void AppleDWARFIndex::GetGlobalVariables(
74-
const DWARFUnit &cu, llvm::function_ref<bool(DIERef ref)> callback) {
71+
void AppleDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
72+
DIEArray &offsets) {
7573
if (!m_apple_names_up)
7674
return;
7775

7876
DWARFMappedHash::DIEInfoArray hash_data;
79-
m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(), cu.GetNextUnitOffset(),
80-
hash_data);
81-
DWARFMappedHash::ExtractDIEArray(hash_data, callback);
77+
if (m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(),
78+
cu.GetNextUnitOffset(), hash_data))
79+
DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
8280
}
8381

84-
void AppleDWARFIndex::GetObjCMethods(
85-
ConstString class_name, llvm::function_ref<bool(DIERef ref)> callback) {
82+
void AppleDWARFIndex::GetObjCMethods(ConstString class_name,
83+
DIEArray &offsets) {
8684
if (!m_apple_objc_up)
8785
return;
88-
m_apple_objc_up->FindByName(class_name.GetStringRef(), callback);
86+
m_apple_objc_up->FindByName(class_name.GetStringRef(), offsets);
8987
}
9088

91-
void AppleDWARFIndex::GetCompleteObjCClass(
92-
ConstString class_name, bool must_be_implementation,
93-
llvm::function_ref<bool(DIERef ref)> callback) {
89+
void AppleDWARFIndex::GetCompleteObjCClass(ConstString class_name,
90+
bool must_be_implementation,
91+
DIEArray &offsets) {
9492
if (!m_apple_types_up)
9593
return;
9694
m_apple_types_up->FindCompleteObjCClassByName(
97-
class_name.GetStringRef(), callback, must_be_implementation);
95+
class_name.GetStringRef(), offsets, must_be_implementation);
9896
}
9997

100-
void AppleDWARFIndex::GetTypes(ConstString name,
101-
llvm::function_ref<bool(DIERef ref)> callback) {
98+
void AppleDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
10299
if (!m_apple_types_up)
103100
return;
104-
m_apple_types_up->FindByName(name.GetStringRef(), callback);
101+
m_apple_types_up->FindByName(name.GetStringRef(), offsets);
105102
}
106103

107104
void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
108-
llvm::function_ref<bool(DIERef ref)> callback) {
105+
DIEArray &offsets) {
109106
if (!m_apple_types_up)
110107
return;
111108

@@ -125,7 +122,7 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
125122
if (log)
126123
m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
127124
m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
128-
type_name.GetStringRef(), tag, qualified_name_hash, callback);
125+
type_name.GetStringRef(), tag, qualified_name_hash, offsets);
129126
return;
130127
}
131128

@@ -139,46 +136,47 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
139136
if (!has_qualified_name_hash && (context.GetSize() > 1) &&
140137
(context[1].tag == DW_TAG_class_type ||
141138
context[1].tag == DW_TAG_structure_type)) {
142-
if (!m_apple_types_up->FindByName(context[1].name,
143-
[&](DIERef ref) { return false; }))
139+
DIEArray class_matches;
140+
m_apple_types_up->FindByName(context[1].name, class_matches);
141+
if (class_matches.empty())
144142
return;
145143
}
146144

147145
if (log)
148146
m_module.LogMessage(log, "FindByNameAndTag()");
149-
m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, callback);
147+
m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
150148
return;
151149
}
152150

153-
m_apple_types_up->FindByName(type_name.GetStringRef(), callback);
151+
m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
154152
}
155153

156-
void AppleDWARFIndex::GetNamespaces(
157-
ConstString name, llvm::function_ref<bool(DIERef ref)> callback) {
154+
void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
158155
if (!m_apple_namespaces_up)
159156
return;
160-
m_apple_namespaces_up->FindByName(name.GetStringRef(), callback);
157+
m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
161158
}
162159

163-
void AppleDWARFIndex::GetFunctions(
164-
ConstString name, SymbolFileDWARF &dwarf,
165-
const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
166-
llvm::function_ref<bool(DWARFDIE die)> callback) {
167-
m_apple_names_up->FindByName(name.GetStringRef(), [&](DIERef die_ref) {
168-
return ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf,
169-
parent_decl_ctx, name_type_mask, callback);
170-
});
160+
void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
161+
const CompilerDeclContext &parent_decl_ctx,
162+
uint32_t name_type_mask,
163+
std::vector<DWARFDIE> &dies) {
164+
DIEArray offsets;
165+
m_apple_names_up->FindByName(name.GetStringRef(), offsets);
166+
for (const DIERef &die_ref : offsets) {
167+
ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx,
168+
name_type_mask, dies);
169+
}
171170
}
172171

173-
void AppleDWARFIndex::GetFunctions(
174-
const RegularExpression &regex,
175-
llvm::function_ref<bool(DIERef ref)> callback) {
172+
void AppleDWARFIndex::GetFunctions(const RegularExpression &regex,
173+
DIEArray &offsets) {
176174
if (!m_apple_names_up)
177175
return;
178176

179177
DWARFMappedHash::DIEInfoArray hash_data;
180-
m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data);
181-
DWARFMappedHash::ExtractDIEArray(hash_data, callback);
178+
if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data))
179+
DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
182180
}
183181

184182
void AppleDWARFIndex::ReportInvalidDIERef(const DIERef &ref,

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,21 @@ class AppleDWARFIndex : public DWARFIndex {
3232

3333
void Preload() override {}
3434

35-
void
36-
GetGlobalVariables(ConstString basename,
37-
llvm::function_ref<bool(DIERef ref)> callback) override;
38-
void
39-
GetGlobalVariables(const RegularExpression &regex,
40-
llvm::function_ref<bool(DIERef ref)> callback) override;
41-
void
42-
GetGlobalVariables(const DWARFUnit &cu,
43-
llvm::function_ref<bool(DIERef ref)> callback) override;
44-
void GetObjCMethods(ConstString class_name,
45-
llvm::function_ref<bool(DIERef ref)> callback) override;
46-
void
47-
GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
48-
llvm::function_ref<bool(DIERef ref)> callback) override;
49-
void GetTypes(ConstString name,
50-
llvm::function_ref<bool(DIERef ref)> callback) override;
51-
void GetTypes(const DWARFDeclContext &context,
52-
llvm::function_ref<bool(DIERef ref)> callback) override;
53-
void GetNamespaces(ConstString name,
54-
llvm::function_ref<bool(DIERef ref)> callback) override;
35+
void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
36+
void GetGlobalVariables(const RegularExpression &regex,
37+
DIEArray &offsets) override;
38+
void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
39+
void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
40+
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
41+
DIEArray &offsets) override;
42+
void GetTypes(ConstString name, DIEArray &offsets) override;
43+
void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
44+
void GetNamespaces(ConstString name, DIEArray &offsets) override;
5545
void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
5646
const CompilerDeclContext &parent_decl_ctx,
5747
uint32_t name_type_mask,
58-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
59-
void GetFunctions(const RegularExpression &regex,
60-
llvm::function_ref<bool(DIERef ref)> callback) override;
48+
std::vector<DWARFDIE> &dies) override;
49+
void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
6150

6251
void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override;
6352
void Dump(Stream &s) override;

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,13 +2013,18 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
20132013
if (class_language == eLanguageTypeObjC) {
20142014
ConstString class_name(clang_type.GetTypeName());
20152015
if (class_name) {
2016-
dwarf->GetObjCMethods(class_name, [&](DIERef die_ref) {
2016+
DIEArray method_die_offsets;
2017+
dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
2018+
2019+
const size_t num_matches = method_die_offsets.size();
2020+
for (size_t i = 0; i < num_matches; ++i) {
2021+
const DIERef &die_ref = method_die_offsets[i];
20172022
DWARFDebugInfo &debug_info = dwarf->DebugInfo();
20182023
DWARFDIE method_die = debug_info.GetDIE(die_ref);
2024+
20192025
if (method_die)
20202026
method_die.ResolveType();
2021-
return true;
2022-
});
2027+
}
20232028

20242029
for (DelayedPropertyList::iterator pi = delayed_properties.begin(),
20252030
pe = delayed_properties.end();

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,42 @@ using namespace lldb;
1616

1717
DWARFIndex::~DWARFIndex() = default;
1818

19-
bool DWARFIndex::ProcessFunctionDIE(
20-
llvm::StringRef name, DIERef ref, SymbolFileDWARF &dwarf,
21-
const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
22-
llvm::function_ref<bool(DWARFDIE die)> callback) {
19+
void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
20+
SymbolFileDWARF &dwarf,
21+
const CompilerDeclContext &parent_decl_ctx,
22+
uint32_t name_type_mask,
23+
std::vector<DWARFDIE> &dies) {
2324
DWARFDIE die = dwarf.GetDIE(ref);
2425
if (!die) {
2526
ReportInvalidDIERef(ref, name);
26-
return true;
27+
return;
2728
}
2829

2930
// Exit early if we're searching exclusively for methods or selectors and
3031
// we have a context specified (no methods in namespaces).
3132
uint32_t looking_for_nonmethods =
3233
name_type_mask & ~(eFunctionNameTypeMethod | eFunctionNameTypeSelector);
3334
if (!looking_for_nonmethods && parent_decl_ctx.IsValid())
34-
return true;
35+
return;
3536

3637
// Otherwise, we need to also check that the context matches. If it does not
3738
// match, we do nothing.
3839
if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
39-
return true;
40+
return;
4041

4142
// In case of a full match, we just insert everything we find.
42-
if (name_type_mask & eFunctionNameTypeFull)
43-
return callback(die);
43+
if (name_type_mask & eFunctionNameTypeFull) {
44+
dies.push_back(die);
45+
return;
46+
}
4447

4548
// If looking for ObjC selectors, we need to also check if the name is a
4649
// possible selector.
4750
if (name_type_mask & eFunctionNameTypeSelector &&
48-
ObjCLanguage::IsPossibleObjCMethodName(die.GetName()))
49-
return callback(die);
51+
ObjCLanguage::IsPossibleObjCMethodName(die.GetName())) {
52+
dies.push_back(die);
53+
return;
54+
}
5055

5156
bool looking_for_methods = name_type_mask & lldb::eFunctionNameTypeMethod;
5257
bool looking_for_functions = name_type_mask & lldb::eFunctionNameTypeBase;
@@ -56,8 +61,6 @@ bool DWARFIndex::ProcessFunctionDIE(
5661
// searching for.
5762
if ((looking_for_methods && looking_for_functions) ||
5863
looking_for_methods == die.IsMethod())
59-
return callback(die);
64+
dies.push_back(die);
6065
}
61-
62-
return true;
6366
}

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

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,24 @@ class DWARFIndex {
2727
/// Finds global variables with the given base name. Any additional filtering
2828
/// (e.g., to only retrieve variables from a given context) should be done by
2929
/// the consumer.
30-
virtual void
31-
GetGlobalVariables(ConstString basename,
32-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
30+
virtual void GetGlobalVariables(ConstString basename, DIEArray &offsets) = 0;
3331

34-
virtual void
35-
GetGlobalVariables(const RegularExpression &regex,
36-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
37-
virtual void
38-
GetGlobalVariables(const DWARFUnit &cu,
39-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
40-
virtual void
41-
GetObjCMethods(ConstString class_name,
42-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
43-
virtual void
44-
GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
45-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
46-
virtual void GetTypes(ConstString name,
47-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
48-
virtual void GetTypes(const DWARFDeclContext &context,
49-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
50-
virtual void GetNamespaces(ConstString name,
51-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
52-
virtual void
53-
GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
54-
const CompilerDeclContext &parent_decl_ctx,
55-
uint32_t name_type_mask,
56-
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
32+
virtual void GetGlobalVariables(const RegularExpression &regex,
33+
DIEArray &offsets) = 0;
34+
virtual void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) = 0;
35+
virtual void GetObjCMethods(ConstString class_name, DIEArray &offsets) = 0;
36+
virtual void GetCompleteObjCClass(ConstString class_name,
37+
bool must_be_implementation,
38+
DIEArray &offsets) = 0;
39+
virtual void GetTypes(ConstString name, DIEArray &offsets) = 0;
40+
virtual void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) = 0;
41+
virtual void GetNamespaces(ConstString name, DIEArray &offsets) = 0;
42+
virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
43+
const CompilerDeclContext &parent_decl_ctx,
44+
uint32_t name_type_mask,
45+
std::vector<DWARFDIE> &dies) = 0;
5746
virtual void GetFunctions(const RegularExpression &regex,
58-
llvm::function_ref<bool(DIERef ref)> callback) = 0;
47+
DIEArray &offsets) = 0;
5948

6049
virtual void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) = 0;
6150
virtual void Dump(Stream &s) = 0;
@@ -67,11 +56,10 @@ class DWARFIndex {
6756
/// the function given by "ref" matches search criteria given by
6857
/// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
6958
/// vector.
70-
bool ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
59+
void ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
7160
SymbolFileDWARF &dwarf,
7261
const CompilerDeclContext &parent_decl_ctx,
73-
uint32_t name_type_mask,
74-
llvm::function_ref<bool(DWARFDIE die)> callback);
62+
uint32_t name_type_mask, std::vector<DWARFDIE> &dies);
7563
};
7664
} // namespace lldb_private
7765

0 commit comments

Comments
 (0)