summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/ValueObjectPrinter.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-09-06 02:20:19 +0000
committerEnrico Granata <egranata@apple.com>2014-09-06 02:20:19 +0000
commit0f883ffbdb0362b6064d9bcf61a23ddef1e2b2bd (patch)
tree34c7d58b6bf363bfaf526eb4b590f58cdc130d9b /lldb/source/DataFormatters/ValueObjectPrinter.cpp
parentefa6f736e63a9978d68f47be6e980803452d256d (diff)
downloadbcm5719-llvm-0f883ffbdb0362b6064d9bcf61a23ddef1e2b2bd.tar.gz
bcm5719-llvm-0f883ffbdb0362b6064d9bcf61a23ddef1e2b2bd.zip
Add a -V <bool> flag to frame variable/expression that enables execution of type validators. The jury is still out on what the user experience of type validators should be, so for now gate it on a specific flag. The mode I am using is prefix variables that fail to validate with a bang, and then emitting the actual validation error on a separate line. Of course, given the total absence of validators, this should never actually happen to you
llvm-svn: 217303
Diffstat (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp')
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 65e5e3f4582..3ce5051cc4e 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -71,6 +71,8 @@ ValueObjectPrinter::PrintValueObject ()
if (ShouldPrintValueObject())
{
+ PrintValidationMarkerIfNeeded();
+
PrintLocationIfNeeded();
m_stream->Indent();
@@ -89,6 +91,8 @@ ValueObjectPrinter::PrintValueObject ()
else
m_stream->EOL();
+ PrintValidationErrorIfNeeded();
+
return true;
}
@@ -624,3 +628,44 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
else
m_stream->EOL();
}
+
+bool
+ValueObjectPrinter::ShouldPrintValidation ()
+{
+ return options.m_run_validator;
+}
+
+bool
+ValueObjectPrinter::PrintValidationMarkerIfNeeded ()
+{
+ if (!ShouldPrintValidation())
+ return false;
+
+ m_validation = m_valobj->GetValidationStatus();
+
+ if (TypeValidatorResult::Failure == m_validation.first)
+ {
+ m_stream->Printf("! ");
+ return true;
+ }
+
+ return false;
+}
+
+bool
+ValueObjectPrinter::PrintValidationErrorIfNeeded ()
+{
+ if (!ShouldPrintValidation())
+ return false;
+
+ if (TypeValidatorResult::Success == m_validation.first)
+ return false;
+
+ if (m_validation.second.empty())
+ m_validation.second.assign("unknown error");
+
+ m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());
+ m_stream->EOL();
+
+ return true;
+}
OpenPOWER on IntegriCloud