summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/ValueObjectPrinter.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-10-04 23:14:13 +0000
committerEnrico Granata <egranata@apple.com>2013-10-04 23:14:13 +0000
commita29cb0bada725d47daa0006be1a847964b29e45e (patch)
tree05a98d9df302f53ddf17041714dc5a2c54314e0d /lldb/source/DataFormatters/ValueObjectPrinter.cpp
parent1f4f5d7b84034f0b9dae78f4c67ff59bff27d96c (diff)
downloadbcm5719-llvm-a29cb0bada725d47daa0006be1a847964b29e45e.tar.gz
bcm5719-llvm-a29cb0bada725d47daa0006be1a847964b29e45e.zip
<rdar://problem/12042982>
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<int,int> 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
Diffstat (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp')
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp62
1 files changed, 61 insertions, 1 deletions
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; idx<num_children; ++idx)
+ {
+ lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(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())
{
OpenPOWER on IntegriCloud