Skip to content

Commit

Permalink
Revert "[LLDB][NFC] Decouple dwarf location table from DWARFExpression."
Browse files Browse the repository at this point in the history
This reverts commit 227dffd and its
follow up 562c346 because it breaks a
bunch of tests on GreenDragon:

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45155/
  • Loading branch information
JDevlieghere committed Jul 7, 2022
1 parent a81cc1f commit e4c5bca
Show file tree
Hide file tree
Showing 33 changed files with 613 additions and 573 deletions.
128 changes: 114 additions & 14 deletions lldb/include/lldb/Expression/DWARFExpression.h
Expand Up @@ -42,14 +42,49 @@ class DWARFExpression {
/// \param[in] data
/// A data extractor configured to read the DWARF location expression's
/// bytecode.
DWARFExpression(const DataExtractor &data);
DWARFExpression(lldb::ModuleSP module, const DataExtractor &data,
const DWARFUnit *dwarf_cu);

/// Destructor
virtual ~DWARFExpression();

/// Print the description of the expression to a stream
///
/// \param[in] s
/// The stream to print to.
///
/// \param[in] level
/// The level of verbosity to use.
///
/// \param[in] abi
/// An optional ABI plug-in that can be used to resolve register
/// names.
void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const;

/// Return true if the location expression contains data
bool IsValid() const;

/// Return true if a location list was provided
bool IsLocationList() const;

/// Search for a load address in the location list
///
/// \param[in] func_load_addr
/// The actual address of the function containing this location list.
///
/// \param[in] addr
/// The address to resolve
///
/// \return
/// True if IsLocationList() is true and the address was found;
/// false otherwise.
// bool
// LocationListContainsLoadAddress (Process* process, const Address &addr)
// const;
//
bool LocationListContainsAddress(lldb::addr_t func_load_addr,
lldb::addr_t addr) const;

/// If a location is not a location list, return true if the location
/// contains a DW_OP_addr () opcode in the stream that matches \a file_addr.
/// If file_addr is LLDB_INVALID_ADDRESS, the this function will return true
Expand All @@ -58,9 +93,6 @@ class DWARFExpression {
/// static variable since there is no other indication from DWARF debug
/// info.
///
/// \param[in] dwarf_cu
/// The dwarf unit this expression belongs to.
///
/// \param[in] op_addr_idx
/// The DW_OP_addr index to retrieve in case there is more than
/// one DW_OP_addr opcode in the location byte stream.
Expand All @@ -72,29 +104,57 @@ class DWARFExpression {
/// \return
/// LLDB_INVALID_ADDRESS if the location doesn't contain a
/// DW_OP_addr for \a op_addr_idx, otherwise a valid file address
lldb::addr_t GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
uint32_t op_addr_idx, bool &error) const;
lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;

bool Update_DW_OP_addr(lldb::addr_t file_addr);

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

void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }

bool ContainsThreadLocalStorage() const;

bool LinkThreadLocalStorage(
lldb::ModuleSP new_module_sp,
std::function<lldb::addr_t(lldb::addr_t file_addr)> const
&link_address_callback);

/// Tells the expression that it refers to a location list.
///
/// \param[in] cu_file_addr
/// The base address to use for interpreting relative location list
/// entries.
/// \param[in] func_file_addr
/// The file address of the function containing this location list. This
/// address will be used to relocate the location list on the fly (in
/// conjuction with the func_load_addr arguments).
void SetLocationListAddresses(lldb::addr_t cu_file_addr,
lldb::addr_t func_file_addr);

/// Return the call-frame-info style register kind
lldb::RegisterKind GetRegisterKind() const;
int GetRegisterKind();

/// Set the call-frame-info style register kind
///
/// \param[in] reg_kind
/// The register kind.
void SetRegisterKind(lldb::RegisterKind reg_kind);

/// Wrapper for the static evaluate function that accepts an
/// ExecutionContextScope instead of an ExecutionContext and uses member
/// variables to populate many operands
bool Evaluate(ExecutionContextScope *exe_scope, lldb::addr_t func_load_addr,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) const;

/// Wrapper for the static evaluate function that uses member variables to
/// populate many operands
bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::addr_t loclist_base_load_addr,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) const;

/// Evaluate a DWARF location expression in a particular context
///
/// \param[in] exe_ctx
Expand Down Expand Up @@ -134,32 +194,72 @@ class DWARFExpression {
/// True on success; false otherwise. If error_ptr is non-NULL,
/// details of the failure are provided through it.
static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
const 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,
const DataExtractor &data,
DWARFExpressionList *loc_list);

bool GetExpressionData(DataExtractor &data) const {
data = m_data;
return data.GetByteSize() > 0;
}

void DumpLocation(Stream *s, lldb::DescriptionLevel level, ABI *abi) const;
bool DumpLocationForAddress(Stream *s, lldb::DescriptionLevel level,
lldb::addr_t func_load_addr, lldb::addr_t address,
ABI *abi);

bool DumpLocations(Stream *s, lldb::DescriptionLevel level,
lldb::addr_t func_load_addr, lldb::addr_t addr, ABI *abi);

bool GetLocationExpressions(
lldb::addr_t load_function_start,
llvm::function_ref<bool(llvm::DWARFLocationExpression)> callback) const;

bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op) const;
bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);

llvm::Optional<DataExtractor>
GetLocationExpression(lldb::addr_t load_function_start,
lldb::addr_t addr) const;

private:
/// Pretty-prints the location expression to a stream
///
/// \param[in] s
/// The stream to use for pretty-printing.
///
/// \param[in] data
/// The data extractor.
///
/// \param[in] level
/// The level of detail to use in pretty-printing.
///
/// \param[in] abi
/// An optional ABI plug-in that can be used to resolve register
/// names.
void DumpLocation(Stream *s, const DataExtractor &data,
lldb::DescriptionLevel level, ABI *abi) const;

/// Module which defined this expression.
lldb::ModuleWP m_module_wp;

/// A data extractor capable of reading opcode bytes
DataExtractor m_data;

/// 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;

/// One of the defines that starts with LLDB_REGKIND_
lldb::RegisterKind m_reg_kind = lldb::eRegisterKindDWARF;

struct LoclistAddresses {
lldb::addr_t cu_file_addr;
lldb::addr_t func_file_addr;
};
llvm::Optional<LoclistAddresses> m_loclist_addresses;
};

} // namespace lldb_private
Expand Down
132 changes: 0 additions & 132 deletions lldb/include/lldb/Expression/DWARFExpressionList.h

This file was deleted.

16 changes: 8 additions & 8 deletions lldb/include/lldb/Symbol/Function.h
Expand Up @@ -12,7 +12,7 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Declaration.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Expression/DWARFExpressionList.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Utility/UserID.h"
#include "llvm/ADT/ArrayRef.h"
Expand Down Expand Up @@ -253,8 +253,8 @@ class Function;
/// Represent the locations of a parameter at a call site, both in the caller
/// and in the callee.
struct CallSiteParameter {
DWARFExpressionList LocationInCallee;
DWARFExpressionList LocationInCaller;
DWARFExpression LocationInCallee;
DWARFExpression LocationInCaller;
};

/// A vector of \c CallSiteParameter.
Expand Down Expand Up @@ -370,7 +370,7 @@ class IndirectCallEdge : public CallEdge {
public:
/// Construct a call edge using a DWARFExpression to identify the callee, and
/// a return PC within the calling function to identify a specific call site.
IndirectCallEdge(DWARFExpressionList call_target, AddrType caller_address_type,
IndirectCallEdge(DWARFExpression call_target, AddrType caller_address_type,
lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
: CallEdge(caller_address_type, caller_address, is_tail_call,
Expand All @@ -383,7 +383,7 @@ class IndirectCallEdge : public CallEdge {
// Used to describe an indirect call.
//
// Specifies the location of the callee address in the calling frame.
DWARFExpressionList call_target;
DWARFExpression call_target;
};

/// \class Function Function.h "lldb/Symbol/Function.h"
Expand Down Expand Up @@ -521,13 +521,13 @@ class Function : public UserID, public SymbolContextScope {
/// \return
/// A location expression that describes the function frame
/// base.
DWARFExpressionList &GetFrameBaseExpression() { return m_frame_base; }
DWARFExpression &GetFrameBaseExpression() { return m_frame_base; }

/// Get const accessor for the frame base location.
///
/// \return
/// A const compile unit object pointer.
const DWARFExpressionList &GetFrameBaseExpression() const { return m_frame_base; }
const DWARFExpression &GetFrameBaseExpression() const { return m_frame_base; }

ConstString GetName() const;

Expand Down Expand Up @@ -659,7 +659,7 @@ class Function : public UserID, public SymbolContextScope {

/// The frame base expression for variables that are relative to the frame
/// pointer.
DWARFExpressionList m_frame_base;
DWARFExpression m_frame_base;

Flags m_flags;

Expand Down

0 comments on commit e4c5bca

Please sign in to comment.