diff options
author | Enrico Granata <egranata@apple.com> | 2016-02-10 02:12:42 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-02-10 02:12:42 +0000 |
commit | 14086ed75d165b827b20de0101324bd8467d93c4 (patch) | |
tree | 0d111f6e46db8114e2e212db26b93d05ef6b0777 /lldb/packages/Python/lldbsuite/test/python_api/value | |
parent | 4abe94fb6b215d5342816f189fa18988e829441a (diff) | |
download | bcm5719-llvm-14086ed75d165b827b20de0101324bd8467d93c4.tar.gz bcm5719-llvm-14086ed75d165b827b20de0101324bd8467d93c4.zip |
Change lldb.value.__int__() so that it takes into account the signedness of the value being cast to return a Python number with the proper value
The explicit APIs on SBValue obviously remain if one wants to be explicit in intent, or override this guess, but since __int__() has to pick one, an educated guess is definitely better than than always going to signed regardless
Fixes rdar://24556976
llvm-svn: 260349
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/value')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py | 9 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/value/main.c | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py index 11b5d3c890a..2a53177d28a 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -134,3 +134,12 @@ class ValueAPITestCase(TestBase): val_a = target.EvaluateExpression('a') self.assertTrue(val_s.GetChildMemberWithName('a').AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) + + self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex'))) == 3768803088, 'uinthex == 3768803088') + self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex'))) == -526164208, 'sinthex == -526164208') + + self.assertTrue(frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088, 'unsigned uinthex == 3768803088') + self.assertTrue(frame0.FindVariable('sinthex').GetValueAsUnsigned() == 3768803088, 'unsigned sinthex == 3768803088') + + self.assertTrue(frame0.FindVariable('uinthex').GetValueAsSigned() == -526164208, 'signed uinthex == -526164208') + self.assertTrue(frame0.FindVariable('sinthex').GetValueAsSigned() == -526164208, 'signed sinthex == -526164208') diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/main.c b/lldb/packages/Python/lldbsuite/test/python_api/value/main.c index a00795750de..2ebe3ad303c 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/value/main.c +++ b/lldb/packages/Python/lldbsuite/test/python_api/value/main.c @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// #include <stdio.h> +#include <stdint.h> // This simple program is to test the lldb Python API SBValue.GetChildAtIndex(). @@ -38,6 +39,9 @@ struct MyStruct int main (int argc, char const *argv[]) { + uint32_t uinthex = 0xE0A35F10; + int32_t sinthex = 0xE0A35F10; + int i; MyInt a = 12345; struct MyStruct s = { 11, 22 }; |