brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · be73255 Raw
153 lines · c
1//===-- DWARFIndex.h -------------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H11 12#include "Plugins/SymbolFile/DWARF/DIERef.h"13#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"14#include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"15#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"16 17#include "lldb/Core/Module.h"18#include "lldb/Target/Statistics.h"19#include "lldb/lldb-private-enumerations.h"20 21namespace lldb_private::plugin {22namespace dwarf {23class DWARFDeclContext;24class DWARFDIE;25 26class DWARFIndex {27public:28  DWARFIndex(Module &module) : m_module(module) {}29  virtual ~DWARFIndex();30 31  virtual void Preload() = 0;32 33  /// Finds global variables with the given base name. Any additional filtering34  /// (e.g., to only retrieve variables from a given context) should be done by35  /// the consumer.36  virtual void GetGlobalVariables(37      ConstString basename,38      llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;39 40  virtual void GetGlobalVariables(41      const RegularExpression &regex,42      llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;43  /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().44  virtual void GetGlobalVariables(45      DWARFUnit &cu,46      llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;47  virtual void GetObjCMethods(48      ConstString class_name,49      llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;50  virtual void GetCompleteObjCClass(51      ConstString class_name, bool must_be_implementation,52      llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;53  virtual void54  GetTypes(ConstString name,55           llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;56  virtual void57  GetTypes(const DWARFDeclContext &context,58           llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;59 60  /// Finds all DIEs whose fully qualified name matches `context`. A base61  /// implementation is provided, and it uses the entire CU to check the DIE62  /// parent hierarchy. Specializations should override this if they are able63  /// to provide a faster implementation.64  virtual void GetFullyQualifiedType(65      const DWARFDeclContext &context,66      llvm::function_ref<IterationAction(DWARFDIE die)> callback);67  virtual void68  GetNamespaces(ConstString name,69                llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;70  /// Get type DIEs meeting requires of \a query.71  /// in its decl parent chain as subset.  A base implementation is provided,72  /// Specializations should override this if they are able to provide a faster73  /// implementation.74  virtual void75  GetTypesWithQuery(TypeQuery &query,76                    llvm::function_ref<IterationAction(DWARFDIE die)> callback);77  /// Get namespace DIEs whose base name match \param name with \param78  /// parent_decl_ctx in its decl parent chain.  A base implementation79  /// is provided. Specializations should override this if they are able to80  /// provide a faster implementation.81  virtual void GetNamespacesWithParents(82      ConstString name, const CompilerDeclContext &parent_decl_ctx,83      llvm::function_ref<IterationAction(DWARFDIE die)> callback);84  virtual void85  GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,86               const CompilerDeclContext &parent_decl_ctx,87               llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;88  virtual void89  GetFunctions(const RegularExpression &regex,90               llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;91 92  virtual void Dump(Stream &s) = 0;93 94  StatsDuration::Duration GetIndexTime() { return m_index_time; }95 96  void ResetStatistics() { m_index_time.reset(); }97 98protected:99  Module &m_module;100  StatsDuration m_index_time;101 102  /// Helper function implementing common logic for processing function dies. If103  /// the function given by "die" matches search criteria given by104  /// "parent_decl_ctx" and "name_type_mask", it calls the callback with the105  /// given die.106  IterationAction ProcessFunctionDIE(107      const Module::LookupInfo &lookup_info, DWARFDIE die,108      const CompilerDeclContext &parent_decl_ctx,109      llvm::function_ref<IterationAction(DWARFDIE die)> callback);110 111  class DIERefCallbackImpl {112  public:113    DIERefCallbackImpl(114        const DWARFIndex &index,115        llvm::function_ref<IterationAction(DWARFDIE die)> callback,116        llvm::StringRef name);117    IterationAction operator()(DIERef ref) const;118    IterationAction119    operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;120 121  private:122    const DWARFIndex &m_index;123    SymbolFileDWARF &m_dwarf;124    const llvm::function_ref<IterationAction(DWARFDIE die)> m_callback;125    const llvm::StringRef m_name;126  };127  DIERefCallbackImpl128  DIERefCallback(llvm::function_ref<IterationAction(DWARFDIE die)> callback,129                 llvm::StringRef name = {}) const {130    return DIERefCallbackImpl(*this, callback, name);131  }132 133  void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;134 135  /// Implementation of `GetFullyQualifiedType` to check a single entry,136  /// shareable with derived classes.137  IterationAction GetFullyQualifiedTypeImpl(138      const DWARFDeclContext &context, DWARFDIE die,139      llvm::function_ref<IterationAction(DWARFDIE die)> callback);140 141  /// Check if the type \a die can meet the requirements of \a query.142  IterationAction ProcessTypeDIEMatchQuery(143      TypeQuery &query, DWARFDIE die,144      llvm::function_ref<IterationAction(DWARFDIE die)> callback);145  IterationAction ProcessNamespaceDieMatchParents(146      const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,147      llvm::function_ref<IterationAction(DWARFDIE die)> callback);148};149} // namespace dwarf150} // namespace lldb_private::plugin151 152#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H153