diff options
| author | Enrico Granata <egranata@apple.com> | 2014-09-05 21:46:22 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2014-09-05 21:46:22 +0000 |
| commit | 744794aa96adea673708e3ace98ec36680b2e5e9 (patch) | |
| tree | 14155f3d776ac278036aacb41ce0db7205643c15 | |
| parent | d31dc048ca01fbeb4cee31189d8a4e5ca41a5a44 (diff) | |
| download | bcm5719-llvm-744794aa96adea673708e3ace98ec36680b2e5e9.tar.gz bcm5719-llvm-744794aa96adea673708e3ace98ec36680b2e5e9.zip | |
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
llvm-svn: 217282
| -rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 23 | ||||
| -rw-r--r-- | lldb/include/lldb/DataFormatters/TypeValidator.h | 6 | ||||
| -rw-r--r-- | lldb/include/lldb/lldb-private-enumerations.h | 8 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 27 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/TypeValidator.cpp | 4 |
5 files changed, 59 insertions, 9 deletions
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 6a08ec6507f..18844318c08 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -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; diff --git a/lldb/include/lldb/DataFormatters/TypeValidator.h b/lldb/include/lldb/DataFormatters/TypeValidator.h index 515a95f371a..b501e47943f 100644 --- a/lldb/include/lldb/DataFormatters/TypeValidator.h +++ b/lldb/include/lldb/DataFormatters/TypeValidator.h @@ -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; }; diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index adc8b4c3e6f..9aae2a6cb25 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -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 diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 1819e834536..3b37de79234 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -77,6 +77,7 @@ ValueObject::ValueObject (ValueObject &parent) : 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 &parent) : 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 (ExecutionContextScope *exe_scope, 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 (ExecutionContextScope *exe_scope, 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& s, 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_t clear_mask) 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_t clear_mask) if (m_synthetic_value) m_synthetic_value = NULL; } + + if ((clear_mask & eClearUserVisibleDataItemsValidator) == eClearUserVisibleDataItemsValidator) + m_validation_result.reset(); } SymbolContextScope * diff --git a/lldb/source/DataFormatters/TypeValidator.cpp b/lldb/source/DataFormatters/TypeValidator.cpp index 0327f5a0931..317e0962128 100644 --- a/lldb/source/DataFormatters/TypeValidator.cpp +++ b/lldb/source/DataFormatters/TypeValidator.cpp @@ -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) : |

