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
17#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
18#include <optional>
19
20namespace lldb_private::plugin {
21namespace dwarf {
23public:
24 static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
25 Create(Module &module, DWARFDataExtractor debug_names,
27
28 void Preload() override { m_fallback.Preload(); }
29
30 void
32 llvm::function_ref<bool(DWARFDIE die)> callback) override;
33 void
35 llvm::function_ref<bool(DWARFDIE die)> callback) override;
36 void
38 llvm::function_ref<bool(DWARFDIE die)> callback) override;
39 void
41 llvm::function_ref<bool(DWARFDIE die)> callback) override {}
43 ConstString class_name, bool must_be_implementation,
44 llvm::function_ref<bool(DWARFDIE die)> callback) override;
45
46 /// Uses DWARF5's IDX_parent fields, when available, to speed up this query.
48 const DWARFDeclContext &context,
49 llvm::function_ref<bool(DWARFDIE die)> callback) override;
50 void GetTypes(ConstString name,
51 llvm::function_ref<bool(DWARFDIE die)> callback) override;
52 void GetTypes(const DWARFDeclContext &context,
53 llvm::function_ref<bool(DWARFDIE die)> callback) override;
54 void GetNamespaces(ConstString name,
55 llvm::function_ref<bool(DWARFDIE die)> callback) override;
56 void GetFunctions(const Module::LookupInfo &lookup_info,
58 const CompilerDeclContext &parent_decl_ctx,
59 llvm::function_ref<bool(DWARFDIE die)> callback) override;
60 void GetFunctions(const RegularExpression &regex,
61 llvm::function_ref<bool(DWARFDIE die)> callback) override;
62
63 void Dump(Stream &s) override;
64
65private:
67 std::unique_ptr<llvm::DWARFDebugNames> debug_names_up,
68 DWARFDataExtractor debug_names_data,
69 DWARFDataExtractor debug_str_data,
72 m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
73 m_debug_names_up(std::move(debug_names_up)),
75
77
78 // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep
79 // track of the ownership here.
82
83 using DebugNames = llvm::DWARFDebugNames;
84 std::unique_ptr<DebugNames> m_debug_names_up;
86
87 std::optional<DIERef> ToDIERef(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)
std::optional< DIERef > ToDIERef(const DebugNames::Entry &entry) const
static void MaybeLogLookupError(llvm::Error error, const DebugNames::NameIndex &ni, llvm::StringRef name)
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)