[Lldb-commits] [lldb] r217282 - Start plumbing the type validator logic through to the ValueObjects; allow a ValueObject to have a validator, to update it from the FormatManager, and to retrieve (and cache) the result of the validation
Enrico Granata
egranata at apple.com
Fri Sep 5 14:46:22 PDT 2014
Author: enrico
Date: Fri Sep 5 16:46:22 2014
New Revision: 217282
URL: http://llvm.org/viewvc/llvm-project?rev=217282&view=rev
Log:
Start plumbing the type validator logic through to the ValueObjects; allow a ValueObject to have a validator, to update it from the FormatManager, and to retrieve (and cache) the result of the validation
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
lldb/trunk/include/lldb/lldb-private-enumerations.h
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/DataFormatters/TypeValidator.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=217282&r1=217281&r2=217282&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Sep 5 16:46:22 2014
@@ -129,6 +129,7 @@ public:
eClearUserVisibleDataItemsLocation = 1u << 3,
eClearUserVisibleDataItemsDescription = 1u << 4,
eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
+ eClearUserVisibleDataItemsValidator = 1u << 6,
eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
eClearUserVisibleDataItemsAll = 0xFFFF
};
@@ -607,6 +608,9 @@ public:
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination);
+ std::pair<TypeValidatorResult, std::string>
+ GetValidationStatus ();
+
const char *
GetObjectDescription ();
@@ -848,6 +852,20 @@ public:
ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
}
+ lldb::TypeValidatorImplSP
+ GetValidator()
+ {
+ UpdateFormatsIfNeeded();
+ return m_type_validator_sp;
+ }
+
+ void
+ SetValidator(lldb::TypeValidatorImplSP format)
+ {
+ m_type_validator_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
+ }
+
void
SetValueFormat(lldb::TypeFormatImplSP format)
{
@@ -1018,7 +1036,9 @@ protected:
std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
// in that the summary is consed up by us, the object_desc_string is builtin.
-
+
+ llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
+
ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose.
ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
@@ -1043,6 +1063,7 @@ protected:
lldb::TypeSummaryImplSP m_type_summary_sp;
lldb::TypeFormatImplSP m_type_format_sp;
lldb::SyntheticChildrenSP m_synthetic_children_sp;
+ lldb::TypeValidatorImplSP m_type_validator_sp;
ProcessModID m_user_id_of_forced_summary;
AddressType m_address_type_of_ptr_or_ref_children;
Modified: lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeValidator.h?rev=217282&r1=217281&r2=217282&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeValidator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeValidator.h Fri Sep 5 16:46:22 2014
@@ -21,6 +21,7 @@
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private-enumerations.h"
namespace lldb_private {
@@ -196,10 +197,7 @@ public:
};
struct ValidationResult {
- enum class ResultType {
- eSuccess,
- eFailure
- } m_result;
+ TypeValidatorResult m_result;
std::string m_message;
};
Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=217282&r1=217281&r2=217282&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-private-enumerations.h Fri Sep 5 16:46:22 2014
@@ -240,6 +240,14 @@ typedef enum ExitType {
eExitTypeStop, // The exit status represents the stop signal that caused the program to exit (i.e. WIFSTOPPED() was true)
} ExitType;
+//----------------------------------------------------------------------
+// Boolean result of running a Type Validator
+//----------------------------------------------------------------------
+enum class TypeValidatorResult : bool {
+ Success = true,
+ Failure = false
+};
+
} // namespace lldb_private
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=217282&r1=217281&r2=217282&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Sep 5 16:46:22 2014
@@ -77,6 +77,7 @@ ValueObject::ValueObject (ValueObject &p
m_location_str (),
m_summary_str (),
m_object_desc_str (),
+ m_validation_result(),
m_manager(parent.GetManager()),
m_children (),
m_synthetic_children (),
@@ -89,6 +90,7 @@ ValueObject::ValueObject (ValueObject &p
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
+ m_type_validator_sp(),
m_user_id_of_forced_summary(),
m_address_type_of_ptr_or_ref_children(eAddressTypeInvalid),
m_value_is_valid (false),
@@ -123,6 +125,7 @@ ValueObject::ValueObject (ExecutionConte
m_location_str (),
m_summary_str (),
m_object_desc_str (),
+ m_validation_result(),
m_manager(),
m_children (),
m_synthetic_children (),
@@ -135,6 +138,7 @@ ValueObject::ValueObject (ExecutionConte
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
+ m_type_validator_sp(),
m_user_id_of_forced_summary(),
m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type),
m_value_is_valid (false),
@@ -253,6 +257,7 @@ ValueObject::UpdateFormatsIfNeeded()
#ifndef LLDB_DISABLE_PYTHON
SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, GetDynamicValueType()));
#endif
+ SetValidator(DataVisualization::GetValidator(*this, GetDynamicValueType()));
}
return any_change;
@@ -1341,6 +1346,23 @@ ValueObject::ReadPointedString (Stream&
return total_bytes_read;
}
+std::pair<TypeValidatorResult, std::string>
+ValueObject::GetValidationStatus ()
+{
+ if (!UpdateValueIfNeeded(true))
+ return {TypeValidatorResult::Success,""}; // not the validator's job to discuss update problems
+
+ if (m_validation_result.hasValue())
+ return m_validation_result.getValue();
+
+ if (!m_type_validator_sp)
+ return {TypeValidatorResult::Success,""}; // no validator no failure
+
+ auto outcome = m_type_validator_sp->FormatObject(this);
+
+ return (m_validation_result = {outcome.m_result,outcome.m_message}).getValue();
+}
+
const char *
ValueObject::GetObjectDescription ()
{
@@ -3900,9 +3922,7 @@ ValueObject::ClearUserVisibleData(uint32
m_location_str.clear();
if ((clear_mask & eClearUserVisibleDataItemsSummary) == eClearUserVisibleDataItemsSummary)
- {
m_summary_str.clear();
- }
if ((clear_mask & eClearUserVisibleDataItemsDescription) == eClearUserVisibleDataItemsDescription)
m_object_desc_str.clear();
@@ -3912,6 +3932,9 @@ ValueObject::ClearUserVisibleData(uint32
if (m_synthetic_value)
m_synthetic_value = NULL;
}
+
+ if ((clear_mask & eClearUserVisibleDataItemsValidator) == eClearUserVisibleDataItemsValidator)
+ m_validation_result.reset();
}
SymbolContextScope *
Modified: lldb/trunk/source/DataFormatters/TypeValidator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeValidator.cpp?rev=217282&r1=217281&r2=217282&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeValidator.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeValidator.cpp Fri Sep 5 16:46:22 2014
@@ -23,13 +23,13 @@ using namespace lldb_private;
TypeValidatorImpl::ValidationResult
TypeValidatorImpl::Success ()
{
- return ValidationResult { ValidationResult::ResultType::eSuccess, "" };
+ return ValidationResult { TypeValidatorResult::Success, "" };
}
TypeValidatorImpl::ValidationResult
TypeValidatorImpl::Failure (std::string message)
{
- return ValidationResult { ValidationResult::ResultType::eFailure, message };
+ return ValidationResult { TypeValidatorResult::Failure, message };
}
TypeValidatorImpl_CXX::TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags) :
More information about the lldb-commits
mailing list