diff options
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp')
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp | 135 |
1 files changed, 75 insertions, 60 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index 0a5073b8cd9e..33ab11a3ca40 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -1,4 +1,4 @@ -//===-- AppleDWARFIndex.cpp ------------------------------------*- C++ -*-===// +//===-- AppleDWARFIndex.cpp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -52,54 +52,70 @@ std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create( return nullptr; } -void AppleDWARFIndex::GetGlobalVariables(ConstString basename, DIEArray &offsets) { - if (m_apple_names_up) - m_apple_names_up->FindByName(basename.GetStringRef(), offsets); +void AppleDWARFIndex::GetGlobalVariables( + ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) { + if (!m_apple_names_up) + return; + m_apple_names_up->FindByName( + basename.GetStringRef(), + DIERefCallback(callback, basename.GetStringRef())); } -void AppleDWARFIndex::GetGlobalVariables(const RegularExpression ®ex, - DIEArray &offsets) { +void AppleDWARFIndex::GetGlobalVariables( + const RegularExpression ®ex, + llvm::function_ref<bool(DWARFDIE die)> callback) { if (!m_apple_names_up) return; DWARFMappedHash::DIEInfoArray hash_data; - if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data)) - DWARFMappedHash::ExtractDIEArray(hash_data, offsets); + m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data); + // This is not really the DIE name. + DWARFMappedHash::ExtractDIEArray(hash_data, + DIERefCallback(callback, regex.GetText())); } -void AppleDWARFIndex::GetGlobalVariables(const DWARFUnit &cu, - DIEArray &offsets) { +void AppleDWARFIndex::GetGlobalVariables( + const DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) { if (!m_apple_names_up) return; DWARFMappedHash::DIEInfoArray hash_data; - if (m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(), - cu.GetNextUnitOffset(), hash_data)) - DWARFMappedHash::ExtractDIEArray(hash_data, offsets); + m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(), cu.GetNextUnitOffset(), + hash_data); + DWARFMappedHash::ExtractDIEArray(hash_data, DIERefCallback(callback)); } -void AppleDWARFIndex::GetObjCMethods(ConstString class_name, - DIEArray &offsets) { - if (m_apple_objc_up) - m_apple_objc_up->FindByName(class_name.GetStringRef(), offsets); +void AppleDWARFIndex::GetObjCMethods( + ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) { + if (!m_apple_objc_up) + return; + m_apple_objc_up->FindByName( + class_name.GetStringRef(), + DIERefCallback(callback, class_name.GetStringRef())); } -void AppleDWARFIndex::GetCompleteObjCClass(ConstString class_name, - bool must_be_implementation, - DIEArray &offsets) { - if (m_apple_types_up) { - m_apple_types_up->FindCompleteObjCClassByName( - class_name.GetStringRef(), offsets, must_be_implementation); - } +void AppleDWARFIndex::GetCompleteObjCClass( + ConstString class_name, bool must_be_implementation, + llvm::function_ref<bool(DWARFDIE die)> callback) { + if (!m_apple_types_up) + return; + m_apple_types_up->FindCompleteObjCClassByName( + class_name.GetStringRef(), + DIERefCallback(callback, class_name.GetStringRef()), + must_be_implementation); } -void AppleDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) { - if (m_apple_types_up) - m_apple_types_up->FindByName(name.GetStringRef(), offsets); +void AppleDWARFIndex::GetTypes( + ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) { + if (!m_apple_types_up) + return; + m_apple_types_up->FindByName(name.GetStringRef(), + DIERefCallback(callback, name.GetStringRef())); } -void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context, - DIEArray &offsets) { +void AppleDWARFIndex::GetTypes( + const DWARFDeclContext &context, + llvm::function_ref<bool(DWARFDIE die)> callback) { if (!m_apple_types_up) return; @@ -119,7 +135,8 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context, if (log) m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()"); m_apple_types_up->FindByNameAndTagAndQualifiedNameHash( - type_name.GetStringRef(), tag, qualified_name_hash, offsets); + type_name.GetStringRef(), tag, qualified_name_hash, + DIERefCallback(callback, type_name.GetStringRef())); return; } @@ -133,54 +150,52 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context, if (!has_qualified_name_hash && (context.GetSize() > 1) && (context[1].tag == DW_TAG_class_type || context[1].tag == DW_TAG_structure_type)) { - DIEArray class_matches; - m_apple_types_up->FindByName(context[1].name, class_matches); - if (class_matches.empty()) + if (m_apple_types_up->FindByName(context[1].name, + [&](DIERef ref) { return false; })) return; } if (log) m_module.LogMessage(log, "FindByNameAndTag()"); - m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets); + m_apple_types_up->FindByNameAndTag( + type_name.GetStringRef(), tag, + DIERefCallback(callback, type_name.GetStringRef())); return; } - m_apple_types_up->FindByName(type_name.GetStringRef(), offsets); + m_apple_types_up->FindByName( + type_name.GetStringRef(), + DIERefCallback(callback, type_name.GetStringRef())); } -void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) { - if (m_apple_namespaces_up) - m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets); +void AppleDWARFIndex::GetNamespaces( + ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) { + if (!m_apple_namespaces_up) + return; + m_apple_namespaces_up->FindByName( + name.GetStringRef(), DIERefCallback(callback, name.GetStringRef())); } -void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, - uint32_t name_type_mask, - std::vector<DWARFDIE> &dies) { - DIEArray offsets; - m_apple_names_up->FindByName(name.GetStringRef(), offsets); - for (const DIERef &die_ref : offsets) { - ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx, - name_type_mask, dies); - } +void AppleDWARFIndex::GetFunctions( + ConstString name, SymbolFileDWARF &dwarf, + const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, + llvm::function_ref<bool(DWARFDIE die)> callback) { + m_apple_names_up->FindByName(name.GetStringRef(), [&](DIERef die_ref) { + return ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, + parent_decl_ctx, name_type_mask, callback); + }); } -void AppleDWARFIndex::GetFunctions(const RegularExpression ®ex, - DIEArray &offsets) { +void AppleDWARFIndex::GetFunctions( + const RegularExpression ®ex, + llvm::function_ref<bool(DWARFDIE die)> callback) { if (!m_apple_names_up) return; DWARFMappedHash::DIEInfoArray hash_data; - if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data)) - DWARFMappedHash::ExtractDIEArray(hash_data, offsets); -} - -void AppleDWARFIndex::ReportInvalidDIERef(const DIERef &ref, - llvm::StringRef name) { - m_module.ReportErrorIfModifyDetected( - "the DWARF debug information has been modified (accelerator table had " - "bad die 0x%8.8x for '%s')\n", - ref.die_offset(), name.str().c_str()); + m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data); + DWARFMappedHash::ExtractDIEArray(hash_data, + DIERefCallback(callback, regex.GetText())); } void AppleDWARFIndex::Dump(Stream &s) { |