Skip to content

Commit 1673a1b

Browse files
[LLDB][NFC] Create a namespace for the DWARF plugin (llvm#68150)
As a followup of llvm#67851, I'm defining a new namespace `lldb_plugin::dwarf` for the classes in this Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with exporting the necessary symbols for my out-of-tree language plugin. The only class that I didn't change is ClangDWARFASTParser, because that shouldn't be in the same namespace as the generic language-agnostic dwarf parser. It would be a good idea if other plugins follow the same namespace scheme.
1 parent d9ede91 commit 1673a1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+700
-594
lines changed

lldb/include/lldb/Expression/DWARFExpression.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
1919
#include <functional>
2020

21-
class DWARFUnit;
22-
2321
namespace lldb_private {
2422

23+
namespace plugin {
24+
namespace dwarf {
25+
class DWARFUnit;
26+
} // namespace dwarf
27+
} // namespace plugin
28+
2529
/// \class DWARFExpression DWARFExpression.h
2630
/// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
2731
/// expression and interprets it.
@@ -64,18 +68,20 @@ class DWARFExpression {
6468
/// \return
6569
/// The address specified by the operation, if the operation exists, or
6670
/// LLDB_INVALID_ADDRESS otherwise.
67-
lldb::addr_t GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
71+
lldb::addr_t GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu,
6872
bool &error) const;
6973

70-
bool Update_DW_OP_addr(const DWARFUnit *dwarf_cu, lldb::addr_t file_addr);
74+
bool Update_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu,
75+
lldb::addr_t file_addr);
7176

7277
void UpdateValue(uint64_t const_value, lldb::offset_t const_value_byte_size,
7378
uint8_t addr_byte_size);
7479

75-
bool ContainsThreadLocalStorage(const DWARFUnit *dwarf_cu) const;
80+
bool
81+
ContainsThreadLocalStorage(const plugin::dwarf::DWARFUnit *dwarf_cu) const;
7682

7783
bool LinkThreadLocalStorage(
78-
const DWARFUnit *dwarf_cu,
84+
const plugin::dwarf::DWARFUnit *dwarf_cu,
7985
std::function<lldb::addr_t(lldb::addr_t file_addr)> const
8086
&link_address_callback);
8187

@@ -128,13 +134,13 @@ class DWARFExpression {
128134
/// details of the failure are provided through it.
129135
static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
130136
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
131-
const DWARFUnit *dwarf_cu,
137+
const plugin::dwarf::DWARFUnit *dwarf_cu,
132138
const lldb::RegisterKind reg_set,
133139
const Value *initial_value_ptr,
134140
const Value *object_address_ptr, Value &result,
135141
Status *error_ptr);
136142

137-
static bool ParseDWARFLocationList(const DWARFUnit *dwarf_cu,
143+
static bool ParseDWARFLocationList(const plugin::dwarf::DWARFUnit *dwarf_cu,
138144
const DataExtractor &data,
139145
DWARFExpressionList *loc_list);
140146

lldb/include/lldb/Expression/DWARFExpressionList.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,29 @@
1313
#include "lldb/Utility/RangeMap.h"
1414
#include "lldb/lldb-private.h"
1515

16-
class DWARFUnit;
17-
1816
namespace lldb_private {
1917

18+
namespace plugin {
19+
namespace dwarf {
20+
class DWARFUnit;
21+
} // namespace dwarf
22+
} // namespace plugin
23+
2024
/// \class DWARFExpressionList DWARFExpressionList.h
2125
/// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
2226
/// address range to a single DWARF location expression.
2327
class DWARFExpressionList {
2428
public:
2529
DWARFExpressionList() = default;
2630

27-
DWARFExpressionList(lldb::ModuleSP module_sp, const DWARFUnit *dwarf_cu,
31+
DWARFExpressionList(lldb::ModuleSP module_sp,
32+
const plugin::dwarf::DWARFUnit *dwarf_cu,
2833
lldb::addr_t func_file_addr)
2934
: m_module_wp(module_sp), m_dwarf_cu(dwarf_cu),
3035
m_func_file_addr(func_file_addr) {}
3136

3237
DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr,
33-
const DWARFUnit *dwarf_cu)
38+
const plugin::dwarf::DWARFUnit *dwarf_cu)
3439
: m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) {
3540
AddExpression(0, LLDB_INVALID_ADDRESS, expr);
3641
}
@@ -136,7 +141,7 @@ class DWARFExpressionList {
136141
/// The DWARF compile unit this expression belongs to. It is used to evaluate
137142
/// values indexing into the .debug_addr section (e.g. DW_OP_GNU_addr_index,
138143
/// DW_OP_GNU_const_index)
139-
const DWARFUnit *m_dwarf_cu = nullptr;
144+
const plugin::dwarf::DWARFUnit *m_dwarf_cu = nullptr;
140145

141146
// Function base file address.
142147
lldb::addr_t m_func_file_addr = LLDB_INVALID_ADDRESS;

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@
2828
#include "lldb/Symbol/CompilerDeclContext.h"
2929
#include "lldb/lldb-private.h"
3030

31-
class DWARFDIE;
32-
class DWARFASTParser;
3331
class PDBASTParser;
3432

3533
namespace lldb_private {
34+
35+
namespace plugin {
36+
namespace dwarf {
37+
class DWARFDIE;
38+
class DWARFASTParser;
39+
} // namespace dwarf
40+
} // namespace plugin
41+
3642
namespace npdb {
3743
class PdbAstBuilder;
3844
} // namespace npdb
@@ -93,7 +99,8 @@ class TypeSystem : public PluginInterface,
9399
/// removing all the TypeSystems from the TypeSystemMap.
94100
virtual void Finalize() {}
95101

96-
virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
102+
virtual plugin::dwarf::DWARFASTParser *GetDWARFParser() { return nullptr; }
103+
97104
virtual PDBASTParser *GetPDBParser() { return nullptr; }
98105
virtual npdb::PdbAstBuilder *GetNativePDBParser() { return nullptr; }
99106

@@ -563,6 +570,6 @@ class TypeSystemMap {
563570
std::optional<CreateCallback> create_callback = std::nullopt);
564571
};
565572

566-
} // namespace lldb_private
573+
} // namespace lldb_private
567574

568575
#endif // LLDB_SYMBOL_TYPESYSTEM_H

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
using namespace lldb;
4646
using namespace lldb_private;
4747
using namespace lldb_private::dwarf;
48+
using namespace lldb_private::plugin::dwarf;
4849

4950
// DWARFExpression constructor
5051
DWARFExpression::DWARFExpression() : m_data() {}

lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using namespace lldb_private;
1919
using namespace lldb;
2020
using namespace lldb_private::dwarf;
21+
using namespace lldb_private::plugin::dwarf;
2122

2223
std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create(
2324
Module &module, DWARFDataExtractor apple_names,

lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
1313
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
1414

15-
namespace lldb_private {
15+
namespace lldb_private::plugin {
16+
namespace dwarf {
1617
class AppleDWARFIndex : public DWARFIndex {
1718
public:
1819
static std::unique_ptr<AppleDWARFIndex>
@@ -77,6 +78,7 @@ class AppleDWARFIndex : public DWARFIndex {
7778
std::optional<dw_tag_t> search_for_tag = std::nullopt,
7879
std::optional<uint32_t> search_for_qualhash = std::nullopt);
7980
};
80-
} // namespace lldb_private
81+
} // namespace dwarf
82+
} // namespace lldb_private::plugin
8183

8284
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H

lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using namespace lldb;
1616
using namespace lldb_private;
17+
using namespace lldb_private::plugin::dwarf;
1718

1819
void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS,
1920
StringRef Style) {

lldb/source/Plugins/SymbolFile/DWARF/DIERef.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <cassert>
1515
#include <optional>
1616

17+
namespace lldb_private::plugin {
18+
namespace dwarf {
1719
/// Identifies a DWARF debug info entry within a given Module. It contains three
1820
/// "coordinates":
1921
/// - file_index: identifies the separate stand alone debug info file
@@ -93,7 +95,7 @@ class DIERef {
9395
/// \return
9496
/// Returns a valid DIERef if decoding succeeded, std::nullopt if there was
9597
/// unsufficient or invalid values that were decoded.
96-
static std::optional<DIERef> Decode(const lldb_private::DataExtractor &data,
98+
static std::optional<DIERef> Decode(const DataExtractor &data,
9799
lldb::offset_t *offset_ptr);
98100

99101
/// Encode this object into a data encoder object.
@@ -103,7 +105,7 @@ class DIERef {
103105
/// \param encoder
104106
/// A data encoder object that serialized bytes will be encoded into.
105107
///
106-
void Encode(lldb_private::DataEncoder &encoder) const;
108+
void Encode(DataEncoder &encoder) const;
107109

108110
static constexpr uint64_t k_die_offset_bit_size = DW_DIE_OFFSET_MAX_BITSIZE;
109111
static constexpr uint64_t k_file_index_bit_size =
@@ -131,10 +133,13 @@ class DIERef {
131133
static_assert(sizeof(DIERef) == 8);
132134

133135
typedef std::vector<DIERef> DIEArray;
136+
} // namespace dwarf
137+
} // namespace lldb_private::plugin
134138

135139
namespace llvm {
136-
template<> struct format_provider<DIERef> {
137-
static void format(const DIERef &ref, raw_ostream &OS, StringRef Style);
140+
template <> struct format_provider<lldb_private::plugin::dwarf::DIERef> {
141+
static void format(const lldb_private::plugin::dwarf::DIERef &ref,
142+
raw_ostream &OS, StringRef Style);
138143
};
139144
} // namespace llvm
140145

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using namespace lldb;
1919
using namespace lldb_private;
2020
using namespace lldb_private::dwarf;
21+
using namespace lldb_private::plugin::dwarf;
2122

2223
std::optional<SymbolFile::ArrayInfo>
2324
DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,53 @@
1717
#include "lldb/lldb-enumerations.h"
1818
#include <optional>
1919

20-
class DWARFDIE;
2120
namespace lldb_private {
2221
class CompileUnit;
2322
class ExecutionContext;
2423
}
24+
25+
namespace lldb_private::plugin {
26+
namespace dwarf {
27+
class DWARFDIE;
2528
class SymbolFileDWARF;
2629

2730
class DWARFASTParser {
2831
public:
2932
virtual ~DWARFASTParser() = default;
3033

31-
virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
34+
virtual lldb::TypeSP ParseTypeFromDWARF(const SymbolContext &sc,
3235
const DWARFDIE &die,
3336
bool *type_is_new_ptr) = 0;
3437

35-
virtual lldb_private::ConstString
36-
ConstructDemangledNameFromDWARF(const DWARFDIE &die) = 0;
38+
virtual ConstString ConstructDemangledNameFromDWARF(const DWARFDIE &die) = 0;
3739

38-
virtual lldb_private::Function *
39-
ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
40-
const DWARFDIE &die,
41-
const lldb_private::AddressRange &range) = 0;
40+
virtual Function *ParseFunctionFromDWARF(CompileUnit &comp_unit,
41+
const DWARFDIE &die,
42+
const AddressRange &range) = 0;
4243

43-
virtual bool
44-
CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
45-
lldb_private::CompilerType &compiler_type) = 0;
44+
virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
45+
CompilerType &compiler_type) = 0;
4646

47-
virtual lldb_private::CompilerDecl
48-
GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;
47+
virtual CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;
4948

50-
virtual lldb_private::CompilerDeclContext
49+
virtual CompilerDeclContext
5150
GetDeclContextForUIDFromDWARF(const DWARFDIE &die) = 0;
5251

53-
virtual lldb_private::CompilerDeclContext
52+
virtual CompilerDeclContext
5453
GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) = 0;
5554

5655
virtual void EnsureAllDIEsInDeclContextHaveBeenParsed(
57-
lldb_private::CompilerDeclContext decl_context) = 0;
56+
CompilerDeclContext decl_context) = 0;
5857

59-
virtual lldb_private::ConstString
60-
GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
58+
virtual ConstString GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
6159

62-
static std::optional<lldb_private::SymbolFile::ArrayInfo>
60+
static std::optional<SymbolFile::ArrayInfo>
6361
ParseChildArrayInfo(const DWARFDIE &parent_die,
64-
const lldb_private::ExecutionContext *exe_ctx = nullptr);
62+
const ExecutionContext *exe_ctx = nullptr);
6563

6664
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
6765
};
66+
} // namespace dwarf
67+
} // namespace lldb_private::plugin
6868

6969
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
using namespace lldb;
6161
using namespace lldb_private;
6262
using namespace lldb_private::dwarf;
63+
using namespace lldb_private::plugin::dwarf;
64+
6365
DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)
6466
: m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
6567

0 commit comments

Comments
 (0)