From a29cb0bada725d47daa0006be1a847964b29e45e Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Fri, 4 Oct 2013 23:14:13 +0000 Subject: This radar extends the notion of one-liner summaries to automagically apply in a few interesting cases More specifically, this checkin changes the printout of ValueObjects to print on one-line (as if type summary add -c had been applied) iff: this ValueObject does not have a summary its children have no synthetic children its children are not a non-empty base class without a summary its children do not have a summary that asks for children to show up the aggregate length of all the names of all the children is <= 50 characters you did not ask to see the types during a printout your pointer depth is 0 This is meant to simplify the way LLDB shows data on screen for small structs and similarly compact data types (e.g. std::pair anyone?) Feedback is especially welcome on how the feature feels and corner cases where we should apply this printout and don't (or viceversa, we are applying it when we shouldn't be) llvm-svn: 191996 --- lldb/source/DataFormatters/ValueObjectPrinter.cpp | 62 ++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp') diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index cd316cec628..7da5450bcd2 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Debugger.h" +#include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Target.h" @@ -97,6 +98,8 @@ ValueObjectPrinter::PrintValueObject () bool ValueObjectPrinter::GetDynamicValueIfNeeded () { + if (m_valobj) + return true; bool update_success = m_orig_valobj->UpdateValueIfNeeded (true); if (!update_success) return false; @@ -522,6 +525,55 @@ ValueObjectPrinter::PrintChildren (uint32_t curr_ptr_depth) } } +bool +ValueObjectPrinter::PrintChildrenOneLiner (bool hide_names) +{ + if (!GetDynamicValueIfNeeded () || m_valobj == nullptr) + return false; + + ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration(); + + bool print_dotdotdot = false; + size_t num_children = GetMaxNumChildrenToPrint(print_dotdotdot); + + if (num_children) + { + m_stream->PutChar('('); + + for (uint32_t idx=0; idxGetChildAtIndex(idx, true)); + lldb::ValueObjectSP child_dyn_sp = child_sp.get() ? child_sp->GetDynamicValue(options.m_use_dynamic) : child_sp; + if (child_dyn_sp) + child_sp = child_dyn_sp; + if (child_sp) + { + if (idx) + m_stream->PutCString(", "); + if (!hide_names) + { + const char* name = child_sp.get()->GetName().AsCString(); + if (name && *name) + { + m_stream->PutCString(name); + m_stream->PutCString(" = "); + } + } + child_sp->DumpPrintableRepresentation(*m_stream, + ValueObject::eValueObjectRepresentationStyleSummary, + lldb::eFormatInvalid, + ValueObject::ePrintableRepresentationSpecialCasesDisable); + } + } + + if (print_dotdotdot) + m_stream->PutCString(", ...)"); + else + m_stream->PutChar(')'); + } + return true; +} + void ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed, bool summary_printed) @@ -532,10 +584,18 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed, uint32_t curr_ptr_depth = m_ptr_depth; bool print_children = ShouldPrintChildren (is_failed_description,curr_ptr_depth); + bool print_oneline = (curr_ptr_depth > 0 || options.m_show_types) ? false : DataVisualization::ShouldPrintAsOneLiner(*m_valobj); if (print_children) { - PrintChildren (curr_ptr_depth); + if (print_oneline) + { + m_stream->PutChar(' '); + PrintChildrenOneLiner (false); + m_stream->EOL(); + } + else + PrintChildren (curr_ptr_depth); } else if (m_curr_depth >= options.m_max_depth && IsAggregate() && ShouldPrintValueObject()) { -- cgit v1.2.3