LLDB  mainline
DWARFIndex.h
Go to the documentation of this file.
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
11 
15 
16 #include "lldb/Target/Statistics.h"
17 
18 class DWARFDeclContext;
19 class DWARFDIE;
20 
21 namespace lldb_private {
22 class DWARFIndex {
23 public:
24  DWARFIndex(Module &module) : m_module(module) {}
25  virtual ~DWARFIndex();
26 
27  virtual void Preload() = 0;
28 
29  /// Finds global variables with the given base name. Any additional filtering
30  /// (e.g., to only retrieve variables from a given context) should be done by
31  /// the consumer.
32  virtual void
34  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
35 
36  virtual void
38  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
39  /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
40  virtual void
42  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
43  virtual void
44  GetObjCMethods(ConstString class_name,
45  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
46  virtual void
47  GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
48  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
49  virtual void GetTypes(ConstString name,
50  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
51  virtual void GetTypes(const DWARFDeclContext &context,
52  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
53  virtual void
55  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
56  virtual void
58  const CompilerDeclContext &parent_decl_ctx,
59  uint32_t name_type_mask,
60  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
61  virtual void
62  GetFunctions(const RegularExpression &regex,
63  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
64 
65  virtual void Dump(Stream &s) = 0;
66 
68 
69 protected:
72 
73  /// Helper function implementing common logic for processing function dies. If
74  /// the function given by "ref" matches search criteria given by
75  /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
76  /// vector.
77  bool ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
79  const CompilerDeclContext &parent_decl_ctx,
80  uint32_t name_type_mask,
81  llvm::function_ref<bool(DWARFDIE die)> callback);
82 
84  public:
85  DIERefCallbackImpl(const DWARFIndex &index,
86  llvm::function_ref<bool(DWARFDIE die)> callback,
87  llvm::StringRef name);
88  bool operator()(DIERef ref) const;
89 
90  private:
93  const llvm::function_ref<bool(DWARFDIE die)> m_callback;
94  const llvm::StringRef m_name;
95  };
97  DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
98  llvm::StringRef name = {}) const {
99  return DIERefCallbackImpl(*this, callback, name);
100  }
101 
102  void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
103 };
104 } // namespace lldb_private
105 
106 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
DWARFFormValue.h
DIERef
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:26
DIERef.h
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::DWARFIndex::m_index_time
StatsDuration m_index_time
Definition: DWARFIndex.h:71
DWARFDIE.h
lldb_private::DWARFIndex::DIERefCallback
DIERefCallbackImpl DIERefCallback(llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
Definition: DWARFIndex.h:97
lldb_private::DWARFIndex::DWARFIndex
DWARFIndex(Module &module)
Definition: DWARFIndex.h:24
lldb_private::DWARFIndex::GetTypes
virtual void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
lldb_private::DWARFIndex::GetCompleteObjCClass
virtual void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback)=0
SymbolFileDWARF
Definition: SymbolFileDWARF.h:59
lldb_private::DWARFIndex::DIERefCallbackImpl::DIERefCallbackImpl
DIERefCallbackImpl(const DWARFIndex &index, llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name)
Definition: DWARFIndex.cpp:67
lldb_private::Module
Definition: Module.h:85
lldb_private::Stream
Definition: Stream.h:28
lldb_private::DWARFIndex::GetGlobalVariables
virtual void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback)=0
Finds global variables with the given base name.
DWARFDIE
Definition: DWARFDIE.h:16
lldb_private::DWARFIndex
Definition: DWARFIndex.h:22
lldb_private::DWARFIndex::Preload
virtual void Preload()=0
DWARFUnit
Definition: DWARFUnit.h:81
dwarf
Definition: ABISysV_arc.cpp:61
lldb_private::DWARFIndex::DIERefCallbackImpl::m_index
const DWARFIndex & m_index
Definition: DWARFIndex.h:91
lldb_private::DWARFIndex::DIERefCallbackImpl::m_dwarf
SymbolFileDWARF & m_dwarf
Definition: DWARFIndex.h:92
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::DWARFIndex::~DWARFIndex
virtual ~DWARFIndex()
lldb_private::DWARFIndex::DIERefCallbackImpl::operator()
bool operator()(DIERef ref) const
Definition: DWARFIndex.cpp:74
lldb_private::DWARFIndex::ReportInvalidDIERef
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:81
lldb_private::DWARFIndex::ProcessFunctionDIE
bool ProcessFunctionDIE(llvm::StringRef name, DIERef ref, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
Definition: DWARFIndex.cpp:21
lldb_private::DWARFIndex::DIERefCallbackImpl
Definition: DWARFIndex.h:83
lldb_private::StatsDuration
std::chrono::duration< double > StatsDuration
Definition: Statistics.h:23
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::DWARFIndex::DIERefCallbackImpl::m_name
const llvm::StringRef m_name
Definition: DWARFIndex.h:94
uint32_t
lldb_private::DWARFIndex::GetFunctions
virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, llvm::function_ref< bool(DWARFDIE die)> callback)=0
lldb_private::DWARFIndex::m_module
Module & m_module
Definition: DWARFIndex.h:70
lldb_private::DWARFIndex::Dump
virtual void Dump(Stream &s)=0
lldb_private::DWARFIndex::GetIndexTime
StatsDuration GetIndexTime()
Definition: DWARFIndex.h:67
lldb_private::DWARFIndex::GetObjCMethods
virtual void GetObjCMethods(ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
Statistics.h
DWARFDeclContext
Definition: DWARFDeclContext.h:23
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::DWARFIndex::GetNamespaces
virtual void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
lldb_private::DWARFIndex::DIERefCallbackImpl::m_callback
const llvm::function_ref< bool(DWARFDIE die)> m_callback
Definition: DWARFIndex.h:93