/// \param[in] data
/// A data extractor configured to read the DWARF location expression's
/// bytecode.
- ///
- /// \param[in] data_offset
- /// The offset of the location expression in the extractor.
- ///
- /// \param[in] data_length
- /// The byte length of the location expression.
DWARFExpression(lldb::ModuleSP module, const DataExtractor &data,
- const DWARFUnit *dwarf_cu, lldb::offset_t data_offset,
- lldb::offset_t data_length);
+ const DWARFUnit *dwarf_cu);
/// Destructor
virtual ~DWARFExpression();
/// in the case where an expression needs to be evaluated while building
/// the stack frame list, this short-cut is available.
///
- /// \param[in] offset
- /// The offset of the location expression in the data extractor.
- ///
- /// \param[in] length
- /// The length in bytes of the location expression.
- ///
/// \param[in] reg_set
/// The call-frame-info style register kind.
///
/// details of the failure are provided through it.
static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
- const DWARFUnit *dwarf_cu, const lldb::offset_t offset,
- const lldb::offset_t length,
+ const DWARFUnit *dwarf_cu,
const lldb::RegisterKind reg_set,
const Value *initial_value_ptr,
const Value *object_address_ptr, Value &result,
DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp,
const DataExtractor &data,
- const DWARFUnit *dwarf_cu,
- lldb::offset_t data_offset,
- lldb::offset_t data_length)
- : m_module_wp(), m_data(data, data_offset, data_length),
- m_dwarf_cu(dwarf_cu), m_reg_kind(eRegisterKindDWARF),
- m_loclist_slide(LLDB_INVALID_ADDRESS) {
+ const DWARFUnit *dwarf_cu)
+ : m_module_wp(), m_data(data), m_dwarf_cu(dwarf_cu),
+ m_reg_kind(eRegisterKindDWARF), m_loclist_slide(LLDB_INVALID_ADDRESS) {
if (module_sp)
m_module_wp = module_sp;
}
if (length > 0 && lo_pc <= pc && pc < hi_pc) {
return DWARFExpression::Evaluate(
- exe_ctx, reg_ctx, module_sp, m_data, m_dwarf_cu, offset, length,
- m_reg_kind, initial_value_ptr, object_address_ptr, result,
- error_ptr);
+ exe_ctx, reg_ctx, module_sp,
+ DataExtractor(m_data, offset, length), m_dwarf_cu, m_reg_kind,
+ initial_value_ptr, object_address_ptr, result, error_ptr);
}
offset += length;
}
}
// Not a location list, just a single expression.
- return DWARFExpression::Evaluate(
- exe_ctx, reg_ctx, module_sp, m_data, m_dwarf_cu, 0, m_data.GetByteSize(),
- m_reg_kind, initial_value_ptr, object_address_ptr, result, error_ptr);
+ return DWARFExpression::Evaluate(exe_ctx, reg_ctx, module_sp, m_data,
+ m_dwarf_cu, m_reg_kind, initial_value_ptr,
+ object_address_ptr, result, error_ptr);
}
bool DWARFExpression::Evaluate(
ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
- const DWARFUnit *dwarf_cu, const lldb::offset_t opcodes_offset,
- const lldb::offset_t opcodes_length, const lldb::RegisterKind reg_kind,
+ const DWARFUnit *dwarf_cu, const lldb::RegisterKind reg_kind,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) {
- if (opcodes_length == 0) {
+ if (opcodes.GetByteSize() == 0) {
if (error_ptr)
error_ptr->SetErrorString(
"no location, value may have been optimized out");
if (initial_value_ptr)
stack.push_back(*initial_value_ptr);
- lldb::offset_t offset = opcodes_offset;
- const lldb::offset_t end_offset = opcodes_offset + opcodes_length;
+ lldb::offset_t offset = 0;
Value tmp;
uint32_t reg_num;
uint64_t op_piece_offset = 0;
Value pieces; // Used for DW_OP_piece
- // Make sure all of the data is available in opcodes.
- if (!opcodes.ValidOffsetForDataOfSize(opcodes_offset, opcodes_length)) {
- if (error_ptr)
- error_ptr->SetErrorString(
- "invalid offset and/or length for opcodes buffer.");
- return false;
- }
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- while (opcodes.ValidOffset(offset) && offset < end_offset) {
+ while (opcodes.ValidOffset(offset)) {
const lldb::offset_t op_offset = offset;
const uint8_t op = opcodes.GetU8(&offset);
case DW_OP_skip: {
int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
lldb::offset_t new_offset = offset + skip_offset;
- if (new_offset >= opcodes_offset && new_offset < end_offset)
+ if (opcodes.ValidOffset(new_offset))
offset = new_offset;
else {
if (error_ptr)
Scalar zero(0);
if (tmp.ResolveValue(exe_ctx) != zero) {
lldb::offset_t new_offset = offset + bra_offset;
- if (new_offset >= opcodes_offset && new_offset < end_offset)
+ if (opcodes.ValidOffset(new_offset))
offset = new_offset;
else {
if (error_ptr)
process->GetByteOrder(),
process->GetAddressByteSize());
ModuleSP opcode_ctx;
- DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
- unwindplan_regloc.GetDWARFExpressionLength());
+ DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
dwarfexpr.SetRegisterKind(unwindplan_registerkind);
Value cfa_val = Scalar(m_cfa);
cfa_val.SetValueType(Value::eValueTypeLoadAddress);
process->GetByteOrder(),
process->GetAddressByteSize());
ModuleSP opcode_ctx;
- DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
- fa.GetDWARFExpressionLength());
+ DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
dwarfexpr.SetRegisterKind(row_register_kind);
Value result;
Status error;
if (DWARFExpression::Evaluate(
nullptr, // ExecutionContext *
nullptr, // RegisterContext *
- module_sp, debug_info_data, die.GetCU(), block_offset,
- block_length, eRegisterKindDWARF, &initialValue,
- nullptr, memberOffset, nullptr)) {
+ module_sp,
+ DataExtractor(debug_info_data, block_offset,
+ block_length),
+ die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
+ memberOffset, nullptr)) {
member_byte_offset =
memberOffset.ResolveValue(nullptr).UInt();
}
uint32_t block_length = form_value.Unsigned();
uint32_t block_offset =
form_value.BlockData() - debug_info_data.GetDataStart();
- if (DWARFExpression::Evaluate(nullptr, nullptr, module_sp,
- debug_info_data, die.GetCU(),
- block_offset, block_length,
- eRegisterKindDWARF, &initialValue,
- nullptr, memberOffset, nullptr)) {
+ if (DWARFExpression::Evaluate(
+ nullptr, nullptr, module_sp,
+ DataExtractor(debug_info_data, block_offset,
+ block_length),
+ die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
+ memberOffset, nullptr)) {
member_byte_offset =
memberOffset.ResolveValue(nullptr).UInt();
}
uint32_t block_offset =
form_value.BlockData() - data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- *frame_base = DWARFExpression(module, data, cu,
- block_offset, block_length);
+ *frame_base = DWARFExpression(
+ module, DataExtractor(data, block_offset, block_length), cu);
} else {
const DWARFDataExtractor &debug_loc_data = dwarf.DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
size_t loc_list_length = DWARFExpression::LocationListSize(
cu, debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
- *frame_base =
- DWARFExpression(module, debug_loc_data, cu,
- debug_loc_offset, loc_list_length);
+ *frame_base = DWARFExpression(module,
+ DataExtractor(debug_loc_data,
+ debug_loc_offset,
+ loc_list_length),
+ cu);
if (lo_pc != LLDB_INVALID_ADDRESS) {
assert(lo_pc >= cu->GetBaseAddress());
frame_base->SetLocationListSlide(lo_pc -
uint32_t block_offset =
form_value.BlockData() - debug_info_data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- location = DWARFExpression(module, debug_info_data, die.GetCU(),
- block_offset, block_length);
+ location = DWARFExpression(
+ module,
+ DataExtractor(debug_info_data, block_offset, block_length),
+ die.GetCU());
} else if (DWARFFormValue::IsDataForm(form_value.Form())) {
// Retrieve the value as a data expression.
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
if (auto data_length = form_value.GetFixedSize())
- location =
- DWARFExpression(module, debug_info_data, die.GetCU(),
- data_offset, *data_length);
+ location = DWARFExpression(
+ module,
+ DataExtractor(debug_info_data, data_offset, *data_length),
+ die.GetCU());
else {
const uint8_t *data_pointer = form_value.BlockData();
if (data_pointer) {
if (form_value.Form() == DW_FORM_strp) {
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
if (auto data_length = form_value.GetFixedSize())
- location =
- DWARFExpression(module, debug_info_data, die.GetCU(),
- data_offset, *data_length);
+ location = DWARFExpression(module,
+ DataExtractor(debug_info_data,
+ data_offset,
+ *data_length),
+ die.GetCU());
} else {
const char *str = form_value.AsCString();
uint32_t string_offset =
str - (const char *)debug_info_data.GetDataStart();
uint32_t string_length = strlen(str) + 1;
- location =
- DWARFExpression(module, debug_info_data, die.GetCU(),
- string_offset, string_length);
+ location = DWARFExpression(module,
+ DataExtractor(debug_info_data,
+ string_offset,
+ string_length),
+ die.GetCU());
}
}
}
uint32_t block_offset =
form_value.BlockData() - data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- location = DWARFExpression(module, data, die.GetCU(),
- block_offset, block_length);
+ location = DWARFExpression(
+ module, DataExtractor(data, block_offset, block_length),
+ die.GetCU());
} else {
const DWARFDataExtractor &debug_loc_data = DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
size_t loc_list_length = DWARFExpression::LocationListSize(
die.GetCU(), debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
- location = DWARFExpression(module, debug_loc_data, die.GetCU(),
- debug_loc_offset, loc_list_length);
+ location = DWARFExpression(module,
+ DataExtractor(debug_loc_data,
+ debug_loc_offset,
+ loc_list_length),
+ die.GetCU());
assert(func_low_pc != LLDB_INVALID_ADDRESS);
location.SetLocationListSlide(
func_low_pc -
DataBufferSP buffer =
std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
DataExtractor extractor(buffer, byte_order, address_size, byte_size);
- DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+ DWARFExpression result(module, extractor, nullptr);
result.SetRegisterKind(register_kind);
return result;
.take_front(size);
buffer->CopyData(bytes.data(), size);
DataExtractor extractor(buffer, lldb::eByteOrderLittle, address_size);
- DWARFExpression result(nullptr, extractor, nullptr, 0, size);
+ DWARFExpression result(nullptr, extractor, nullptr);
return result;
}
DataBufferSP buffer =
std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
DataExtractor extractor(buffer, byte_order, address_size, byte_size);
- DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+ DWARFExpression result(module, extractor, nullptr);
result.SetRegisterKind(register_kind);
return result;
DataExtractor dwarf_data(dwarf_opcode_ptr, dwarf_opcode_len,
arch.GetByteOrder(), addr_size);
ModuleSP opcode_ctx;
- DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr, 0,
- dwarf_opcode_len);
+ DWARFExpression dwarf_expr(opcode_ctx, dwarf_data, nullptr);
Value result;
Status error;
- const lldb::offset_t offset = 0;
if (dwarf_expr.Evaluate(&exe_ctx, this, opcode_ctx, dwarf_data, nullptr,
- offset, dwarf_opcode_len, eRegisterKindDWARF, nullptr,
- nullptr, result, &error)) {
+ eRegisterKindDWARF, nullptr, nullptr, result,
+ &error)) {
expr_result = result.GetScalar().SInt(-1);
switch (expr_result) {
case 0:
Status status;
if (!DWARFExpression::Evaluate(
/*exe_ctx*/ nullptr, /*reg_ctx*/ nullptr, /*opcode_ctx*/ nullptr,
- extractor, /*dwarf_cu*/ nullptr, /*offset*/ 0, expr.size(),
- lldb::eRegisterKindLLDB, /*initial_value_ptr*/ nullptr,
+ extractor, /*dwarf_cu*/ nullptr, lldb::eRegisterKindLLDB,
+ /*initial_value_ptr*/ nullptr,
/*object_address_ptr*/ nullptr, result, &status))
return status.ToError();