[Lldb-commits] [lldb] r147332 - in /lldb/trunk: include/lldb/Core/Scalar.h source/Core/Scalar.cpp source/Core/ValueObject.cpp test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
Greg Clayton
gclayton at apple.com
Wed Dec 28 17:26:57 PST 2011
Author: gclayton
Date: Wed Dec 28 19:26:56 2011
New Revision: 147332
URL: http://llvm.org/viewvc/llvm-project?rev=147332&view=rev
Log:
<rdar://problem/10546739>
Fixed SBValue::GetValueAsUnsigned() and SBValue::GetValueAsSigned() calls to
work for bitfields.
Modified:
lldb/trunk/include/lldb/Core/Scalar.h
lldb/trunk/source/Core/Scalar.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
Modified: lldb/trunk/include/lldb/Core/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=147332&r1=147331&r2=147332&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Scalar.h (original)
+++ lldb/trunk/include/lldb/Core/Scalar.h Wed Dec 28 19:26:56 2011
@@ -57,6 +57,10 @@
bool
SignExtend (uint32_t bit_pos);
+ bool
+ ExtractBitfield (uint32_t bit_size,
+ uint32_t bit_offset);
+
size_t
GetByteSize() const;
Modified: lldb/trunk/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=147332&r1=147331&r2=147332&view=diff
==============================================================================
--- lldb/trunk/source/Core/Scalar.cpp (original)
+++ lldb/trunk/source/Core/Scalar.cpp Wed Dec 28 19:26:56 2011
@@ -17,6 +17,8 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Host/Endian.h"
+#include "Plugins/Process/Utility/InstructionUtils.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -2018,6 +2020,85 @@
}
bool
+Scalar::ExtractBitfield (uint32_t bit_size,
+ uint32_t bit_offset)
+{
+ if (bit_size == 0)
+ return true;
+
+ uint32_t msbit = bit_offset + bit_size - 1;
+ uint32_t lsbit = bit_offset;
+ switch (m_type)
+ {
+ default:
+ case Scalar::e_void:
+ break;
+
+ case e_float:
+ if (sizeof(m_data.flt) == sizeof(int))
+ m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+ else if (sizeof(m_data.flt) == sizeof(unsigned long))
+ m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+ else if (sizeof(m_data.flt) == sizeof(unsigned long long))
+ m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ else
+ return false;
+ return true;
+
+ case e_double:
+ if (sizeof(m_data.dbl) == sizeof(int))
+ m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+ else if (sizeof(m_data.dbl) == sizeof(unsigned long))
+ m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+ else if (sizeof(m_data.dbl) == sizeof(unsigned long long))
+ m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ else
+ return false;
+ return true;
+
+ case e_long_double:
+ if (sizeof(m_data.ldbl) == sizeof(int))
+ m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+ else if (sizeof(m_data.ldbl) == sizeof(unsigned long))
+ m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+ else if (sizeof(m_data.ldbl) == sizeof(unsigned long long))
+ m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ else
+ return false;
+ return true;
+
+ case Scalar::e_sint:
+ m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+ return true;
+
+ case Scalar::e_uint:
+ m_data.uint = UnsignedBits (m_data.uint, msbit, lsbit);
+ return true;
+
+ case Scalar::e_slong:
+ m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+ return true;
+
+ case Scalar::e_ulong:
+ m_data.ulong = SignedBits (m_data.ulong, msbit, lsbit);
+ return true;
+
+ case Scalar::e_slonglong:
+ m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ return true;
+
+ case Scalar::e_ulonglong:
+ m_data.ulonglong = SignedBits (m_data.ulonglong, msbit, lsbit);
+ return true;
+ }
+ return false;
+}
+
+
+
+
+
+bool
lldb_private::operator== (const Scalar& lhs, const Scalar& rhs)
{
// If either entry is void then we can just compare the types
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=147332&r1=147331&r2=147332&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Dec 28 19:26:56 2011
@@ -359,10 +359,15 @@
exe_scope->CalculateExecutionContext(exe_ctx);
Value tmp_value(m_value);
scalar = tmp_value.ResolveValue(&exe_ctx, GetClangAST ());
- return scalar.IsValid();
+ if (scalar.IsValid())
+ {
+ const uint32_t bitfield_bit_size = GetBitfieldBitSize();
+ if (bitfield_bit_size)
+ return scalar.ExtractBitfield (bitfield_bit_size, GetBitfieldBitOffset());
+ return true;
+ }
}
- else
- return false;
+ return false;
}
bool
Modified: lldb/trunk/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py?rev=147332&r1=147331&r2=147332&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py (original)
+++ lldb/trunk/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py Wed Dec 28 19:26:56 2011
@@ -80,9 +80,9 @@
self.assertTrue (flag2_value == 7)
# GetValueAsUnsigned fails for bit-fields:
-# flag2_value = mine_flag2.GetValueAsUnsigned (error)
-# self.assertTrue (error.Success())
-# self.assertTrue (flag2_value == 7)
+ flag2_value = mine_flag2.GetValueAsUnsigned (error)
+ self.assertTrue (error.Success())
+ self.assertTrue (flag2_value == 7)
if __name__ == '__main__':
import atexit
More information about the lldb-commits
mailing list