Skip to content

[LLDB][NFC] Create a namespace for the DWARF plugin #68150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions lldb/include/lldb/Expression/DWARFExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
#include <functional>

class DWARFUnit;

namespace lldb_private {

namespace plugin {
namespace dwarf {
class DWARFUnit;
} // namespace dwarf
} // namespace plugin

/// \class DWARFExpression DWARFExpression.h
/// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
/// expression and interprets it.
Expand Down Expand Up @@ -64,18 +68,20 @@ class DWARFExpression {
/// \return
/// The address specified by the operation, if the operation exists, or
/// LLDB_INVALID_ADDRESS otherwise.
lldb::addr_t GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
lldb::addr_t GetLocation_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu,
bool &error) const;

bool Update_DW_OP_addr(const DWARFUnit *dwarf_cu, lldb::addr_t file_addr);
bool Update_DW_OP_addr(const plugin::dwarf::DWARFUnit *dwarf_cu,
lldb::addr_t file_addr);

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

bool ContainsThreadLocalStorage(const DWARFUnit *dwarf_cu) const;
bool
ContainsThreadLocalStorage(const plugin::dwarf::DWARFUnit *dwarf_cu) const;

bool LinkThreadLocalStorage(
const DWARFUnit *dwarf_cu,
const plugin::dwarf::DWARFUnit *dwarf_cu,
std::function<lldb::addr_t(lldb::addr_t file_addr)> const
&link_address_callback);

Expand Down Expand Up @@ -128,13 +134,13 @@ class DWARFExpression {
/// details of the failure are provided through it.
static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
const DWARFUnit *dwarf_cu,
const plugin::dwarf::DWARFUnit *dwarf_cu,
const lldb::RegisterKind reg_set,
const Value *initial_value_ptr,
const Value *object_address_ptr, Value &result,
Status *error_ptr);

static bool ParseDWARFLocationList(const DWARFUnit *dwarf_cu,
static bool ParseDWARFLocationList(const plugin::dwarf::DWARFUnit *dwarf_cu,
const DataExtractor &data,
DWARFExpressionList *loc_list);

Expand Down
15 changes: 10 additions & 5 deletions lldb/include/lldb/Expression/DWARFExpressionList.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@
#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"

class DWARFUnit;

namespace lldb_private {

namespace plugin {
namespace dwarf {
class DWARFUnit;
} // namespace dwarf
} // namespace plugin

/// \class DWARFExpressionList DWARFExpressionList.h
/// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
/// address range to a single DWARF location expression.
class DWARFExpressionList {
public:
DWARFExpressionList() = default;

DWARFExpressionList(lldb::ModuleSP module_sp, const DWARFUnit *dwarf_cu,
DWARFExpressionList(lldb::ModuleSP module_sp,
const plugin::dwarf::DWARFUnit *dwarf_cu,
lldb::addr_t func_file_addr)
: m_module_wp(module_sp), m_dwarf_cu(dwarf_cu),
m_func_file_addr(func_file_addr) {}

DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr,
const DWARFUnit *dwarf_cu)
const plugin::dwarf::DWARFUnit *dwarf_cu)
: m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) {
AddExpression(0, LLDB_INVALID_ADDRESS, expr);
}
Expand Down Expand Up @@ -136,7 +141,7 @@ class DWARFExpressionList {
/// The DWARF compile unit this expression belongs to. It is used to evaluate
/// values indexing into the .debug_addr section (e.g. DW_OP_GNU_addr_index,
/// DW_OP_GNU_const_index)
const DWARFUnit *m_dwarf_cu = nullptr;
const plugin::dwarf::DWARFUnit *m_dwarf_cu = nullptr;

// Function base file address.
lldb::addr_t m_func_file_addr = LLDB_INVALID_ADDRESS;
Expand Down
15 changes: 11 additions & 4 deletions lldb/include/lldb/Symbol/TypeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/lldb-private.h"

class DWARFDIE;
class DWARFASTParser;
class PDBASTParser;

namespace lldb_private {

namespace plugin {
namespace dwarf {
class DWARFDIE;
class DWARFASTParser;
} // namespace dwarf
} // namespace plugin

namespace npdb {
class PdbAstBuilder;
} // namespace npdb
Expand Down Expand Up @@ -93,7 +99,8 @@ class TypeSystem : public PluginInterface,
/// removing all the TypeSystems from the TypeSystemMap.
virtual void Finalize() {}

virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
virtual plugin::dwarf::DWARFASTParser *GetDWARFParser() { return nullptr; }

virtual PDBASTParser *GetPDBParser() { return nullptr; }
virtual npdb::PdbAstBuilder *GetNativePDBParser() { return nullptr; }

Expand Down Expand Up @@ -563,6 +570,6 @@ class TypeSystemMap {
std::optional<CreateCallback> create_callback = std::nullopt);
};

} // namespace lldb_private
} // namespace lldb_private

#endif // LLDB_SYMBOL_TYPESYSTEM_H
1 change: 1 addition & 0 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::dwarf;
using namespace lldb_private::plugin::dwarf;

// DWARFExpression constructor
DWARFExpression::DWARFExpression() : m_data() {}
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using namespace lldb_private;
using namespace lldb;
using namespace lldb_private::dwarf;
using namespace lldb_private::plugin::dwarf;

std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create(
Module &module, DWARFDataExtractor apple_names,
Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"

namespace lldb_private {
namespace lldb_private::plugin {
namespace dwarf {
class AppleDWARFIndex : public DWARFIndex {
public:
static std::unique_ptr<AppleDWARFIndex>
Expand Down Expand Up @@ -77,6 +78,7 @@ class AppleDWARFIndex : public DWARFIndex {
std::optional<dw_tag_t> search_for_tag = std::nullopt,
std::optional<uint32_t> search_for_qualhash = std::nullopt);
};
} // namespace lldb_private
} // namespace dwarf
} // namespace lldb_private::plugin

#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
1 change: 1 addition & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::plugin::dwarf;

void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS,
StringRef Style) {
Expand Down
13 changes: 9 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <cassert>
#include <optional>

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

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

static constexpr uint64_t k_die_offset_bit_size = DW_DIE_OFFSET_MAX_BITSIZE;
static constexpr uint64_t k_file_index_bit_size =
Expand Down Expand Up @@ -131,10 +133,13 @@ class DIERef {
static_assert(sizeof(DIERef) == 8);

typedef std::vector<DIERef> DIEArray;
} // namespace dwarf
} // namespace lldb_private::plugin

namespace llvm {
template<> struct format_provider<DIERef> {
static void format(const DIERef &ref, raw_ostream &OS, StringRef Style);
template <> struct format_provider<lldb_private::plugin::dwarf::DIERef> {
static void format(const lldb_private::plugin::dwarf::DIERef &ref,
raw_ostream &OS, StringRef Style);
};
} // namespace llvm

Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::dwarf;
using namespace lldb_private::plugin::dwarf;

std::optional<SymbolFile::ArrayInfo>
DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
Expand Down
40 changes: 20 additions & 20 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,53 @@
#include "lldb/lldb-enumerations.h"
#include <optional>

class DWARFDIE;
namespace lldb_private {
class CompileUnit;
class ExecutionContext;
}

namespace lldb_private::plugin {
namespace dwarf {
class DWARFDIE;
class SymbolFileDWARF;

class DWARFASTParser {
public:
virtual ~DWARFASTParser() = default;

virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
virtual lldb::TypeSP ParseTypeFromDWARF(const SymbolContext &sc,
const DWARFDIE &die,
bool *type_is_new_ptr) = 0;

virtual lldb_private::ConstString
ConstructDemangledNameFromDWARF(const DWARFDIE &die) = 0;
virtual ConstString ConstructDemangledNameFromDWARF(const DWARFDIE &die) = 0;

virtual lldb_private::Function *
ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
const DWARFDIE &die,
const lldb_private::AddressRange &range) = 0;
virtual Function *ParseFunctionFromDWARF(CompileUnit &comp_unit,
const DWARFDIE &die,
const AddressRange &range) = 0;

virtual bool
CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
lldb_private::CompilerType &compiler_type) = 0;
virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
CompilerType &compiler_type) = 0;

virtual lldb_private::CompilerDecl
GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;
virtual CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;

virtual lldb_private::CompilerDeclContext
virtual CompilerDeclContext
GetDeclContextForUIDFromDWARF(const DWARFDIE &die) = 0;

virtual lldb_private::CompilerDeclContext
virtual CompilerDeclContext
GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) = 0;

virtual void EnsureAllDIEsInDeclContextHaveBeenParsed(
lldb_private::CompilerDeclContext decl_context) = 0;
CompilerDeclContext decl_context) = 0;

virtual lldb_private::ConstString
GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
virtual ConstString GetDIEClassTemplateParams(const DWARFDIE &die) = 0;

static std::optional<lldb_private::SymbolFile::ArrayInfo>
static std::optional<SymbolFile::ArrayInfo>
ParseChildArrayInfo(const DWARFDIE &parent_die,
const lldb_private::ExecutionContext *exe_ctx = nullptr);
const ExecutionContext *exe_ctx = nullptr);

static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
};
} // namespace dwarf
} // namespace lldb_private::plugin

#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::dwarf;
using namespace lldb_private::plugin::dwarf;

DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)
: m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}

Expand Down
Loading