summaryrefslogtreecommitdiff
path: root/lldb/source
diff options
context:
space:
mode:
authorLU Hongyi <hluaw@connect.ust.hk>2023-05-05 06:42:17 -0400
committerMichael Buch <michaelbuch12@gmail.com>2023-05-05 06:45:07 -0400
commit16c2872d7b09eee67dd0c7ef6b5dd3c3724d3cfc (patch)
tree3eeebf3919e75d58a9dd508c0567a3e5c197238c /lldb/source
parentf9dd3ea475e467d42bd3a3ff28c9aa384fe75549 (diff)
downloadllvm-16c2872d7b09eee67dd0c7ef6b5dd3c3724d3cfc.tar.gz
Reland "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"
This patch resolves an issue where a value is incorrectly displayed if it is represented by DW_OP_div. This issue is caused by lldb evaluating operands of DW_OP_div as unsigned and performed unintended unsigned division. This issue is resolved by creating two temporary signed scalar and performing signed division. (Addresses GH#61727) Differential Revision: https://reviews.llvm.org/D147370
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index f2ca6534c2fc..9232282d8135 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1436,8 +1436,12 @@ bool DWARFExpression::Evaluate(
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.");