summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2020-01-16 14:21:03 -0800
committerHans Wennborg <hans@chromium.org>2020-02-19 14:20:33 +0100
commit7751f0c191518b377d9b71bdd17281abec83945a (patch)
tree0ccae336d37723d00d0053ec2dd0ce0d0ca7d5ec /lldb/source
parentd5f8656a68c25e93c5c8f03e0670fecb16609d40 (diff)
downloadbcm5719-llvm-7751f0c191518b377d9b71bdd17281abec83945a.tar.gz
bcm5719-llvm-7751f0c191518b377d9b71bdd17281abec83945a.zip
Add testing for DW_OP_piece and fix a bug with small Scalar values.
By switching to Scalars that are backed by explicitly-sized APInts we can avoid a bug that increases the buffer reserved for a small piece to the next-largest host integer type. This manifests as "DW_OP_piece for offset foo but top of stack is of size bar". Differential Revision: https://reviews.llvm.org/D72879 (cherry picked from commit 7b0d58e339b271e3b1d9dc14b781b57fa0262e3a)
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 69c84640ef9..0f8eea754c2 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2128,7 +2128,8 @@ bool DWARFExpression::Evaluate(
case Value::eValueTypeScalar: {
uint32_t bit_size = piece_byte_size * 8;
uint32_t bit_offset = 0;
- if (!curr_piece_source_value.GetScalar().ExtractBitfield(
+ Scalar &scalar = curr_piece_source_value.GetScalar();
+ if (!scalar.ExtractBitfield(
bit_size, bit_offset)) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
@@ -2139,7 +2140,14 @@ bool DWARFExpression::Evaluate(
.GetByteSize());
return false;
}
- curr_piece = curr_piece_source_value;
+ // Create curr_piece with bit_size. By default Scalar
+ // grows to the nearest host integer type.
+ llvm::APInt fail_value(1, 0, false);
+ llvm::APInt ap_int = scalar.UInt128(fail_value);
+ assert(ap_int.getBitWidth() >= bit_size);
+ llvm::ArrayRef<uint64_t> buf{ap_int.getRawData(),
+ ap_int.getNumWords()};
+ curr_piece.GetScalar() = Scalar(llvm::APInt(bit_size, buf));
} break;
case Value::eValueTypeVector: {
@@ -2161,7 +2169,7 @@ bool DWARFExpression::Evaluate(
if (op_piece_offset == 0) {
// This is the first piece, we should push it back onto the stack
// so subsequent pieces will be able to access this piece and add
- // to it
+ // to it.
if (pieces.AppendDataToHostBuffer(curr_piece) == 0) {
if (error_ptr)
error_ptr->SetErrorString("failed to append piece data");
@@ -2169,7 +2177,7 @@ bool DWARFExpression::Evaluate(
}
} else {
// If this is the second or later piece there should be a value on
- // the stack
+ // the stack.
if (pieces.GetBuffer().GetByteSize() != op_piece_offset) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
OpenPOWER on IntegriCloud