• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ManualDWARFIndex.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_MANUALDWARFINDEX_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H
11 
12 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
13 #include "Plugins/SymbolFile/DWARF/NameToDIE.h"
14 #include "llvm/ADT/DenseSet.h"
15 
16 class DWARFDebugInfo;
17 class SymbolFileDWARFDwo;
18 
19 namespace lldb_private {
20 class ManualDWARFIndex : public DWARFIndex {
21 public:
22   ManualDWARFIndex(Module &module, SymbolFileDWARF &dwarf,
23                    llvm::DenseSet<dw_offset_t> units_to_avoid = {})
DWARFIndex(module)24       : DWARFIndex(module), m_dwarf(&dwarf),
25         m_units_to_avoid(std::move(units_to_avoid)) {}
26 
Preload()27   void Preload() override { Index(); }
28 
29   void
30   GetGlobalVariables(ConstString basename,
31                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
32   void
33   GetGlobalVariables(const RegularExpression &regex,
34                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
35   void
36   GetGlobalVariables(const DWARFUnit &unit,
37                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
38   void GetObjCMethods(ConstString class_name,
39                       llvm::function_ref<bool(DWARFDIE die)> callback) override;
40   void GetCompleteObjCClass(
41       ConstString class_name, bool must_be_implementation,
42       llvm::function_ref<bool(DWARFDIE die)> callback) override;
43   void GetTypes(ConstString name,
44                 llvm::function_ref<bool(DWARFDIE die)> callback) override;
45   void GetTypes(const DWARFDeclContext &context,
46                 llvm::function_ref<bool(DWARFDIE die)> callback) override;
47   void GetNamespaces(ConstString name,
48                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
49   void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
50                     const CompilerDeclContext &parent_decl_ctx,
51                     uint32_t name_type_mask,
52                     llvm::function_ref<bool(DWARFDIE die)> callback) override;
53   void GetFunctions(const RegularExpression &regex,
54                     llvm::function_ref<bool(DWARFDIE die)> callback) override;
55 
56   void Dump(Stream &s) override;
57 
58 private:
59   struct IndexSet {
60     NameToDIE function_basenames;
61     NameToDIE function_fullnames;
62     NameToDIE function_methods;
63     NameToDIE function_selectors;
64     NameToDIE objc_class_selectors;
65     NameToDIE globals;
66     NameToDIE types;
67     NameToDIE namespaces;
68   };
69   void Index();
70   void IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp, IndexSet &set);
71 
72   static void IndexUnitImpl(DWARFUnit &unit,
73                             const lldb::LanguageType cu_language,
74                             IndexSet &set);
75 
76   /// The DWARF file which we are indexing. Set to nullptr after the index is
77   /// built.
78   SymbolFileDWARF *m_dwarf;
79   /// Which dwarf units should we skip while building the index.
80   llvm::DenseSet<dw_offset_t> m_units_to_avoid;
81 
82   IndexSet m_set;
83 };
84 } // namespace lldb_private
85 
86 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H
87