diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3b411e8a9e01..0cc6a9f5a7a6 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -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) // 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; + } }; diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 72cb131aea15..35d372ddd567 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -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 diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 4dc22f02039f..127152e3bb42 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -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(""); //const char* typeName = valobj->GetTypeName().AsCString(""); diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods2.py b/lldb/test/lang/objc/foundation/TestObjCMethods2.py index 84381a91a2b1..86478d9d1428 100644 --- a/lldb/test/lang/objc/foundation/TestObjCMethods2.py +++ b/lldb/test/lang/objc/foundation/TestObjCMethods2.py @@ -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): diff --git a/lldb/test/lang/objc/print-obj/TestPrintObj.py b/lldb/test/lang/objc/print-obj/TestPrintObj.py index dc21be980bee..66b59581a61b 100644 --- a/lldb/test/lang/objc/print-obj/TestPrintObj.py +++ b/lldb/test/lang/objc/print-obj/TestPrintObj.py @@ -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__':