diff options
author | Enrico Granata <egranata@apple.com> | 2012-10-27 02:05:48 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2012-10-27 02:05:48 +0000 |
commit | 21fd13f9b704361e36af81939e068ccbf6a669d1 (patch) | |
tree | caf4ccbf84ecede57fd9eda1da9ffdc89d5164ea | |
parent | cd6ce2ff3113ec70d24d3013a24bb379f1455ccf (diff) | |
download | bcm5719-llvm-21fd13f9b704361e36af81939e068ccbf6a669d1.tar.gz bcm5719-llvm-21fd13f9b704361e36af81939e068ccbf6a669d1.zip |
Moving ValueObjectCast over to its own .h/.cpp files instead of sharing ValueObjectDynamic.h/.cpp
Removing the IsDynamic() and GetStaticValue() calls, so that they will default to the base class behavior:
- non-dynamic
- itself as the static value
This is in contrast with the previous behavior which could be confusing and could potentially cause issues when using those objects
llvm-svn: 166857
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectCast.h | 90 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectDynamicValue.h | 77 | ||||
-rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 1 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectCast.cpp | 132 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectDynamicValue.cpp | 105 |
6 files changed, 230 insertions, 181 deletions
diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h new file mode 100644 index 00000000000..e7218b5dfaf --- /dev/null +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -0,0 +1,90 @@ +//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ValueObjectCast_h_ +#define liblldb_ValueObjectCast_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ValueObject.h" + +namespace lldb_private { + +//--------------------------------------------------------------------------------- +// A ValueObject that represents a given value represented as a different type. +//--------------------------------------------------------------------------------- +class ValueObjectCast : public ValueObject +{ +public: + static lldb::ValueObjectSP + Create (ValueObject &parent, + const ConstString &name, + const ClangASTType &cast_type); + + virtual + ~ValueObjectCast(); + + virtual size_t + GetByteSize(); + + virtual uint32_t + CalculateNumChildren(); + + virtual lldb::ValueType + GetValueType() const; + + virtual bool + IsInScope (); + + virtual ValueObject * + GetParent() + { + if (m_parent) + return m_parent->GetParent(); + else + return NULL; + } + + virtual const ValueObject * + GetParent() const + { + if (m_parent) + return m_parent->GetParent(); + else + return NULL; + } + +protected: + virtual bool + UpdateValue (); + + virtual clang::ASTContext * + GetClangASTImpl (); + + virtual lldb::clang_type_t + GetClangTypeImpl (); + + ClangASTType m_cast_type; + +private: + ValueObjectCast (ValueObject &parent, + const ConstString &name, + const ClangASTType &cast_type); + + //------------------------------------------------------------------ + // For ValueObject only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (ValueObjectCast); +}; + +} // namespace lldb_private + +#endif // liblldb_ValueObjectCast_h_ diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 565cc2fd9db..a76ca10d637 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -15,86 +15,9 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/ClangASTType.h" namespace lldb_private { - class ValueObjectCast : public ValueObject - { - public: - static lldb::ValueObjectSP - Create (ValueObject &parent, - const ConstString &name, - const ClangASTType &cast_type); - - virtual - ~ValueObjectCast(); - - virtual size_t - GetByteSize(); - - virtual uint32_t - CalculateNumChildren(); - - virtual lldb::ValueType - GetValueType() const; - - virtual bool - IsInScope (); - - virtual bool - IsDynamic () - { - return true; - } - - virtual ValueObject * - GetParent() - { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; - } - - virtual const ValueObject * - GetParent() const - { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; - } - - virtual lldb::ValueObjectSP - GetStaticValue () - { - return m_parent->GetSP(); - } - - protected: - virtual bool - UpdateValue (); - - virtual clang::ASTContext * - GetClangASTImpl (); - - virtual lldb::clang_type_t - GetClangTypeImpl (); - - ClangASTType m_cast_type; - - private: - ValueObjectCast (ValueObject &parent, - const ConstString &name, - const ClangASTType &cast_type); - - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (ValueObjectCast); - }; - //---------------------------------------------------------------------- // A ValueObject that represents memory at a given address, viewed as some // set lldb type. diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index fe0ae1c38cb..e942d83bcc9 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -513,6 +513,7 @@ 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; 94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; }; + 94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; }; 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; }; 941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568614E355F2003A195C /* SBTypeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568714E355F2003A195C /* SBTypeFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1514,6 +1515,8 @@ 94031A9B13CF484600DCFF3C /* InputReaderEZ.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InputReaderEZ.h; path = include/lldb/Core/InputReaderEZ.h; sourceTree = "<group>"; }; 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderEZ.cpp; path = source/Core/InputReaderEZ.cpp; sourceTree = "<group>"; }; 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; }; + 94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; }; + 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; }; 9415F61613B2C0DC00A52B36 /* FormatManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = FormatManager.h; path = include/lldb/Core/FormatManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = FormatManager.cpp; path = source/Core/FormatManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; }; @@ -2599,6 +2602,8 @@ 26BC7E9910F1B85900F91463 /* Value.cpp */, 26BC7D8210F1B77400F91463 /* ValueObject.h */, 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */, + 94094C68163B6CCC0083A547 /* ValueObjectCast.h */, + 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */, 26BC7D8310F1B77400F91463 /* ValueObjectChild.h */, 26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */, 26424E3E125986D30016D82C /* ValueObjectConstResult.h */, @@ -4161,6 +4166,7 @@ 94CDEB9D15F0258500DD2A7A /* CXXFormatterFunctions.cpp in Sources */, 947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */, 262ED0081631FA3A00879631 /* OptionGroupString.cpp in Sources */, + 94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index f608f85f3cd..c3560f1089e 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -24,6 +24,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectDynamicValue.h" diff --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp new file mode 100644 index 00000000000..7834c850874 --- /dev/null +++ b/lldb/source/Core/ValueObjectCast.cpp @@ -0,0 +1,132 @@ +//===-- ValueObjectDynamicValue.cpp ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include "lldb/Core/ValueObjectCast.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObject.h" + +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/Variable.h" + +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + +using namespace lldb_private; + +lldb::ValueObjectSP +ValueObjectCast::Create (ValueObject &parent, + const ConstString &name, + const ClangASTType &cast_type) +{ + ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type); + return cast_valobj_ptr->GetSP(); +} + +ValueObjectCast::ValueObjectCast +( + ValueObject &parent, + const ConstString &name, + const ClangASTType &cast_type +) : + ValueObject(parent), + m_cast_type (cast_type) +{ + SetName (name); + m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType()); +} + +ValueObjectCast::~ValueObjectCast() +{ +} + +lldb::clang_type_t +ValueObjectCast::GetClangTypeImpl () +{ + return m_cast_type.GetOpaqueQualType(); +} + +uint32_t +ValueObjectCast::CalculateNumChildren() +{ + return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true); +} + +clang::ASTContext * +ValueObjectCast::GetClangASTImpl () +{ + return m_cast_type.GetASTContext(); +} + +size_t +ValueObjectCast::GetByteSize() +{ + return m_value.GetValueByteSize(GetClangAST(), NULL); +} + +lldb::ValueType +ValueObjectCast::GetValueType() const +{ + // Let our parent answer global, local, argument, etc... + return m_parent->GetValueType(); +} + +bool +ValueObjectCast::UpdateValue () +{ + SetValueIsValid (false); + m_error.Clear(); + + if (m_parent->UpdateValueIfNeeded(false)) + { + Value old_value(m_value); + m_update_point.SetUpdated(); + m_value = m_parent->GetValue(); + m_value.SetContext (Value::eContextTypeClangType, GetClangType()); + SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren()); + if (ClangASTContext::IsAggregateType (GetClangType())) + { + // this value object represents an aggregate type whose + // children have values, but this object does not. So we + // say we are changed if our location has changed. + SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); + } + ExecutionContext exe_ctx (GetExecutionContextRef()); + m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get()); + SetValueDidChange (m_parent->GetValueDidChange()); + return true; + } + + // The dynamic value failed to get an error, pass the error along + if (m_error.Success() && m_parent->GetError().Fail()) + m_error = m_parent->GetError(); + SetValueIsValid (false); + return false; +} + +bool +ValueObjectCast::IsInScope () +{ + return m_parent->IsInScope(); +} diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index dfddbd97c95..2b5c605dee6 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -20,6 +20,7 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" @@ -32,112 +33,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" - using namespace lldb_private; -lldb::ValueObjectSP -ValueObjectCast::Create (ValueObject &parent, - const ConstString &name, - const ClangASTType &cast_type) -{ - ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type); - return cast_valobj_ptr->GetSP(); -} - -ValueObjectCast::ValueObjectCast -( - ValueObject &parent, - const ConstString &name, - const ClangASTType &cast_type -) : - ValueObject(parent), - m_cast_type (cast_type) -{ - SetName (name); - m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType()); -} - -ValueObjectCast::~ValueObjectCast() -{ -} - -lldb::clang_type_t -ValueObjectCast::GetClangTypeImpl () -{ - return m_cast_type.GetOpaqueQualType(); -} - -uint32_t -ValueObjectCast::CalculateNumChildren() -{ - return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true); -} - -clang::ASTContext * -ValueObjectCast::GetClangASTImpl () -{ - return m_cast_type.GetASTContext(); -} - -size_t -ValueObjectCast::GetByteSize() -{ - return m_value.GetValueByteSize(GetClangAST(), NULL); -} - -lldb::ValueType -ValueObjectCast::GetValueType() const -{ - // Let our parent answer global, local, argument, etc... - return m_parent->GetValueType(); -} - -bool -ValueObjectCast::UpdateValue () -{ - SetValueIsValid (false); - m_error.Clear(); - - if (m_parent->UpdateValueIfNeeded(false)) - { - Value old_value(m_value); - m_update_point.SetUpdated(); - m_value = m_parent->GetValue(); - m_value.SetContext (Value::eContextTypeClangType, GetClangType()); - SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren()); - if (ClangASTContext::IsAggregateType (GetClangType())) - { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. - SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); - } - ExecutionContext exe_ctx (GetExecutionContextRef()); - m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get()); - SetValueDidChange (m_parent->GetValueDidChange()); - return true; - } - - // The dynamic value failed to get an error, pass the error along - if (m_error.Success() && m_parent->GetError().Fail()) - m_error = m_parent->GetError(); - SetValueIsValid (false); - return false; -} - - - -bool -ValueObjectCast::IsInScope () -{ - return m_parent->IsInScope(); -} - -//---------------------------------------------------------------------- - - - - ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) : ValueObject(parent), m_address (), |