[Lldb-commits] [lldb] r173748 - <rdar://problem/12890171>

Enrico Granata egranata at apple.com
Mon Jan 28 17:35:01 PST 2013


Author: enrico
Date: Mon Jan 28 19:35:01 2013
New Revision: 173748

URL: http://llvm.org/viewvc/llvm-project?rev=173748&view=rev
Log:
<rdar://problem/12890171>

Providing a compact display mode for "po" to use where the convenience variable name and the pointer value are both hidden.
This is for convenience when dealing with ObjC instances where the description often gets it right and the debugger-provided information is not useful to most people.
If you need either of these, "expr" will still show them.


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

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=173748&r1=173747&r2=173748&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Jan 28 19:35:01 2013
@@ -232,6 +232,8 @@ public:
         lldb::TypeSummaryImplSP m_summary_sp;
         std::string m_root_valobj_name;
         bool m_hide_root_type;
+        bool m_hide_name;
+        bool m_hide_value;
         
         DumpValueObjectOptions() :
             m_max_ptr_depth(0),
@@ -248,7 +250,9 @@ public:
             m_format (lldb::eFormatDefault),
             m_summary_sp(),
             m_root_valobj_name(),
-            m_hide_root_type(false)  // <rdar://problem/11505459> provide a special compact display for "po",
+            m_hide_root_type(false),  // provide a special compact display for "po"
+            m_hide_name(false), // provide a special compact display for "po"
+            m_hide_value(false) // provide a special compact display for "po"
         {}
         
         static const DumpValueObjectOptions
@@ -274,7 +278,9 @@ public:
             m_format(rhs.m_format),
             m_summary_sp(rhs.m_summary_sp),
             m_root_valobj_name(rhs.m_root_valobj_name),
-            m_hide_root_type(rhs.m_hide_root_type)
+            m_hide_root_type(rhs.m_hide_root_type),
+            m_hide_name(rhs.m_hide_name),
+            m_hide_value(rhs.m_hide_value)
         {}
         
         DumpValueObjectOptions&
@@ -372,12 +378,16 @@ public:
                 SetUseSyntheticValue(false);
                 SetOmitSummaryDepth(UINT32_MAX);
                 SetIgnoreCap(true);
+                SetHideName(false);
+                SetHideValue(false);
             }
             else
             {
                 SetUseSyntheticValue(true);
                 SetOmitSummaryDepth(0);
                 SetIgnoreCap(false);
+                SetHideName(false);
+                SetHideValue(false);
             }
             return *this;
         }
@@ -412,7 +422,20 @@ public:
             m_hide_root_type = hide_root_type;
             return *this;
         }
+        
+        DumpValueObjectOptions&
+        SetHideName (bool hide_name = false)
+        {
+            m_hide_name = hide_name;
+            return *this;
+        }
 
+        DumpValueObjectOptions&
+        SetHideValue (bool hide_value = false)
+        {
+            m_hide_value = hide_value;
+            return *this;
+        }        
     };
 
     class EvaluationPoint

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=173748&r1=173747&r2=173748&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Jan 28 19:35:01 2013
@@ -400,7 +400,9 @@ CommandObjectExpression::EvaluateExpress
                     .SetFormat(format)
                     .SetSummary()
                     .SetShowSummary(!m_varobj_options.use_objc)
-                    .SetHideRootType(m_varobj_options.use_objc);
+                    .SetHideRootType(m_varobj_options.use_objc)
+                    .SetHideName(m_varobj_options.use_objc)
+                    .SetHideValue(m_varobj_options.use_objc);
                     
                     if (m_varobj_options.be_raw)
                         options.SetRawDisplay(true);

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=173748&r1=173747&r2=173748&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Jan 28 19:35:01 2013
@@ -3287,10 +3287,13 @@ DumpValueObject_Impl (Stream &s,
             {
                 // If we are showing types, also qualify the C++ base classes 
                 const bool qualify_cxx_base_classes = options.m_show_types;
-                valobj->GetExpressionPath(s, qualify_cxx_base_classes);
-                s.PutCString(" =");
+                if (!options.m_hide_name)
+                {
+                    valobj->GetExpressionPath(s, qualify_cxx_base_classes);
+                    s.PutCString(" =");
+                }
             }
-            else
+            else if (!options.m_hide_name)
             {
                 const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString("");
                 s.Printf ("%s =", name_cstr);
@@ -3354,7 +3357,7 @@ DumpValueObject_Impl (Stream &s,
                 // Make sure we have a value and make sure the summary didn't
                 // 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))
+                if (!is_nil && !value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL) && !options.m_hide_value)
                     s.Printf(" %s", value_str.c_str());
 
                 if (sum_cstr)
@@ -3363,11 +3366,13 @@ DumpValueObject_Impl (Stream &s,
                 // let's avoid the overly verbose no description error for a nil thing
                 if (options.m_use_objc && !is_nil)
                 {
+                    if (!options.m_hide_value || !options.m_hide_name)
+                        s.Printf(" ");
                     const char *object_desc = valobj->GetObjectDescription();
                     if (object_desc)
-                        s.Printf(" %s\n", object_desc);
+                        s.Printf("%s\n", object_desc);
                     else
-                        s.Printf (" [no Objective-C description available]\n");
+                        s.Printf ("[no Objective-C description available]\n");
                     return;
                 }
             }
@@ -3438,7 +3443,7 @@ DumpValueObject_Impl (Stream &s,
 
                         ValueObject::DumpValueObjectOptions child_options(options);
                         child_options.SetFormat(options.m_format).SetSummary().SetRootValueObjectName();
-                        child_options.SetScopeChecked(true)
+                        child_options.SetScopeChecked(true).SetHideName(options.m_hide_name).SetHideValue(options.m_hide_value)
                         .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0);
                         for (size_t idx=0; idx<num_children; ++idx)
                         {

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=173748&r1=173747&r2=173748&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestObjCMethods2.py Mon Jan 28 19:35:01 2013
@@ -216,7 +216,7 @@ class FoundationTestCase2(TestBase):
         self.runCmd("run", RUN_SUCCEEDED)
 
         self.expect("po [NSError errorWithDomain:@\"Hello\" code:35 userInfo:nil]",
-            substrs = ["$", "= 0x", "Error Domain=Hello", "Code=35", "be completed."])
+            substrs = ["Error Domain=Hello", "Code=35", "be completed."])
         self.runCmd("process continue")
 
     def NSError_p(self):





More information about the lldb-commits mailing list