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_MANUALDWARFINDEX_H
10#define LLDB_MANUALDWARFINDEX_H
11
12#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
13#include "Plugins/SymbolFile/DWARF/NameToDIE.h"
14#include "llvm/ADT/DenseSet.h"
15
16class DWARFDebugInfo;
17
18namespace lldb_private {
19class ManualDWARFIndex : public DWARFIndex {
20public:
21  ManualDWARFIndex(Module &module, DWARFDebugInfo *debug_info,
22                   llvm::DenseSet<dw_offset_t> units_to_avoid = {})
23      : DWARFIndex(module), m_debug_info(debug_info),
24        m_units_to_avoid(std::move(units_to_avoid)) {}
25
26  void Preload() override { Index(); }
27
28  void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
29  void GetGlobalVariables(const RegularExpression &regex,
30                          DIEArray &offsets) override;
31  void GetGlobalVariables(const DWARFUnit &unit, DIEArray &offsets) override;
32  void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
33  void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
34                            DIEArray &offsets) override;
35  void GetTypes(ConstString name, DIEArray &offsets) override;
36  void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
37  void GetNamespaces(ConstString name, DIEArray &offsets) override;
38  void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
39                    const CompilerDeclContext &parent_decl_ctx,
40                    uint32_t name_type_mask,
41                    std::vector<DWARFDIE> &dies) override;
42  void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
43
44  void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
45  void Dump(Stream &s) override;
46
47private:
48  struct IndexSet {
49    NameToDIE function_basenames;
50    NameToDIE function_fullnames;
51    NameToDIE function_methods;
52    NameToDIE function_selectors;
53    NameToDIE objc_class_selectors;
54    NameToDIE globals;
55    NameToDIE types;
56    NameToDIE namespaces;
57  };
58  void Index();
59  void IndexUnit(DWARFUnit &unit, IndexSet &set);
60
61  static void IndexUnitImpl(DWARFUnit &unit,
62                            const lldb::LanguageType cu_language,
63                            IndexSet &set);
64
65  /// Non-null value means we haven't built the index yet.
66  DWARFDebugInfo *m_debug_info;
67  /// Which dwarf units should we skip while building the index.
68  llvm::DenseSet<dw_offset_t> m_units_to_avoid;
69
70  IndexSet m_set;
71};
72} // namespace lldb_private
73
74#endif // LLDB_MANUALDWARFINDEX_H
75