#include "lldb/Expression/DWARFExpression.h"
#include <cinttypes>
#include <optional>
#include <vector>
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Utility/DataEncoder.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/VMRange.h"
#include "lldb/Host/Host.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/StackID.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
usingnamespacelldb;
usingnamespacelldb_private;
usingnamespacelldb_private::dwarf;
usingnamespacelldb_private::plugin::dwarf;
DWARFExpression::DWARFExpression() : … { … }
DWARFExpression::DWARFExpression(const DataExtractor &data) : … { … }
DWARFExpression::~DWARFExpression() = default;
bool DWARFExpression::IsValid() const { … }
void DWARFExpression::UpdateValue(uint64_t const_value,
lldb::offset_t const_value_byte_size,
uint8_t addr_byte_size) { … }
void DWARFExpression::DumpLocation(Stream *s, lldb::DescriptionLevel level,
ABI *abi) const { … }
RegisterKind DWARFExpression::GetRegisterKind() const { … }
void DWARFExpression::SetRegisterKind(RegisterKind reg_kind) { … }
static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
lldb::RegisterKind reg_kind,
uint32_t reg_num, Value &value) { … }
static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
const lldb::offset_t data_offset,
const uint8_t op,
const DWARFUnit *dwarf_cu) { … }
lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu,
bool &error) const { … }
bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
lldb::addr_t file_addr) { … }
bool DWARFExpression::ContainsThreadLocalStorage(
const DWARFUnit *dwarf_cu) const { … }
bool DWARFExpression::LinkThreadLocalStorage(
const DWARFUnit *dwarf_cu,
std::function<lldb::addr_t(lldb::addr_t file_addr)> const
&link_address_callback) { … }
static llvm::Error Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
ExecutionContext *exe_ctx,
RegisterContext *reg_ctx,
const DataExtractor &opcodes,
lldb::offset_t &opcode_offset,
Log *log) { … }
namespace {
enum LocationDescriptionKind { … };
void UpdateValueTypeFromLocationDescription(Log *log, const DWARFUnit *dwarf_cu,
LocationDescriptionKind kind,
Value *value = nullptr) { … }
}
static llvm::Expected<lldb::addr_t>
ResolveLoadAddress(ExecutionContext *exe_ctx, lldb::ModuleSP &module_sp,
const char *dw_op_type, lldb::addr_t file_addr,
Address &so_addr, bool check_sectionoffset = false) { … }
static Scalar DerefSizeExtractDataHelper(uint8_t *addr_bytes,
size_t size_addr_bytes,
ByteOrder byte_order, size_t size) { … }
llvm::Expected<Value> DWARFExpression::Evaluate(
ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
const DWARFUnit *dwarf_cu, const lldb::RegisterKind reg_kind,
const Value *initial_value_ptr, const Value *object_address_ptr) { … }
bool DWARFExpression::ParseDWARFLocationList(
const DWARFUnit *dwarf_cu, const DataExtractor &data,
DWARFExpressionList *location_list) { … }
bool DWARFExpression::MatchesOperand(
StackFrame &frame, const Instruction::Operand &operand) const { … }