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/Core/Module.h"
17 #include "lldb/Target/Statistics.h"
18 
19 class DWARFDeclContext;
20 class DWARFDIE;
21 
22 namespace lldb_private {
23 class DWARFIndex {
24 public:
25  DWARFIndex(Module &module) : m_module(module) {}
26  virtual ~DWARFIndex();
27 
28  virtual void Preload() = 0;
29 
30  /// Finds global variables with the given base name. Any additional filtering
31  /// (e.g., to only retrieve variables from a given context) should be done by
32  /// the consumer.
33  virtual void
35  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
36 
37  virtual void
39  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
40  /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
41  virtual void
43  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
44  virtual void
45  GetObjCMethods(ConstString class_name,
46  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
47  virtual void
48  GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
49  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
50  virtual void GetTypes(ConstString name,
51  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
52  virtual void GetTypes(const DWARFDeclContext &context,
53  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
54  virtual void
56  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
57  virtual void
59  const CompilerDeclContext &parent_decl_ctx,
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(const Module::LookupInfo &lookup_info, DIERef ref,
79  const CompilerDeclContext &parent_decl_ctx,
80  llvm::function_ref<bool(DWARFDIE die)> callback);
81 
83  public:
84  DIERefCallbackImpl(const DWARFIndex &index,
85  llvm::function_ref<bool(DWARFDIE die)> callback,
86  llvm::StringRef name);
87  bool operator()(DIERef ref) const;
88 
89  private:
92  const llvm::function_ref<bool(DWARFDIE die)> m_callback;
93  const llvm::StringRef m_name;
94  };
96  DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
97  llvm::StringRef name = {}) const {
98  return DIERefCallbackImpl(*this, callback, name);
99  }
100 
101  void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
102 };
103 } // namespace lldb_private
104 
105 #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:96
lldb_private::DWARFIndex::DWARFIndex
DWARFIndex(Module &module)
Definition: DWARFIndex.h:25
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
lldb_private::StatsDuration::Duration
std::chrono::duration< double > Duration
Definition: Statistics.h:29
Module.h
SymbolFileDWARF
Definition: SymbolFileDWARF.h:60
lldb_private::DWARFIndex::DIERefCallbackImpl::DIERefCallbackImpl
DIERefCallbackImpl(const DWARFIndex &index, llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name)
Definition: DWARFIndex.cpp:87
lldb_private::Module
Definition: Module.h:85
lldb_private::DWARFIndex::GetIndexTime
StatsDuration::Duration GetIndexTime()
Definition: DWARFIndex.h:67
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StatsDuration
Definition: Statistics.h:27
lldb_private::DWARFIndex::GetFunctions
virtual void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)=0
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:23
lldb_private::Module::LookupInfo
Definition: Module.h:931
lldb_private::DWARFIndex::Preload
virtual void Preload()=0
lldb_private::DWARFIndex::ProcessFunctionDIE
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
Definition: DWARFIndex.cpp:23
DWARFUnit
Definition: DWARFUnit.h:83
bool
dwarf
Definition: ABISysV_arc.cpp:61
lldb_private::DWARFIndex::DIERefCallbackImpl::m_index
const DWARFIndex & m_index
Definition: DWARFIndex.h:90
lldb_private::DWARFIndex::DIERefCallbackImpl::m_dwarf
SymbolFileDWARF & m_dwarf
Definition: DWARFIndex.h:91
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::DWARFIndex::~DWARFIndex
virtual ~DWARFIndex()
lldb_private::DWARFIndex::DIERefCallbackImpl::operator()
bool operator()(DIERef ref) const
Definition: DWARFIndex.cpp:95
lldb_private::DWARFIndex::ReportInvalidDIERef
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:102
lldb_private::DWARFIndex::DIERefCallbackImpl
Definition: DWARFIndex.h:82
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:93
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::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:92