[Lldb-commits] [lldb] r149673 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectDynamicValue.h scripts/Python/interface/SBType.i source/API/SBValue.cpp source/Core/ValueObject.cpp source/Core/ValueObjectDynamicValue.cpp
Greg Clayton
gclayton at apple.com
Thu Feb 2 21:34:10 PST 2012
Author: gclayton
Date: Thu Feb 2 23:34:10 2012
New Revision: 149673
URL: http://llvm.org/viewvc/llvm-project?rev=149673&view=rev
Log:
Fixed casting in the lldb::SBValue::Cast(SBType) function.
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
lldb/trunk/scripts/Python/interface/SBType.i
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Feb 2 23:34:10 2012
@@ -774,6 +774,9 @@
}
virtual lldb::ValueObjectSP
+ Cast (const ClangASTType &clang_ast_type);
+
+ virtual lldb::ValueObjectSP
CastPointerType (const char *name,
ClangASTType &ast_type);
Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Thu Feb 2 23:34:10 2012
@@ -15,9 +15,85 @@
// 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:
+ virtual
+ ~ValueObjectCast();
+
+ virtual size_t
+ GetByteSize();
+
+ virtual clang::ASTContext *
+ GetClangAST ();
+
+ virtual lldb::clang_type_t
+ GetClangType ();
+
+ virtual ConstString
+ GetTypeName();
+
+ 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 ();
+
+ ClangASTType m_cast_type;
+
+ private:
+ friend class ValueObject;
+ 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.
Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Thu Feb 2 23:34:10 2012
@@ -201,6 +201,15 @@
GetTemplateArgumentKind (uint32_t idx);
%pythoncode %{
+ def template_arg_array(self):
+ num_args = self.num_template_args
+ if num_args:
+ template_args = []
+ for i in range(num_args):
+ template_args.append(self.GetTemplateArgumentType(i))
+ return template_args
+ return None
+
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
@@ -222,9 +231,16 @@
__swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses
if _newclass: x = property(GetNumberOfVirtualBaseClasses, None)
+ __swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments
+ if _newclass: x = property(GetNumberOfTemplateArguments, None)
+
+ __swig_getmethods__["template_args"] = template_arg_array
+ if _newclass: x = property(template_arg_array, None)
+
__swig_getmethods__["class"] = GetTypeClass
if _newclass: x = property(GetTypeClass, None)
- %}
+
+ %}
};
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Thu Feb 2 23:34:10 2012
@@ -378,8 +378,8 @@
SBValue::Cast (SBType type)
{
lldb::SBValue sb_value;
- if (m_opaque_sp)
- sb_value = CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type);
+ if (m_opaque_sp && type.IsValid())
+ *sb_value = m_opaque_sp->Cast(type.ref().GetClangASTType());
return sb_value;
}
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Feb 2 23:34:10 2012
@@ -3429,6 +3429,12 @@
return m_addr_of_valobj_sp;
}
+ValueObjectSP
+ValueObject::Cast (const ClangASTType &clang_ast_type)
+{
+ ValueObjectSP valobj_sp(new ValueObjectCast (*this, GetName(), clang_ast_type));
+ return valobj_sp;
+}
ValueObjectSP
ValueObject::CastPointerType (const char *name, ClangASTType &clang_ast_type)
Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=149673&r1=149672&r2=149673&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Thu Feb 2 23:34:10 2012
@@ -34,6 +34,107 @@
using namespace lldb_private;
+
+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::GetClangType ()
+{
+ return m_cast_type.GetOpaqueQualType();
+}
+
+ConstString
+ValueObjectCast::GetTypeName()
+{
+ return ClangASTType::GetConstTypeName (GetClangType());
+}
+
+uint32_t
+ValueObjectCast::CalculateNumChildren()
+{
+ return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
+}
+
+clang::ASTContext *
+ValueObjectCast::GetClangAST ()
+{
+ 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 (GetExecutionContextScope());
+ m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ 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 (),
More information about the lldb-commits
mailing list