1 //===-- AppleDWARFIndex.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_APPLEDWARFINDEX_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
11 
12 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
13 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
14 
15 namespace lldb_private {
16 class AppleDWARFIndex : public DWARFIndex {
17 public:
18   static std::unique_ptr<AppleDWARFIndex>
19   Create(Module &module, DWARFDataExtractor apple_names,
20          DWARFDataExtractor apple_namespaces, DWARFDataExtractor apple_types,
21          DWARFDataExtractor apple_objc, DWARFDataExtractor debug_str);
22 
23   AppleDWARFIndex(Module &module,
24                   std::unique_ptr<llvm::AppleAcceleratorTable> apple_names,
25                   std::unique_ptr<llvm::AppleAcceleratorTable> apple_namespaces,
26                   std::unique_ptr<llvm::AppleAcceleratorTable> apple_types,
27                   std::unique_ptr<llvm::AppleAcceleratorTable> apple_objc)
28       : DWARFIndex(module), m_apple_names_up(std::move(apple_names)),
29         m_apple_namespaces_up(std::move(apple_namespaces)),
30         m_apple_types_up(std::move(apple_types)),
31         m_apple_objc_up(std::move(apple_objc)) {}
32 
33   void Preload() override {}
34 
35   void
36   GetGlobalVariables(ConstString basename,
37                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
38   void
39   GetGlobalVariables(const RegularExpression &regex,
40                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
41   void
42   GetGlobalVariables(DWARFUnit &cu,
43                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
44   void GetObjCMethods(ConstString class_name,
45                       llvm::function_ref<bool(DWARFDIE die)> callback) override;
46   void GetCompleteObjCClass(
47       ConstString class_name, bool must_be_implementation,
48       llvm::function_ref<bool(DWARFDIE die)> callback) override;
49   void GetTypes(ConstString name,
50                 llvm::function_ref<bool(DWARFDIE die)> callback) override;
51   void GetTypes(const DWARFDeclContext &context,
52                 llvm::function_ref<bool(DWARFDIE die)> callback) override;
53   void GetNamespaces(ConstString name,
54                      llvm::function_ref<bool(DWARFDIE die)> callback) override;
55   void GetFunctions(const Module::LookupInfo &lookup_info,
56                     SymbolFileDWARF &dwarf,
57                     const CompilerDeclContext &parent_decl_ctx,
58                     llvm::function_ref<bool(DWARFDIE die)> callback) override;
59   void GetFunctions(const RegularExpression &regex,
60                     llvm::function_ref<bool(DWARFDIE die)> callback) override;
61 
62   void Dump(Stream &s) override;
63 
64 private:
65   std::unique_ptr<llvm::AppleAcceleratorTable> m_apple_names_up;
66   std::unique_ptr<llvm::AppleAcceleratorTable> m_apple_namespaces_up;
67   std::unique_ptr<llvm::AppleAcceleratorTable> m_apple_types_up;
68   std::unique_ptr<llvm::AppleAcceleratorTable> m_apple_objc_up;
69 
70   /// Search for entries whose name is `name` in `table`, calling `callback` for
71   /// each match. If `search_for_tag` is provided, ignore entries whose tag is
72   /// not `search_for_tag`. If `search_for_qualhash` is provided, ignore entries
73   /// whose qualified name hash does not match `search_for_qualhash`.
74   /// If `callback` returns false for an entry, the search is interrupted.
75   void SearchFor(const llvm::AppleAcceleratorTable &table, llvm::StringRef name,
76                  llvm::function_ref<bool(DWARFDIE die)> callback,
77                  std::optional<dw_tag_t> search_for_tag = std::nullopt,
78                  std::optional<uint32_t> search_for_qualhash = std::nullopt);
79 };
80 } // namespace lldb_private
81 
82 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
83