summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/ValueObjectPrinter.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-10-08 18:27:36 +0000
committerEnrico Granata <egranata@apple.com>2014-10-08 18:27:36 +0000
commitd07cfd3ae4c6a99d06c67549d7a946a870ce228a (patch)
treec684371dc7d2ea6d6cab1835ebb1a4d32bb1a652 /lldb/source/DataFormatters/ValueObjectPrinter.cpp
parentef9bc3d85761d560b36990d5acf74e4e466c64b0 (diff)
downloadbcm5719-llvm-d07cfd3ae4c6a99d06c67549d7a946a870ce228a.tar.gz
bcm5719-llvm-d07cfd3ae4c6a99d06c67549d7a946a870ce228a.zip
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function. If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value The rationale for doing things this way is twofold: - there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial - we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature Comes with a test case llvm-svn: 219330
Diffstat (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp')
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 3ce5051cc4e..126ff78c389 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -66,7 +66,7 @@ ValueObjectPrinter::Init (ValueObject* valobj,
bool
ValueObjectPrinter::PrintValueObject ()
{
- if (!GetDynamicValueIfNeeded () || m_valobj == nullptr)
+ if (!GetMostSpecializedValue () || m_valobj == nullptr)
return false;
if (ShouldPrintValueObject())
@@ -97,7 +97,7 @@ ValueObjectPrinter::PrintValueObject ()
}
bool
-ValueObjectPrinter::GetDynamicValueIfNeeded ()
+ValueObjectPrinter::GetMostSpecializedValue ()
{
if (m_valobj)
return true;
@@ -134,6 +134,25 @@ ValueObjectPrinter::GetDynamicValueIfNeeded ()
else
m_valobj = m_orig_valobj;
}
+
+ if (m_valobj->IsSynthetic())
+ {
+ if (options.m_use_synthetic == false)
+ {
+ ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get();
+ if (non_synthetic)
+ m_valobj = non_synthetic;
+ }
+ }
+ else
+ {
+ if (options.m_use_synthetic == true)
+ {
+ ValueObject *synthetic = m_valobj->GetSyntheticValue().get();
+ if (synthetic)
+ m_valobj = synthetic;
+ }
+ }
}
m_clang_type = m_valobj->GetClangType();
m_type_flags = m_clang_type.GetTypeInfo ();
@@ -442,8 +461,7 @@ ValueObjectPrinter::ShouldPrintChildren (bool is_failed_description,
ValueObject*
ValueObjectPrinter::GetValueObjectForChildrenGeneration ()
{
- ValueObjectSP synth_valobj_sp = m_valobj->GetSyntheticValue (options.m_use_synthetic);
- return (synth_valobj_sp ? synth_valobj_sp.get() : m_valobj);
+ return m_valobj;
}
void
@@ -540,7 +558,13 @@ ValueObjectPrinter::PrintChildren (uint32_t curr_ptr_depth)
{
// Aggregate, no children...
if (ShouldPrintValueObject())
- m_stream->PutCString(" {}\n");
+ {
+ // if it has a synthetic value, then don't print {}, the synthetic children are probably only being used to vend a value
+ if (m_valobj->DoesProvideSyntheticValue())
+ m_stream->PutCString( "\n");
+ else
+ m_stream->PutCString(" {}\n");
+ }
}
else
{
@@ -552,7 +576,7 @@ ValueObjectPrinter::PrintChildren (uint32_t curr_ptr_depth)
bool
ValueObjectPrinter::PrintChildrenOneLiner (bool hide_names)
{
- if (!GetDynamicValueIfNeeded () || m_valobj == nullptr)
+ if (!GetMostSpecializedValue () || m_valobj == nullptr)
return false;
ValueObject* synth_m_valobj = GetValueObjectForChildrenGeneration();
OpenPOWER on IntegriCloud