Skip to content

Commit

Permalink
[lldb][DWARFExpression] Fix DW_OP_div to use signed division
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jwnhy authored and Michael137 committed May 2, 2023
1 parent 2cdb6b8 commit e15d6b5
Show file tree
Hide file tree
Showing 2 changed files with 474 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
Loading

0 comments on commit e15d6b5

Please sign in to comment.