[Lldb-commits] [lldb] r170161 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
Enrico Granata
egranata at apple.com
Thu Dec 13 15:50:33 PST 2012
Author: enrico
Date: Thu Dec 13 17:50:33 2012
New Revision: 170161
URL: http://llvm.org/viewvc/llvm-project?rev=170161&view=rev
Log:
<rdar://problem/11689939>
Supporting a compact display syntax for ObjC pointers where 0x00.....0 is replaced by a much more legible "nil"
e.g. this would show:
(NSArray *) $2 = nil
instead of:
(NSArray *) $2 = 0x0000000000000000 <nil>
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
lldb/trunk/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=170161&r1=170160&r2=170161&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Dec 13 17:50:33 2012
@@ -613,6 +613,9 @@
IsPossibleDynamicType ();
virtual bool
+ IsObjCNil ();
+
+ virtual bool
IsBaseClass ()
{
return false;
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=170161&r1=170160&r2=170161&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Dec 13 17:50:33 2012
@@ -1823,6 +1823,15 @@
return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType(), NULL, true, true);
}
+bool
+ValueObject::IsObjCNil ()
+{
+ bool isObjCpointer = ClangASTContext::IsObjCObjectPointerType(GetClangType(), NULL);
+ bool canReadValue = true;
+ bool isZero = GetValueAsUnsigned(0,&canReadValue) == 0;
+ return canReadValue && isZero && isObjCpointer;
+}
+
ValueObjectSP
ValueObject::GetSyntheticArrayMember (int32_t index, bool can_create)
{
@@ -3308,6 +3317,8 @@
if (options.m_omit_summary_depth > 0)
entry = NULL;
+ bool is_nil = valobj->IsObjCNil();
+
if (err_cstr == NULL)
{
if (options.m_format != eFormatDefault && options.m_format != valobj->GetFormat())
@@ -3333,7 +3344,9 @@
const bool is_ref = type_flags.Test (ClangASTContext::eTypeIsReference);
if (print_valobj)
{
- if (options.m_omit_summary_depth == 0)
+ if (is_nil)
+ sum_cstr = "nil";
+ else if (options.m_omit_summary_depth == 0)
{
if (options.m_summary_sp)
{
@@ -3345,14 +3358,16 @@
}
// Make sure we have a value and make sure the summary didn't
- // specify that the value should not be printed
- if (!value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL))
+ // specify that the value should not be printed - and do not print
+ // the value if this thing is nil
+ if (!is_nil && !value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL))
s.Printf(" %s", value_str.c_str());
if (sum_cstr)
s.Printf(" %s", sum_cstr);
- if (options.m_use_objc)
+ // let's avoid the overly verbose no description error for a nil thing
+ if (options.m_use_objc && !is_nil)
{
const char *object_desc = valobj->GetObjectDescription();
if (object_desc)
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=170161&r1=170160&r2=170161&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Thu Dec 13 17:50:33 2012
@@ -380,7 +380,7 @@
self.expect('frame variable myclass4',
substrs = ['(Class) myclass4 = NSMutableArray'])
self.expect('frame variable myclass5',
- substrs = ['(Class) myclass5 = <error: unknown Class>'])
+ substrs = ['(Class) myclass5 = nil'])
def expr_objc_data_formatter_commands(self):
Modified: lldb/trunk/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py?rev=170161&r1=170160&r2=170161&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py (original)
+++ lldb/trunk/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py Thu Dec 13 17:50:33 2012
@@ -62,7 +62,7 @@
self.expect("expr (foo)", patterns = ["\(ns::id\) \$.* = 0"])
- self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = 0x0"])
+ self.expect("expr id my_id = 0; my_id", patterns = ["\(id\) \$.* = nil"])
if __name__ == '__main__':
import atexit
More information about the lldb-commits
mailing list