1353358Sdim//===-- ManualDWARFIndex.h --------------------------------------*- C++ -*-===//
2336823Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6336823Sdim//
7336823Sdim//===----------------------------------------------------------------------===//
8336823Sdim
9336823Sdim#ifndef LLDB_MANUALDWARFINDEX_H
10336823Sdim#define LLDB_MANUALDWARFINDEX_H
11336823Sdim
12336823Sdim#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
13336823Sdim#include "Plugins/SymbolFile/DWARF/NameToDIE.h"
14336823Sdim#include "llvm/ADT/DenseSet.h"
15336823Sdim
16353358Sdimclass DWARFDebugInfo;
17353358Sdim
18336823Sdimnamespace lldb_private {
19336823Sdimclass ManualDWARFIndex : public DWARFIndex {
20336823Sdimpublic:
21336823Sdim  ManualDWARFIndex(Module &module, DWARFDebugInfo *debug_info,
22336823Sdim                   llvm::DenseSet<dw_offset_t> units_to_avoid = {})
23336823Sdim      : DWARFIndex(module), m_debug_info(debug_info),
24336823Sdim        m_units_to_avoid(std::move(units_to_avoid)) {}
25336823Sdim
26336823Sdim  void Preload() override { Index(); }
27336823Sdim
28336823Sdim  void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
29336823Sdim  void GetGlobalVariables(const RegularExpression &regex,
30336823Sdim                          DIEArray &offsets) override;
31353358Sdim  void GetGlobalVariables(const DWARFUnit &unit, DIEArray &offsets) override;
32336823Sdim  void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
33336823Sdim  void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
34336823Sdim                            DIEArray &offsets) override;
35336823Sdim  void GetTypes(ConstString name, DIEArray &offsets) override;
36336823Sdim  void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
37336823Sdim  void GetNamespaces(ConstString name, DIEArray &offsets) override;
38353358Sdim  void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
39336823Sdim                    const CompilerDeclContext &parent_decl_ctx,
40336823Sdim                    uint32_t name_type_mask,
41336823Sdim                    std::vector<DWARFDIE> &dies) override;
42336823Sdim  void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
43336823Sdim
44353358Sdim  void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
45336823Sdim  void Dump(Stream &s) override;
46336823Sdim
47336823Sdimprivate:
48336823Sdim  struct IndexSet {
49336823Sdim    NameToDIE function_basenames;
50336823Sdim    NameToDIE function_fullnames;
51336823Sdim    NameToDIE function_methods;
52336823Sdim    NameToDIE function_selectors;
53336823Sdim    NameToDIE objc_class_selectors;
54336823Sdim    NameToDIE globals;
55336823Sdim    NameToDIE types;
56336823Sdim    NameToDIE namespaces;
57336823Sdim  };
58336823Sdim  void Index();
59336823Sdim  void IndexUnit(DWARFUnit &unit, IndexSet &set);
60336823Sdim
61353358Sdim  static void IndexUnitImpl(DWARFUnit &unit,
62353358Sdim                            const lldb::LanguageType cu_language,
63353358Sdim                            IndexSet &set);
64336823Sdim
65336823Sdim  /// Non-null value means we haven't built the index yet.
66336823Sdim  DWARFDebugInfo *m_debug_info;
67336823Sdim  /// Which dwarf units should we skip while building the index.
68336823Sdim  llvm::DenseSet<dw_offset_t> m_units_to_avoid;
69336823Sdim
70336823Sdim  IndexSet m_set;
71336823Sdim};
72336823Sdim} // namespace lldb_private
73336823Sdim
74336823Sdim#endif // LLDB_MANUALDWARFINDEX_H
75