[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div
LU Hongyi via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Apr 1 19:31:06 PDT 2023
jwnhy updated this revision to Diff 510285.
jwnhy added a comment.
Update the patch to include a small
regression test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147370/new/
https://reviews.llvm.org/D147370
Files:
lldb/source/Expression/DWARFExpression.cpp
lldb/test/API/commands/expression/signed-dw-op-div/Makefile
lldb/test/API/commands/expression/signed-dw-op-div/TestSignedDiv.py
lldb/test/API/commands/expression/signed-dw-op-div/main.c
Index: lldb/test/API/commands/expression/signed-dw-op-div/main.c
===================================================================
--- /dev/null
+++ lldb/test/API/commands/expression/signed-dw-op-div/main.c
@@ -0,0 +1,14 @@
+#include "stdint.h"
+static volatile uint64_t g = 0;
+
+static const int32_t f() {
+ uint32_t i;
+ for (i = 0; (i != 10); i++)
+ ++g; // break here
+ return 0;
+}
+
+int main() {
+ f();
+ return 0;
+}
Index: lldb/test/API/commands/expression/signed-dw-op-div/TestSignedDiv.py
===================================================================
--- /dev/null
+++ lldb/test/API/commands/expression/signed-dw-op-div/TestSignedDiv.py
@@ -0,0 +1,14 @@
+"""Test that we can print values that represented via DW_OP_div"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class SignedDivTestCase(TestBase):
+ def test_signed_div(self):
+ """Test that we can print values that represented via DW_OP_div"""
+ self.build()
+ _, process, _, bkpt = lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec('main.c'))
+ self.expect_expr('i', result_type='uint32_t', result_value='0')
+ for i in range(1, 10):
+ lldbutil.continue_to_breakpoint(process, bkpt)
+ self.expect_expr('i', result_type='uint32_t', result_value=str(i))
Index: lldb/test/API/commands/expression/signed-dw-op-div/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/commands/expression/signed-dw-op-div/Makefile
@@ -0,0 +1,4 @@
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -g -O1
+
+include Makefile.rules
Index: lldb/source/Expression/DWARFExpression.cpp
===================================================================
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1436,8 +1436,12 @@
return false;
} else {
stack.pop_back();
- stack.back() =
- stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx);
+ Scalar divisor, dividend;
+ divisor = tmp.ResolveValue(exe_ctx);
+ dividend = stack.back().ResolveValue(exe_ctx);
+ divisor.MakeSigned();
+ dividend.MakeSigned();
+ stack.back() = dividend / divisor;
if (!stack.back().ResolveValue(exe_ctx).IsValid()) {
if (error_ptr)
error_ptr->SetErrorString("Divide failed.");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147370.510285.patch
Type: text/x-patch
Size: 2453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230402/e6ef8340/attachment.bin>
More information about the lldb-commits
mailing list