16#include "llvm/Support/DJB.h"
28 llvm::DataExtractor llvm_debug_str = debug_str.
GetAsLLVM();
30 auto apple_names_table_up = std::make_unique<llvm::AppleAcceleratorTable>(
33 auto apple_namespaces_table_up =
34 std::make_unique<llvm::AppleAcceleratorTable>(
37 auto apple_types_table_up = std::make_unique<llvm::AppleAcceleratorTable>(
40 auto apple_objc_table_up = std::make_unique<llvm::AppleAcceleratorTable>(
43 auto extract_and_check = [](
auto &TablePtr) {
44 if (
auto E = TablePtr->extract()) {
45 llvm::consumeError(std::move(E));
50 extract_and_check(apple_names_table_up);
51 extract_and_check(apple_namespaces_table_up);
52 extract_and_check(apple_types_table_up);
53 extract_and_check(apple_objc_table_up);
60 if (apple_names_table_up || apple_namespaces_table_up ||
61 apple_types_table_up || apple_objc_table_up)
62 return std::make_unique<AppleDWARFIndex>(
63 module, std::move(apple_names_table_up),
64 std::move(apple_namespaces_table_up), std::move(apple_types_table_up),
74 return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
81 uint32_t expected_hash) {
82 std::optional<llvm::DWARFFormValue> form_value =
83 entry.lookup(dwarf::DW_ATOM_qual_name_hash);
86 std::optional<uint64_t> hash = form_value->getAsUnsignedConstant();
87 return hash && (*hash == expected_hash);
95 std::optional<llvm::DWARFFormValue> form_value =
96 entry.lookup(dwarf::DW_ATOM_die_tag);
99 std::optional<uint64_t> maybe_tag = form_value->getAsUnsignedConstant();
102 auto tag =
static_cast<dw_tag_t>(*maybe_tag);
103 return tag == expected_tag ||
111 std::optional<llvm::DWARFFormValue> form_value =
112 entry.lookup(dwarf::DW_ATOM_type_flags);
115 std::optional<uint64_t>
Flags = form_value->getAsUnsignedConstant();
117 (*
Flags & llvm::dwarf::AcceleratorTable::DW_FLAG_type_implementation);
121 llvm::StringRef name,
122 llvm::function_ref<
bool(
DWARFDIE die)> callback,
123 std::optional<dw_tag_t> search_for_tag,
124 std::optional<uint32_t> search_for_qualhash) {
126 for (
const auto &entry : table.equal_range(name)) {
127 if (search_for_qualhash &&
132 if (!converted_cb(entry))
146 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
153 if (std::optional<llvm::StringRef> name = entry.readName();
155 if (!converted_cb(entry.BaseEntry))
167 auto is_in_range = [lower_bound, upper_bound](std::optional<uint32_t> val) {
168 return val.has_value() && *val >= lower_bound && *val < upper_bound;
173 if (is_in_range(entry.BaseEntry.getDIESectionOffset()))
174 if (!converted_cb(entry.BaseEntry))
187 ConstString class_name,
bool must_be_implementation,
188 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
192 llvm::SmallVector<DIERef> decl_dies;
202 *entry.getDIESectionOffset());
205 if (must_be_implementation)
207 for (
DIERef ref : decl_dies)
208 if (!converted_cb(ref))
221 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
226 const bool entries_have_tag =
228 const bool entries_have_qual_hash =
231 llvm::StringRef expected_name = context[0].name;
233 if (entries_have_tag && entries_have_qual_hash) {
234 const dw_tag_t expected_tag = context[0].tag;
235 const uint32_t expected_qualname_hash =
240 expected_qualname_hash);
245 if (!entries_have_tag) {
264 const dw_tag_t expected_tag = context[0].tag;
279 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
286 *entry.getDIESectionOffset());
299 llvm::function_ref<
bool(
DWARFDIE die)> callback) {
307 s.
PutCString(
".apple_namespaces index present\n");
static bool HasImplementationFlag(const llvm::AppleAcceleratorTable::Entry &entry)
Returns true if entry has an extractable DW_ATOM_type_flags and the flag "DW_FLAG_type_implementation...
static bool IsClassOrStruct(dw_tag_t tag)
Returns true if tag is a class_type of structure_type tag.
static bool EntryHasMatchingQualhash(const llvm::AppleAcceleratorTable::Entry &entry, uint32_t expected_hash)
Returns true if entry has an extractable DW_ATOM_qual_name_hash and it matches expected_hash.
static bool EntryHasMatchingTag(const llvm::AppleAcceleratorTable::Entry &entry, dw_tag_t expected_tag)
Returns true if entry has an extractable DW_ATOM_die_tag and it matches expected_tag.
Represents a generic declaration context in a program.
A uniqued constant string class.
A class that handles mangled names.
bool NameMatches(ConstString name) const
Check if "name" matches either the mangled or demangled 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.
void LogMessage(Log *log, const char *format, Args &&...args)
llvm::StringRef GetText() const
Access the regular expression text.
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback) override
Finds global variables with the given base name.
std::unique_ptr< llvm::AppleAcceleratorTable > m_apple_types_up
void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetObjCMethods(ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback) override
static std::unique_ptr< AppleDWARFIndex > Create(Module &module, DWARFDataExtractor apple_names, DWARFDataExtractor apple_namespaces, DWARFDataExtractor apple_types, DWARFDataExtractor apple_objc, DWARFDataExtractor debug_str)
void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
std::unique_ptr< llvm::AppleAcceleratorTable > m_apple_names_up
void SearchFor(const llvm::AppleAcceleratorTable &table, llvm::StringRef name, llvm::function_ref< bool(DWARFDIE die)> callback, std::optional< dw_tag_t > search_for_tag=std::nullopt, std::optional< uint32_t > search_for_qualhash=std::nullopt)
}
std::unique_ptr< llvm::AppleAcceleratorTable > m_apple_namespaces_up
void Dump(Stream &s) override
std::unique_ptr< llvm::AppleAcceleratorTable > m_apple_objc_up
void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback) override
Identifies a DWARF debug info entry within a given Module.
const char * GetQualifiedName() const
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DWARFDIE die, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
DIERefCallbackImpl DIERefCallback(llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
dw_offset_t GetOffset() const
dw_offset_t GetNextUnitOffset() const
DWARFUnit & GetNonSkeletonUnit()
llvm::dwarf::Tag dw_tag_t
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.