<rdar://problem/11505459> Stripping off the object's type from the output of the...
authorEnrico Granata <egranata@apple.com>
Thu, 9 Aug 2012 16:51:25 +0000 (16:51 +0000)
committerEnrico Granata <egranata@apple.com>
Thu, 9 Aug 2012 16:51:25 +0000 (16:51 +0000)
llvm-svn: 161592

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

index 3b411e8..0cc6a9f 100644 (file)
@@ -231,6 +231,7 @@ public:
         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 @@ public:
             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 @@ public:
             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 @@ public:
                 m_root_valobj_name.clear();
             return *this;
         }
+                
+        DumpValueObjectOptions&
+        SetHideRootType (bool hide_root_type = false)
+        {
+            m_hide_root_type = hide_root_type;
+            return *this;
+        }
 
     };
 
index 72cb131..35d372d 100644 (file)
@@ -360,7 +360,8 @@ CommandObjectExpression::EvaluateExpression
                     .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
index 4dc22f0..127152e 100644 (file)
@@ -3191,9 +3191,16 @@ DumpValueObject_Impl (Stream &s,
             }
 
             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>");
index 84381a9..86478d9 100644 (file)
@@ -225,7 +225,7 @@ class FoundationTestCase2(TestBase):
         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):
index dc21be9..66b5958 100644 (file)
@@ -94,7 +94,7 @@ class PrintObjTestCase(TestBase):
                 break
 
         self.expect("po lock_me", OBJECT_PRINTED_CORRECTLY,
-            substrs = ['LockMe *', 'I am pretty special.'])
+            substrs = ['I am pretty special.'])
 
 
 if __name__ == '__main__':