21 llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
25 auto index_up = std::make_unique<DebugNames>(debug_names.
GetAsLLVM(),
31 module, std::move(index_up), debug_names, debug_str,
dwarf));
34 llvm::DenseSet<dw_offset_t>
36 llvm::DenseSet<dw_offset_t> result;
37 for (
const DebugNames::NameIndex &ni : debug_names) {
38 for (
uint32_t cu = 0; cu < ni.getCUCount(); ++cu)
39 result.insert(ni.getCUOffset(cu));
44 llvm::Optional<DIERef>
46 llvm::Optional<uint64_t> cu_offset = entry.getCUOffset();
50 DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset);
55 if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset())
57 DIERef::Section::DebugInfo, cu->
GetOffset() + *die_offset);
64 llvm::function_ref<
bool(
DWARFDIE die)> callback, llvm::StringRef name) {
65 llvm::Optional<DIERef> ref = ToDIERef(entry);
69 m_module.GetSymbolFile()->GetBackingSymbolFile());
77 const DebugNames::NameIndex &ni,
78 llvm::StringRef name) {
82 handleErrors(std::move(
error), [](
const DebugNames::SentinelError &) {}),
83 "Failed to parse index entries for index at {1:x}, name {2}: {0}",
84 ni.getUnitOffset(), name);
90 m_debug_names_up->equal_range(basename.
GetStringRef())) {
91 if (entry.tag() != DW_TAG_variable)
94 if (!ProcessEntry(entry, callback, basename.
GetStringRef()))
98 m_fallback.GetGlobalVariables(basename, callback);
103 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
104 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
105 for (DebugNames::NameTableEntry nte: ni) {
106 if (!regex.
Execute(nte.getString()))
109 uint64_t entry_offset = nte.getEntryOffset();
110 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
111 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
112 if (entry_or->tag() != DW_TAG_variable)
115 if (!ProcessEntry(*entry_or, callback,
116 llvm::StringRef(nte.getString())))
119 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
123 m_fallback.GetGlobalVariables(regex, callback);
130 bool found_entry_for_cu =
false;
131 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
132 for (DebugNames::NameTableEntry nte: ni) {
133 uint64_t entry_offset = nte.getEntryOffset();
134 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
135 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
136 if (entry_or->tag() != DW_TAG_variable)
138 if (entry_or->getCUOffset() != cu_offset)
141 found_entry_for_cu =
true;
142 if (!ProcessEntry(*entry_or, callback,
143 llvm::StringRef(nte.getString())))
146 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
151 if (!found_entry_for_cu)
152 m_fallback.GetGlobalVariables(cu, callback);
156 ConstString class_name,
bool must_be_implementation,
157 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
163 m_debug_names_up->equal_range(class_name.
GetStringRef())) {
164 if (entry.tag() != DW_TAG_structure_type &&
165 entry.tag() != DW_TAG_class_type)
168 llvm::Optional<DIERef> ref = ToDIERef(entry);
172 DWARFUnit *cu = m_debug_info.GetUnit(*ref);
174 incomplete_types.push_back(*ref);
189 incomplete_types.push_back(*ref);
192 auto dierefcallback = DIERefCallback(callback, class_name.
GetStringRef());
193 for (
DIERef ref : incomplete_types)
194 if (!dierefcallback(ref))
197 m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, callback);
204 if (isType(entry.tag())) {
205 if (!ProcessEntry(entry, callback, name.
GetStringRef()))
210 m_fallback.GetTypes(name, callback);
215 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
216 auto name = context[0].name;
218 if (entry.tag() == context[0].tag) {
219 if (!ProcessEntry(entry, callback, name))
224 m_fallback.GetTypes(context, callback);
231 if (entry.tag() == DW_TAG_namespace) {
232 if (!ProcessEntry(entry, callback, name.
GetStringRef()))
237 m_fallback.GetNamespaces(name, callback);
243 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
245 std::set<DWARFDebugInfoEntry *> seen;
248 Tag tag = entry.tag();
249 if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
252 if (llvm::Optional<DIERef> ref = ToDIERef(entry)) {
253 if (!ProcessFunctionDIE(lookup_info, *ref,
dwarf, parent_decl_ctx,
255 if (!seen.insert(die.
GetDIE()).second)
257 return callback(die);
263 m_fallback.GetFunctions(lookup_info,
dwarf, parent_decl_ctx, callback);
268 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
269 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
270 for (DebugNames::NameTableEntry nte: ni) {
271 if (!regex.
Execute(nte.getString()))
274 uint64_t entry_offset = nte.getEntryOffset();
275 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
276 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
277 Tag tag = entry_or->tag();
278 if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
281 if (!ProcessEntry(*entry_or, callback,
282 llvm::StringRef(nte.getString())))
285 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
289 m_fallback.GetFunctions(regex, callback);
296 llvm::raw_string_ostream os(data);
297 m_debug_names_up->dump(os);