Revert "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (#116824)

Reverts llvm/llvm-project#116411
This commit is contained in:
Ilia Kuklin
2024-11-19 20:39:29 +05:00
committed by GitHub
parent 64e3466fd0
commit de6d1683d4
2 changed files with 3 additions and 39 deletions

View File

@@ -1853,25 +1853,12 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
const Value::ValueType curr_piece_source_value_type =
curr_piece_source_value.GetValueType();
Scalar &scalar = curr_piece_source_value.GetScalar();
lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
switch (curr_piece_source_value_type) {
case Value::ValueType::Invalid:
return llvm::createStringError("invalid value type");
case Value::ValueType::FileAddress:
if (target) {
curr_piece_source_value.ConvertToLoadAddress(module_sp.get(),
target);
addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
} else {
return llvm::createStringError(
"unable to convert file address 0x%" PRIx64
" to load address "
"for DW_OP_piece(%" PRIu64 "): "
"no target available",
addr, piece_byte_size);
}
[[fallthrough]];
case Value::ValueType::LoadAddress: {
case Value::ValueType::LoadAddress:
case Value::ValueType::FileAddress: {
if (target) {
if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),

View File

@@ -1,23 +0,0 @@
// Check that optimized with -O3 values that have a file address can be read
// DWARF info:
// 0x00000023: DW_TAG_variable
// DW_AT_name ("array")
// DW_AT_type (0x00000032 "char[5]")
// DW_AT_location (DW_OP_piece 0x2, DW_OP_addrx 0x0, DW_OP_piece 0x1)
// RUN: %clang_host -O3 -gdwarf %s -o %t
// RUN: %lldb %t \
// RUN: -o "b 22" \
// RUN: -o "r" \
// RUN: -o "p/x array[2]" \
// RUN: -b | FileCheck %s
//
// CHECK: (lldb) p/x array[2]
// CHECK: (char) 0x03
static char array[5] = {0, 1, 2, 3, 4};
int main(void) {
array[2]++;
return 0;
}