Skip to content

Commit e15d6b5

Browse files
jwnhyMichael137
authored andcommitted
[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
1 parent 2cdb6b8 commit e15d6b5

File tree

2 files changed

+474
-2
lines changed

2 files changed

+474
-2
lines changed

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,12 @@ bool DWARFExpression::Evaluate(
14361436
return false;
14371437
} else {
14381438
stack.pop_back();
1439-
stack.back() =
1440-
stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx);
1439+
Scalar divisor, dividend;
1440+
divisor = tmp.ResolveValue(exe_ctx);
1441+
dividend = stack.back().ResolveValue(exe_ctx);
1442+
divisor.MakeSigned();
1443+
dividend.MakeSigned();
1444+
stack.back() = dividend / divisor;
14411445
if (!stack.back().ResolveValue(exe_ctx).IsValid()) {
14421446
if (error_ptr)
14431447
error_ptr->SetErrorString("Divide failed.");

0 commit comments

Comments
 (0)