From 0f883ffbdb0362b6064d9bcf61a23ddef1e2b2bd Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Sat, 6 Sep 2014 02:20:19 +0000 Subject: Add a -V 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 --- lldb/source/DataFormatters/ValueObjectPrinter.cpp | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp') diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 65e5e3f45823..3ce5051cc4e1 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; +} -- cgit v1.2.3