<rdar://problem/11505459> Stripping off the object's type from the output of the 'po' command

llvm-svn: 161592
This commit is contained in:
Enrico Granata 2012-08-09 16:51:25 +00:00
parent 8aba007fe1
commit 2b2631c915
5 changed files with 26 additions and 8 deletions

View 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;
}
};

View 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

View 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>");

View 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):

View 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__':