Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
39645 views
//===-- DWARFIndex.h -------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H1011#include "Plugins/SymbolFile/DWARF/DIERef.h"12#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"13#include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"14#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"1516#include "lldb/Core/Module.h"17#include "lldb/Target/Statistics.h"1819namespace lldb_private::plugin {20namespace dwarf {21class DWARFDeclContext;22class DWARFDIE;2324class DWARFIndex {25public:26DWARFIndex(Module &module) : m_module(module) {}27virtual ~DWARFIndex();2829virtual void Preload() = 0;3031/// Finds global variables with the given base name. Any additional filtering32/// (e.g., to only retrieve variables from a given context) should be done by33/// the consumer.34virtual void35GetGlobalVariables(ConstString basename,36llvm::function_ref<bool(DWARFDIE die)> callback) = 0;3738virtual void39GetGlobalVariables(const RegularExpression ®ex,40llvm::function_ref<bool(DWARFDIE die)> callback) = 0;41/// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().42virtual void43GetGlobalVariables(DWARFUnit &cu,44llvm::function_ref<bool(DWARFDIE die)> callback) = 0;45virtual void46GetObjCMethods(ConstString class_name,47llvm::function_ref<bool(DWARFDIE die)> callback) = 0;48virtual void49GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,50llvm::function_ref<bool(DWARFDIE die)> callback) = 0;51virtual void GetTypes(ConstString name,52llvm::function_ref<bool(DWARFDIE die)> callback) = 0;53virtual void GetTypes(const DWARFDeclContext &context,54llvm::function_ref<bool(DWARFDIE die)> callback) = 0;5556/// Finds all DIEs whose fully qualified name matches `context`. A base57/// implementation is provided, and it uses the entire CU to check the DIE58/// parent hierarchy. Specializations should override this if they are able59/// to provide a faster implementation.60virtual void61GetFullyQualifiedType(const DWARFDeclContext &context,62llvm::function_ref<bool(DWARFDIE die)> callback);63virtual void64GetNamespaces(ConstString name,65llvm::function_ref<bool(DWARFDIE die)> callback) = 0;66virtual void67GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,68const CompilerDeclContext &parent_decl_ctx,69llvm::function_ref<bool(DWARFDIE die)> callback) = 0;70virtual void71GetFunctions(const RegularExpression ®ex,72llvm::function_ref<bool(DWARFDIE die)> callback) = 0;7374virtual void Dump(Stream &s) = 0;7576StatsDuration::Duration GetIndexTime() { return m_index_time; }7778protected:79Module &m_module;80StatsDuration m_index_time;8182/// Helper function implementing common logic for processing function dies. If83/// the function given by "die" matches search criteria given by84/// "parent_decl_ctx" and "name_type_mask", it calls the callback with the85/// given die.86bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DWARFDIE die,87const CompilerDeclContext &parent_decl_ctx,88llvm::function_ref<bool(DWARFDIE die)> callback);8990class DIERefCallbackImpl {91public:92DIERefCallbackImpl(const DWARFIndex &index,93llvm::function_ref<bool(DWARFDIE die)> callback,94llvm::StringRef name);95bool operator()(DIERef ref) const;96bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;9798private:99const DWARFIndex &m_index;100SymbolFileDWARF &m_dwarf;101const llvm::function_ref<bool(DWARFDIE die)> m_callback;102const llvm::StringRef m_name;103};104DIERefCallbackImpl105DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,106llvm::StringRef name = {}) const {107return DIERefCallbackImpl(*this, callback, name);108}109110void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;111112/// Implementation of `GetFullyQualifiedType` to check a single entry,113/// shareable with derived classes.114bool115GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,116llvm::function_ref<bool(DWARFDIE die)> callback);117};118} // namespace dwarf119} // namespace lldb_private::plugin120121#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H122123124