[Lldb-commits] [lldb] r161592 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Commands/CommandObjectExpression.cpp source/Core/ValueObject.cpp test/lang/objc/foundation/TestObjCMethods2.py test/lang/objc/print-obj/TestPrintObj.py

Enrico Granata egranata at apple.com
Thu Aug 9 09:51:26 PDT 2012


Author: enrico
Date: Thu Aug  9 11:51:25 2012
New Revision: 161592

URL: http://llvm.org/viewvc/llvm-project?rev=161592&view=rev
Log:
<rdar://problem/11505459> Stripping off the object's type from the output of the 'po' command

Modified:
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
    lldb/trunk/test/lang/objc/print-obj/TestPrintObj.py

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=161592&r1=161591&r2=161592&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug  9 11:51:25 2012
@@ -231,6 +231,7 @@
         lldb::Format m_format;
         lldb::TypeSummaryImplSP m_summary_sp;
         std::string m_root_valobj_name;
+        bool m_hide_root_type;
         
         DumpValueObjectOptions() :
             m_max_ptr_depth(0),
@@ -246,7 +247,8 @@
             m_ignore_cap(false), 
             m_format (lldb::eFormatDefault),
             m_summary_sp(),
-            m_root_valobj_name()
+            m_root_valobj_name(),
+            m_hide_root_type(false)  // <rdar://problem/11505459> provide a special compact display for "po",
         {}
         
         static const DumpValueObjectOptions
@@ -271,7 +273,8 @@
             m_ignore_cap(rhs.m_ignore_cap),
             m_format(rhs.m_format),
             m_summary_sp(rhs.m_summary_sp),
-            m_root_valobj_name(rhs.m_root_valobj_name)
+            m_root_valobj_name(rhs.m_root_valobj_name),
+            m_hide_root_type(rhs.m_hide_root_type)
         {}
         
         DumpValueObjectOptions&
@@ -402,6 +405,13 @@
                 m_root_valobj_name.clear();
             return *this;
         }
+                
+        DumpValueObjectOptions&
+        SetHideRootType (bool hide_root_type = false)
+        {
+            m_hide_root_type = hide_root_type;
+            return *this;
+        }
 
     };
 

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=161592&r1=161591&r2=161592&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Aug  9 11:51:25 2012
@@ -360,7 +360,8 @@
                     .SetIgnoreCap(false)
                     .SetFormat(format)
                     .SetSummary()
-                    .SetShowSummary(!m_command_options.print_object);
+                    .SetShowSummary(!m_command_options.print_object)
+                    .SetHideRootType(m_command_options.print_object);
                     
                     ValueObject::DumpValueObject (*(output_stream),
                                                   result_valobj_sp.get(),   // Variable object to dump

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=161592&r1=161591&r2=161592&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug  9 11:51:25 2012
@@ -3191,9 +3191,16 @@
             }
 
             s.Indent();
-
-            // Always show the type for the top level items.
-            if (options.m_show_types || (curr_depth == 0 && !options.m_flat_output))
+            
+            bool show_type = true;
+            // if we are at the root-level and been asked to hide the root's type, then hide it
+            if (curr_depth == 0 && options.m_hide_root_type)
+                show_type = false;
+            else
+            // otherwise decide according to the usual rules (asked to show types - always at the root level)
+                show_type = options.m_show_types || (curr_depth == 0 && !options.m_flat_output);
+            
+            if (show_type)
             {
                 const char* typeName = valobj->GetQualifiedTypeName().AsCString("<invalid type>");
                 //const char* typeName = valobj->GetTypeName().AsCString("<invalid type>");

Modified: lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py?rev=161592&r1=161591&r2=161592&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py Thu Aug  9 11:51:25 2012
@@ -225,7 +225,7 @@
         self.runCmd("run", RUN_SUCCEEDED)
 
         self.expect("po [NSError errorWithDomain:@\"Hello\" code:35 userInfo:nil]",
-            patterns = ["\(id\) \$.* = ", "Error Domain=Hello", "Code=35", "be completed."])
+            substrs = ["$", "= 0x", "Error Domain=Hello", "Code=35", "be completed."])
         self.runCmd("process continue")
 
     def NSError_p(self):

Modified: lldb/trunk/test/lang/objc/print-obj/TestPrintObj.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/print-obj/TestPrintObj.py?rev=161592&r1=161591&r2=161592&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/print-obj/TestPrintObj.py (original)
+++ lldb/trunk/test/lang/objc/print-obj/TestPrintObj.py Thu Aug  9 11:51:25 2012
@@ -94,7 +94,7 @@
                 break
 
         self.expect("po lock_me", OBJECT_PRINTED_CORRECTLY,
-            substrs = ['LockMe *', 'I am pretty special.'])
+            substrs = ['I am pretty special.'])
 
 
 if __name__ == '__main__':





More information about the lldb-commits mailing list