LLDB mainline
DebugNamesDWARFIndex.h
Go to the documentation of this file.
1//===-- DebugNamesDWARFIndex.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_DEBUGNAMESDWARFINDEX_H
10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H
11
16#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
17#include <optional>
18
19namespace lldb_private::plugin {
20namespace dwarf {
22public:
23 static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
24 Create(Module &module, DWARFDataExtractor debug_names,
26
27 void Preload() override { m_fallback.Preload(); }
28
29 void
31 llvm::function_ref<bool(DWARFDIE die)> callback) override;
32 void
34 llvm::function_ref<bool(DWARFDIE die)> callback) override;
35 void
37 llvm::function_ref<bool(DWARFDIE die)> callback) override;
38 void
40 llvm::function_ref<bool(DWARFDIE die)> callback) override {}
42 ConstString class_name, bool must_be_implementation,
43 llvm::function_ref<bool(DWARFDIE die)> callback) override;
44
45 /// Uses DWARF5's IDX_parent fields, when available, to speed up this query.
47 const DWARFDeclContext &context,
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,
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
64private:
66 std::unique_ptr<llvm::DWARFDebugNames> debug_names_up,
67 DWARFDataExtractor debug_names_data,
68 DWARFDataExtractor debug_str_data,
71 m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
72 m_debug_names_up(std::move(debug_names_up)),
74
76
77 // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep
78 // track of the ownership here.
81
82 using DebugNames = llvm::DWARFDebugNames;
83 std::unique_ptr<DebugNames> m_debug_names_up;
85
86 DWARFUnit *GetNonSkeletonUnit(const DebugNames::Entry &entry) const;
87 DWARFDIE GetDIE(const DebugNames::Entry &entry) const;
88 bool ProcessEntry(const DebugNames::Entry &entry,
89 llvm::function_ref<bool(DWARFDIE die)> callback);
90
91 /// Returns true if `parent_entries` have identical names to `parent_names`.
92 bool SameParentChain(llvm::ArrayRef<llvm::StringRef> parent_names,
93 llvm::ArrayRef<DebugNames::Entry> parent_entries) const;
94
95 static void MaybeLogLookupError(llvm::Error error,
96 const DebugNames::NameIndex &ni,
97 llvm::StringRef name);
98
99 static llvm::DenseSet<dw_offset_t> GetUnits(const DebugNames &debug_names);
100};
101
102} // namespace dwarf
103} // namespace lldb_private::plugin
104
105#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H
static llvm::raw_ostream & error(Stream &strm)
Represents a generic declaration context in a program.
A uniqued constant string class.
Definition: ConstString.h:40
A class that encapsulates name lookup information.
Definition: Module.h:904
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
DebugNamesDWARFIndex(Module &module, std::unique_ptr< llvm::DWARFDebugNames > debug_names_up, DWARFDataExtractor debug_names_data, DWARFDataExtractor debug_str_data, SymbolFileDWARF &dwarf)
static llvm::Expected< std::unique_ptr< DebugNamesDWARFIndex > > Create(Module &module, DWARFDataExtractor debug_names, DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf)
static void MaybeLogLookupError(llvm::Error error, const DebugNames::NameIndex &ni, llvm::StringRef name)
DWARFDIE GetDIE(const DebugNames::Entry &entry) const
void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetFullyQualifiedType(const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback) override
Uses DWARF5's IDX_parent fields, when available, to speed up this query.
void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
bool ProcessEntry(const DebugNames::Entry &entry, llvm::function_ref< bool(DWARFDIE die)> callback)
void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback) override
Finds global variables with the given base name.
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetObjCMethods(ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback) override
void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback) override
bool SameParentChain(llvm::ArrayRef< llvm::StringRef > parent_names, llvm::ArrayRef< DebugNames::Entry > parent_entries) const
Returns true if parent_entries have identical names to parent_names.
static llvm::DenseSet< dw_offset_t > GetUnits(const DebugNames &debug_names)
DWARFUnit * GetNonSkeletonUnit(const DebugNames::Entry &entry) const