[Lldb-commits] [lldb] r130966 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp

Greg Clayton gclayton at apple.com
Thu May 5 16:33:02 PDT 2011


Author: gclayton
Date: Thu May  5 18:32:56 2011
New Revision: 130966

URL: http://llvm.org/viewvc/llvm-project?rev=130966&view=rev
Log:
Added the ability to cast pointer types to another type, no matter what the
ValueObject is, as long as the ValueObject that is being asked to be casted
is a pointer itself.


Modified:
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/source/Core/ValueObject.cpp

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=130966&r1=130965&r2=130966&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu May  5 18:32:56 2011
@@ -377,6 +377,14 @@
     virtual lldb::ValueObjectSP
     AddressOf (Error &error);
 
+    virtual lldb::ValueObjectSP
+    CastPointerType (const char *name,
+                     ClangASTType &ast_type);
+
+    virtual lldb::ValueObjectSP
+    CastPointerType (const char *name,
+                     lldb::TypeSP &type_sp);
+
     // The backing bits of this value object were updated, clear any value
     // values, summaries or descriptions so we refetch them.
     virtual void

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=130966&r1=130965&r2=130966&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu May  5 18:32:56 2011
@@ -24,6 +24,7 @@
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Core/ValueObjectDynamicValue.h"
 #include "lldb/Core/ValueObjectList.h"
+#include "lldb/Core/ValueObjectMemory.h"
 
 #include "lldb/Host/Endian.h"
 
@@ -1498,6 +1499,48 @@
     return m_addr_of_valobj_sp;
 }
 
+
+lldb::ValueObjectSP
+ValueObject::CastPointerType (const char *name, ClangASTType &clang_ast_type)
+{
+    lldb::ValueObjectSP valobj_sp;
+    AddressType address_type;
+    const bool scalar_is_load_address = true;
+    lldb::addr_t ptr_value = GetPointerValue (address_type, scalar_is_load_address);
+    
+    if (ptr_value != LLDB_INVALID_ADDRESS)
+    {
+        Address ptr_addr (NULL, ptr_value);
+        
+        valobj_sp = ValueObjectMemory::Create (GetExecutionContextScope(),
+                                               name, 
+                                               ptr_addr, 
+                                               clang_ast_type);
+    }
+    return valobj_sp;    
+}
+
+lldb::ValueObjectSP
+ValueObject::CastPointerType (const char *name, TypeSP &type_sp)
+{
+    lldb::ValueObjectSP valobj_sp;
+    AddressType address_type;
+    const bool scalar_is_load_address = true;
+    lldb::addr_t ptr_value = GetPointerValue (address_type, scalar_is_load_address);
+    
+    if (ptr_value != LLDB_INVALID_ADDRESS)
+    {
+        Address ptr_addr (NULL, ptr_value);
+        
+        valobj_sp = ValueObjectMemory::Create (GetExecutionContextScope(),
+                                               name, 
+                                               ptr_addr, 
+                                               type_sp);
+    }
+    return valobj_sp;
+}
+
+
 ValueObject::EvaluationPoint::EvaluationPoint () :
     m_thread_id (LLDB_INVALID_UID),
     m_stop_id (0)





More information about the lldb-commits mailing list