diff options
author | Adrian Prantl <aprantl@apple.com> | 2019-08-07 22:40:05 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2019-08-07 22:40:05 +0000 |
commit | f81d6fe75ca17bd3a5153a0d7bae853b977c5ea2 (patch) | |
tree | b281b31107e46a444e73d030037061121327fbcf /lldb/source/Core/ValueObjectChild.cpp | |
parent | beb5150f478d4b9f25bb300430f21dedc0c3b9e4 (diff) | |
download | bcm5719-llvm-f81d6fe75ca17bd3a5153a0d7bae853b977c5ea2.tar.gz bcm5719-llvm-f81d6fe75ca17bd3a5153a0d7bae853b977c5ea2.zip |
Adjust a ValueObjectChild's offset when the child is a bitfield
If a bitfield doesn't fit into the child_byte_size'd window at
child_byte_offset, move the window forward until it fits. The problem
here is that Value has no notion of bitfields and thus the Value's
DataExtractor is sized like the bitfields CompilerType; a sequence of
bitfields, however, can be larger than their underlying type.
This was not in the big-endian-derived DWARF 2 bitfield attributes
because their offsets were counted from the end of the window, so they
always fit.
rdar://problem/53132189
Differential Revision: https://reviews.llvm.org/D65492
llvm-svn: 368226
Diffstat (limited to 'lldb/source/Core/ValueObjectChild.cpp')
-rw-r--r-- | lldb/source/Core/ValueObjectChild.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index 01f2e20dd0b..c8b3a9dc1cf 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -175,6 +175,30 @@ bool ValueObjectChild::UpdateValue() { // Set this object's scalar value to the address of its value by // adding its byte offset to the parent address m_value.GetScalar() += GetByteOffset(); + + // If a bitfield doesn't fit into the child_byte_size'd + // window at child_byte_offset, move the window forward + // until it fits. The problem here is that Value has no + // notion of bitfields and thus the Value's DataExtractor + // is sized like the bitfields CompilerType; a sequence of + // bitfields, however, can be larger than their underlying + // type. + if (m_bitfield_bit_offset) { + const bool thread_and_frame_only_if_stopped = true; + ExecutionContext exe_ctx(GetExecutionContextRef().Lock( + thread_and_frame_only_if_stopped)); + if (auto type_bit_size = GetCompilerType().GetBitSize( + exe_ctx.GetBestExecutionContextScope())) { + uint64_t bitfield_end = + m_bitfield_bit_size + m_bitfield_bit_offset; + if (bitfield_end > *type_bit_size) { + uint64_t overhang_bytes = + (bitfield_end - *type_bit_size + 7) / 8; + m_value.GetScalar() += overhang_bytes; + m_bitfield_bit_offset -= overhang_bytes * 8; + } + } + } } } break; |