[Lldb-commits] [lldb] [lldb] Store proper integer bitwidth in Scalar Type (PR #81451)

via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 12 00:46:34 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Kamlesh Kumar (kamleshbhalui)

<details>
<summary>Changes</summary>

Storing Larger bitwidth causes problem when byteswapping.

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


1 Files Affected:

- (modified) lldb/source/Expression/DWARFExpression.cpp (+12-4) 


``````````diff
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index fe4928d4f43a43..1546612be34ac7 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -857,10 +857,18 @@ static Scalar DerefSizeExtractDataHelper(uint8_t *addr_bytes,
   DataExtractor addr_data(addr_bytes, size_addr_bytes, byte_order, size);
 
   lldb::offset_t addr_data_offset = 0;
-  if (size <= 8)
-    return addr_data.GetMaxU64(&addr_data_offset, size);
-  else
-    return addr_data.GetAddress(&addr_data_offset);
+  switch (size) {
+  case 1:
+    return addr_data.GetU8(&addr_data_offset);
+  case 2:
+    return addr_data.GetU16(&addr_data_offset);
+  case 4:
+    return addr_data.GetU32(&addr_data_offset);
+  case 8:
+    return addr_data.GetU64(&addr_data_offset);
+  default:
+     return addr_data.GetAddress(&addr_data_offset);
+  }
 }
 
 bool DWARFExpression::Evaluate(

``````````

</details>


https://github.com/llvm/llvm-project/pull/81451


More information about the lldb-commits mailing list