22llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
26 auto index_up = std::make_unique<DebugNames>(debug_names.
GetAsLLVMDWARF(),
28 if (llvm::Error E = index_up->extract())
32 module, std::move(index_up), debug_names, debug_str,
dwarf));
35llvm::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();
56 if (std::optional<uint64_t> die_offset = entry.getDIEUnitOffset())
64 const DebugNames::Entry &entry,
65 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
66 std::optional<DIERef> ref =
ToDIERef(entry);
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);
90 for (
const DebugNames::Entry &entry :
92 if (entry.tag() != DW_TAG_variable)
104 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
106 for (DebugNames::NameTableEntry nte: ni) {
107 Mangled mangled_name(nte.getString());
111 uint64_t entry_offset = nte.getEntryOffset();
112 llvm::Expected<DebugNames::Entry> entry_or = ni.getEntry(&entry_offset);
113 for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
114 if (entry_or->tag() != DW_TAG_variable)
130 bool found_entry_for_cu =
false;
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;
150 if (!found_entry_for_cu)
155 ConstString class_name,
bool must_be_implementation,
156 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
161 for (
const DebugNames::Entry &entry :
163 if (entry.tag() != DW_TAG_structure_type &&
164 entry.tag() != DW_TAG_class_type)
167 std::optional<DIERef> ref =
ToDIERef(entry);
173 incomplete_types.push_back(*ref);
188 incomplete_types.push_back(*ref);
192 for (
DIERef ref : incomplete_types)
193 if (!dierefcallback(ref))
201 for (
const DebugNames::Entry &entry :
203 if (isType(entry.tag())) {
214 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
215 auto name = context[0].name;
216 for (
const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name)) {
217 if (entry.tag() == context[0].tag) {
228 for (
const DebugNames::Entry &entry :
230 dwarf::Tag entry_tag = entry.tag();
231 if (entry_tag == DW_TAG_namespace ||
232 entry_tag == DW_TAG_imported_declaration) {
244 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
246 std::set<DWARFDebugInfoEntry *> seen;
247 for (
const DebugNames::Entry &entry :
249 Tag tag = entry.tag();
250 if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
253 if (std::optional<DIERef> ref =
ToDIERef(entry)) {
256 if (!seen.insert(die.
GetDIE()).second)
258 return callback(die);
269 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
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)
296 llvm::raw_string_ostream os(data);
static llvm::raw_ostream & error(Stream &strm)
std::vector< DIERef > DIEArray
#define LLDB_LOG_ERROR(log, error,...)
Identifies a DWARF debug info entry within a given Module.
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
DWARFDIE GetDIE(dw_offset_t die_offset) const
DWARFUnit * GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset, uint32_t *idx_ptr=nullptr)
DWARFDIE GetDIE(const DIERef &die_ref)
DWARFUnit * GetUnit(const DIERef &die_ref)
SymbolFileDWARF & GetSymbolFileDWARF() const
bool Supports_DW_AT_APPLE_objc_complete_type()
DWARFUnit & GetNonSkeletonUnit()
dw_offset_t GetOffset() const
std::optional< uint64_t > GetFileIndex() const
Represents a generic declaration context in a program.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
DIERefCallbackImpl DIERefCallback(llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
static llvm::Expected< std::unique_ptr< DebugNamesDWARFIndex > > Create(Module &module, DWARFDataExtractor debug_names, DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf)
static void MaybeLogLookupError(llvm::Error error, const DebugNames::NameIndex &ni, llvm::StringRef name)
llvm::DWARFDebugNames DebugNames
std::optional< DIERef > ToDIERef(const DebugNames::Entry &entry)
void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
ManualDWARFIndex m_fallback
void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void Dump(Stream &s) override
DWARFDebugInfo & m_debug_info
bool ProcessEntry(const DebugNames::Entry &entry, llvm::function_ref< bool(DWARFDIE die)> callback)
void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback) override
Finds global variables with the given base name.
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback) override
static llvm::DenseSet< dw_offset_t > GetUnits(const DebugNames &debug_names)
std::unique_ptr< DebugNames > m_debug_names_up
A class that handles mangled names.
bool NameMatches(ConstString name) const
Check if "name" matches either the mangled or demangled name.
void Dump(Stream &s) override
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback) override
Finds global variables with the given base name.
A class that encapsulates name lookup information.
ConstString GetLookupName() const
A class that describes an executable image and its associated object and symbol files.
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
virtual SymbolFile * GetBackingSymbolFile()
SymbolFileOnDemand class overrides this to return the underlying backing SymbolFile implementation th...
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.