Skip to content

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

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 1 commit into from
Nov 19, 2024

Conversation

kuilpd
Copy link
Contributor

@kuilpd kuilpd commented Nov 19, 2024

Reverts #116411

@kuilpd kuilpd requested a review from JDevlieghere as a code owner November 19, 2024 15:37
@llvmbot llvmbot added the lldb label Nov 19, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 19, 2024

@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)

Changes

Reverts llvm/llvm-project#116411


Full diff: https://github.com/llvm/llvm-project/pull/116824.diff

2 Files Affected:

  • (modified) lldb/source/Expression/DWARFExpression.cpp (+3-16)
  • (removed) lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c (-23)
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index a7126b25c1cc38..f92f25ed342a9c 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -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(),
diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
deleted file mode 100644
index d31250426dc112..00000000000000
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
+++ /dev/null
@@ -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;
-}
\ No newline at end of file

@kuilpd kuilpd merged commit de6d168 into main Nov 19, 2024
7 of 8 checks passed
@kuilpd kuilpd deleted the revert-116411-lldb-fix-fileaddress-in-DW_OP_piece branch November 19, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants