22 llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
26 auto index_up = std::make_unique<DebugNames>(debug_names.
GetAsLLVM(),
32 module, std::move(index_up), debug_names, debug_str,
dwarf));
35 llvm::DenseSet<dw_offset_t>
37 llvm::DenseSet<dw_offset_t> result;
38 for (
const DebugNames::NameIndex &ni : debug_names) {
39 for (
uint32_t cu = 0; cu < ni.getCUCount(); ++cu)
40 result.insert(ni.getCUOffset(cu));
47 std::optional<uint64_t> cu_offset = entry.getCUOffset();
51 DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset);
56 if (std::optional<uint64_t> die_offset = entry.getDIEUnitOffset())
58 DIERef::Section::DebugInfo, cu->
GetOffset() + *die_offset);
65 llvm::function_ref<
bool(
DWARFDIE die)> callback, llvm::StringRef name) {
66 std::optional<DIERef> ref = ToDIERef(entry);
70 m_module.GetSymbolFile()->GetBackingSymbolFile());
78 const DebugNames::NameIndex &ni,
79 llvm::StringRef name) {
83 handleErrors(std::move(
error), [](
const DebugNames::SentinelError &) {}),
84 "Failed to parse index entries for index at {1:x}, name {2}: {0}",
85 ni.getUnitOffset(), name);
91 m_debug_names_up->equal_range(basename.
GetStringRef())) {
92 if (entry.tag() != DW_TAG_variable)
95 if (!ProcessEntry(entry, callback, basename.
GetStringRef()))
99 m_fallback.GetGlobalVariables(basename, callback);
104 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
105 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
106 for (DebugNames::NameTableEntry nte: ni) {
107 if (!regex.
Execute(nte.getString()))
110 uint64_t entry_offset = nte.getEntryOffset();
111 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
112 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
113 if (entry_or->tag() != DW_TAG_variable)
116 if (!ProcessEntry(*entry_or, callback,
117 llvm::StringRef(nte.getString())))
120 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
124 m_fallback.GetGlobalVariables(regex, callback);
131 bool found_entry_for_cu =
false;
132 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
133 for (DebugNames::NameTableEntry nte: ni) {
134 uint64_t entry_offset = nte.getEntryOffset();
135 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
136 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
137 if (entry_or->tag() != DW_TAG_variable)
139 if (entry_or->getCUOffset() != cu_offset)
142 found_entry_for_cu =
true;
143 if (!ProcessEntry(*entry_or, callback,
144 llvm::StringRef(nte.getString())))
147 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
152 if (!found_entry_for_cu)
153 m_fallback.GetGlobalVariables(cu, callback);
157 ConstString class_name,
bool must_be_implementation,
158 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
164 m_debug_names_up->equal_range(class_name.
GetStringRef())) {
165 if (entry.tag() != DW_TAG_structure_type &&
166 entry.tag() != DW_TAG_class_type)
169 std::optional<DIERef> ref = ToDIERef(entry);
173 DWARFUnit *cu = m_debug_info.GetUnit(*ref);
175 incomplete_types.push_back(*ref);
190 incomplete_types.push_back(*ref);
193 auto dierefcallback = DIERefCallback(callback, class_name.
GetStringRef());
194 for (
DIERef ref : incomplete_types)
195 if (!dierefcallback(ref))
198 m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, callback);
205 if (isType(entry.tag())) {
206 if (!ProcessEntry(entry, callback, name.
GetStringRef()))
211 m_fallback.GetTypes(name, callback);
216 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
217 auto name = context[0].name;
219 if (entry.tag() == context[0].tag) {
220 if (!ProcessEntry(entry, callback, name))
225 m_fallback.GetTypes(context, callback);
232 if (entry.tag() == DW_TAG_namespace) {
233 if (!ProcessEntry(entry, callback, name.
GetStringRef()))
238 m_fallback.GetNamespaces(name, callback);
244 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
246 std::set<DWARFDebugInfoEntry *> seen;
249 Tag tag = entry.tag();
250 if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
253 if (std::optional<DIERef> ref = ToDIERef(entry)) {
254 if (!ProcessFunctionDIE(lookup_info, *ref,
dwarf, parent_decl_ctx,
256 if (!seen.insert(die.
GetDIE()).second)
258 return callback(die);
264 m_fallback.GetFunctions(lookup_info,
dwarf, parent_decl_ctx, callback);
269 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
270 for (
const DebugNames::NameIndex &ni: *m_debug_names_up) {
271 for (DebugNames::NameTableEntry nte: ni) {
272 if (!regex.
Execute(nte.getString()))
275 uint64_t entry_offset = nte.getEntryOffset();
276 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
277 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
278 Tag tag = entry_or->tag();
279 if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
282 if (!ProcessEntry(*entry_or, callback,
283 llvm::StringRef(nte.getString())))
286 MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
290 m_fallback.GetFunctions(regex, callback);
297 llvm::raw_string_ostream os(data);
298 m_debug_names_up->dump(os);