[Lldb-commits] [lldb] f55ab6f - Fix a buffer-size bug when the first DW_OP_piece is undefined
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 16 16:48:54 PST 2020
Author: Adrian Prantl
Date: 2020-01-16T16:47:59-08:00
New Revision: f55ab6f90b7317a6bb85303a6102702bdae1199e
URL: https://github.com/llvm/llvm-project/commit/f55ab6f90b7317a6bb85303a6102702bdae1199e
DIFF: https://github.com/llvm/llvm-project/commit/f55ab6f90b7317a6bb85303a6102702bdae1199e.diff
LOG: Fix a buffer-size bug when the first DW_OP_piece is undefined
and document the shortcomings of LLDB's partially defined DW_OP_piece
handling.
This would manifest as "DW_OP_piece for offset foo but top of stack is
of size bar".
rdar://problem/46262998
Differential Revision: https://reviews.llvm.org/D72880
Added:
Modified:
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 6af0f371d00e..e09b1a5dba49 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2071,6 +2071,10 @@ bool DWARFExpression::Evaluate(
// not available. Fill with zeros for now by resizing the data and
// appending it
curr_piece.ResizeData(piece_byte_size);
+ // Note that "0" is not a correct value for the unknown bits.
+ // It would be better to also return a mask of valid bits together
+ // with the expression result, so the debugger can print missing
+ // members as "<optimized out>" or something.
::memset(curr_piece.GetBuffer().GetBytes(), 0, piece_byte_size);
pieces.AppendDataToHostBuffer(curr_piece);
} else {
@@ -2193,8 +2197,8 @@ bool DWARFExpression::Evaluate(
return false;
}
}
- op_piece_offset += piece_byte_size;
}
+ op_piece_offset += piece_byte_size;
}
} break;
diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index fe5e9c957ba0..45876152f029 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -355,4 +355,9 @@ TEST(DWARFExpression, DW_OP_piece) {
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
llvm::HasValue(GetScalar(32, 0x44332211, true)));
+ EXPECT_THAT_EXPECTED(
+ Evaluate({DW_OP_piece, 1, DW_OP_const1u, 0xff, DW_OP_piece, 1}),
+ // Note that the "00" should really be "undef", but we can't
+ // represent that yet.
+ llvm::HasValue(GetScalar(16, 0xff00, true)));
}
More information about the lldb-commits
mailing list