[Lldb-commits] [lldb] r263604 - On some platforms, the compiler is allowed to assume that BOOL == bool. On others, BOOL == signed char.
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 15 16:38:05 PDT 2016
Author: enrico
Date: Tue Mar 15 18:38:04 2016
New Revision: 263604
URL: http://llvm.org/viewvc/llvm-project?rev=263604&view=rev
Log:
On some platforms, the compiler is allowed to assume that BOOL == bool. On others, BOOL == signed char.
This can cause differences in which bit patterns end up meaning YES or NO. In general, however, 0 == NO and 1 == YES.
To keep it simple, LLDB will now show "YES" and "NO" only for 1 and 0 respectively, and format other values as the plain numeric value instead.
Fixes rdar://24809994
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm
lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py?rev=263604&r1=263603&r2=263604&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py Tue Mar 15 18:38:04 2016
@@ -57,6 +57,8 @@ class DataFormatterBoolRefPtr(TestBase):
substrs = ['YES'])
self.expect('frame variable no_ref',
substrs = ['NO'])
+ self.expect('frame variable unset_ref',
+ substrs = ['12'])
# Now check that we use the right summary for BOOL*
@@ -64,6 +66,8 @@ class DataFormatterBoolRefPtr(TestBase):
substrs = ['YES'])
self.expect('frame variable no_ptr',
substrs = ['NO'])
+ self.expect('frame variable unset_ptr',
+ substrs = ['12'])
# Now check that we use the right summary for BOOL
@@ -71,3 +75,5 @@ class DataFormatterBoolRefPtr(TestBase):
substrs = ['YES'])
self.expect('frame variable no',
substrs = ['NO'])
+ self.expect('frame variable unset',
+ substrs = ['12'])
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm?rev=263604&r1=263603&r2=263604&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm Tue Mar 15 18:38:04 2016
@@ -11,17 +11,19 @@
int main (int argc, const char * argv[])
{
-
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
BOOL yes = YES;
BOOL no = NO;
+ BOOL unset = 12;
BOOL &yes_ref = yes;
BOOL &no_ref = no;
+ BOOL &unset_ref = unset;
BOOL* yes_ptr = &yes;
BOOL* no_ptr = &no;
+ BOOL* unset_ptr = &unset;
[pool drain];// Set break point at this line.
return 0;
Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=263604&r1=263603&r2=263604&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Tue Mar 15 18:38:04 2016
@@ -870,13 +870,19 @@ lldb_private::formatters::ObjCBOOLSummar
if (!real_guy_sp)
return false;
}
- uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
- if (value == 0)
+ uint8_t value = (real_guy_sp->GetValueAsUnsigned(0) & 0xFF);
+ switch (value)
{
- stream.Printf("NO");
- return true;
+ case 0:
+ stream.Printf("NO");
+ break;
+ case 1:
+ stream.Printf("YES");
+ break;
+ default:
+ stream.Printf("%u",value);
+ break;
}
- stream.Printf("YES");
return true;
}
More information about the lldb-commits
mailing list