[Lldb-commits] [lldb] r130035 - in /lldb/trunk: include/lldb/Core/ include/lldb/Utility/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Target/ test/objc-stepping/
Jim Ingham
jingham at apple.com
Fri Apr 22 16:53:53 PDT 2011
Author: jingham
Date: Fri Apr 22 18:53:53 2011
New Revision: 130035
URL: http://llvm.org/viewvc/llvm-project?rev=130035&view=rev
Log:
Fix up how the ValueObjects manage their life cycle so that you can hand out a shared
pointer to a ValueObject or any of its dependent ValueObjects, and the whole cluster will
stay around as long as that shared pointer stays around.
Added:
lldb/trunk/include/lldb/Utility/SharedCluster.h
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectChild.h
lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
lldb/trunk/include/lldb/Core/ValueObjectMemory.h
lldb/trunk/include/lldb/Core/ValueObjectRegister.h
lldb/trunk/include/lldb/Core/ValueObjectVariable.h
lldb/trunk/include/lldb/Utility/SharingPtr.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectConstResult.cpp
lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
lldb/trunk/source/Core/ValueObjectMemory.cpp
lldb/trunk/source/Core/ValueObjectRegister.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/ClangExpressionVariable.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/test/objc-stepping/TestObjCStepping.py
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Apr 22 18:53:53 2011
@@ -27,10 +27,12 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackID.h"
+#include "lldb/Utility/SharedCluster.h"
namespace lldb_private {
/// ValueObject:
+///
/// This abstract class provides an interface to a particular value, be it a register, a local or global variable,
/// that is evaluated in some particular scope. The ValueObject also has the capibility of being the "child" of
/// some other variable object, and in turn of having children.
@@ -38,6 +40,27 @@
/// particular ExecutionContextScope. If it is a child, it inherits the ExecutionContextScope from its parent.
/// The ValueObject will update itself if necessary before fetching its value, summary, object description, etc.
/// But it will always update itself in the ExecutionContextScope with which it was originally created.
+
+/// A brief note on life cycle management for ValueObjects. This is a little tricky because a ValueObject can contain
+/// various other ValueObjects - the Dynamic Value, its children, the dereference value, etc. Any one of these can be
+/// handed out as a shared pointer, but for that contained value object to be valid, the root object and potentially other
+/// of the value objects need to stay around.
+/// We solve this problem by handing out shared pointers to the Value Object and any of its dependents using a shared
+/// ClusterManager. This treats each shared pointer handed out for the entire cluster as a reference to the whole
+/// cluster. The whole cluster will stay around until the last reference is released.
+///
+/// The ValueObject mostly handle this automatically, if a value object is made with a Parent ValueObject, then it adds
+/// itself to the ClusterManager of the parent.
+
+/// It does mean that external to the ValueObjects we should only ever make available ValueObjectSP's, never ValueObjects
+/// or pointers to them. So all the "Root level" ValueObject derived constructors should be private, and
+/// should implement a Create function that new's up object and returns a Shared Pointer that it gets from the GetSP() method.
+///
+/// However, if you are making an derived ValueObject that will be contained in a parent value object, you should just
+/// hold onto a pointer to it internally, and by virtue of passing the parent ValueObject into its constructor, it will
+/// be added to the ClusterManager for the parent. Then if you ever hand out a Shared Pointer to the contained ValueObject,
+/// just do so by calling GetSP() on the contained object.
+
class ValueObject : public UserID
{
public:
@@ -189,8 +212,6 @@
return m_update_point.GetExecutionContextScope();
}
- friend class ValueObjectList;
-
virtual ~ValueObject();
//------------------------------------------------------------------
@@ -331,10 +352,17 @@
bool
Write ();
+ lldb::ValueObjectSP
+ GetSP ()
+ {
+ return m_manager->GetSharedPointer(this);
+ }
+
+protected:
void
AddSyntheticChild (const ConstString &key,
- lldb::ValueObjectSP& valobj_sp);
-
+ ValueObject *valobj);
+public:
lldb::ValueObjectSP
GetSyntheticChild (const ConstString &key) const;
@@ -344,9 +372,6 @@
lldb::ValueObjectSP
GetDynamicValue (bool can_create);
- lldb::ValueObjectSP
- GetDynamicValue (bool can_create, lldb::ValueObjectSP &owning_valobj_sp);
-
virtual lldb::ValueObjectSP
CreateConstantValue (const ConstString &name);
@@ -437,6 +462,8 @@
}
protected:
+ typedef ClusterManager<ValueObject> ValueObjectManager;
+
//------------------------------------------------------------------
// Classes that inherit from ValueObject can see and modify these
//------------------------------------------------------------------
@@ -454,12 +481,19 @@
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.
- std::vector<lldb::ValueObjectSP> m_children;
- std::map<ConstString, lldb::ValueObjectSP> m_synthetic_children;
- lldb::ValueObjectSP m_dynamic_value_sp;
- lldb::ValueObjectSP m_addr_of_valobj_sp; // These two shared pointers help root the ValueObject shared pointers that
- lldb::ValueObjectSP m_deref_valobj_sp; // we hand out, so that we can use them in their dynamic types and ensure
- // they will last as long as this ValueObject...
+
+ ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
+ // without a parent.) The manager gets passed through all the generations of
+ // dependent objects, and will keep the whole cluster of objects alive as long
+ // as a shared pointer to any of them has been handed out. Shared pointers to
+ // value objects must always be made with the GetSP method.
+
+ std::vector<ValueObject *> m_children;
+ std::map<ConstString, ValueObject *> m_synthetic_children;
+ ValueObject *m_dynamic_value;
+ lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
+ // as an independent ValueObjectConstResult, which isn't managed by us.
+ ValueObject *m_deref_valobj;
lldb::Format m_format;
bool m_value_is_valid:1,
@@ -469,11 +503,10 @@
m_pointers_point_to_load_addrs:1,
m_is_deref_of_parent:1;
- friend class CommandObjectExpression;
- friend class ClangExpressionVariable;
- friend class ClangExpressionDeclMap; // For GetValue...
- friend class Target;
- friend class ValueObjectChild;
+ friend class ClangExpressionDeclMap; // For GetValue
+ friend class ClangExpressionVariable; // For SetName
+ friend class Target; // For SetName
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
@@ -492,6 +525,12 @@
ValueObject (ValueObject &parent);
+ ValueObjectManager *
+ GetManager()
+ {
+ return m_manager;
+ }
+
virtual bool
UpdateValue () = 0;
@@ -499,7 +538,8 @@
CalculateDynamicValue ();
// Should only be called by ValueObject::GetChildAtIndex()
- virtual lldb::ValueObjectSP
+ // Returns a ValueObject managed by this ValueObject's manager.
+ virtual ValueObject *
CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
// Should only be called by ValueObject::GetNumChildren()
Modified: lldb/trunk/include/lldb/Core/ValueObjectChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectChild.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectChild.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectChild.h Fri Apr 22 18:53:53 2011
@@ -24,18 +24,6 @@
class ValueObjectChild : public ValueObject
{
public:
- ValueObjectChild (ValueObject &parent,
- clang::ASTContext *clang_ast,
- void *clang_type,
- const ConstString &name,
- uint32_t byte_size,
- int32_t byte_offset,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool is_base_class,
- bool is_deref_of_parent);
-
-
virtual ~ValueObjectChild();
virtual size_t
@@ -117,6 +105,18 @@
// ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
private:
+ friend class ValueObject;
+ ValueObjectChild (ValueObject &parent,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ uint32_t byte_size,
+ int32_t byte_offset,
+ uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset,
+ bool is_base_class,
+ bool is_deref_of_parent);
+
DISALLOW_COPY_AND_ASSIGN (ValueObjectChild);
};
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Fri Apr 22 18:53:53 2011
@@ -24,35 +24,40 @@
class ValueObjectConstResult : public ValueObject
{
public:
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- clang::ASTContext *clang_ast,
- void *clang_type,
- const ConstString &name,
- const DataExtractor &data);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- clang::ASTContext *clang_ast,
- void *clang_type,
- const ConstString &name,
- const lldb::DataBufferSP &result_data_sp,
- lldb::ByteOrder byte_order,
- uint8_t addr_size);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- clang::ASTContext *clang_ast,
- void *clang_type,
- const ConstString &name,
- lldb::addr_t address,
- AddressType address_type,
- uint8_t addr_byte_size);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size);
+
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const DataExtractor &data);
+
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ lldb::addr_t address,
+ AddressType address_type,
+ uint8_t addr_byte_size);
// When an expression fails to evaluate, we return an error
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const Error& error);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ const Error& error);
virtual ~ValueObjectConstResult();
@@ -102,6 +107,35 @@
uint32_t m_byte_size;
private:
+ ValueObjectConstResult (ExecutionContextScope *exe_scope,
+ lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size);
+
+ ValueObjectConstResult (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const DataExtractor &data);
+
+ ValueObjectConstResult (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order,
+ uint8_t addr_size);
+
+ ValueObjectConstResult (ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ lldb::addr_t address,
+ AddressType address_type,
+ uint8_t addr_byte_size);
+
+ ValueObjectConstResult (ExecutionContextScope *exe_scope,
+ const Error& error);
+
DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult);
};
Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Fri Apr 22 18:53:53 2011
@@ -25,8 +25,6 @@
class ValueObjectDynamicValue : public ValueObject
{
public:
- ValueObjectDynamicValue (ValueObject &parent);
-
virtual
~ValueObjectDynamicValue();
@@ -94,6 +92,9 @@
lldb::ValueObjectSP m_owning_valobj_sp;
private:
+ friend class ValueObject;
+ ValueObjectDynamicValue (ValueObject &parent);
+
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Core/ValueObjectMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Fri Apr 22 18:53:53 2011
@@ -25,10 +25,11 @@
class ValueObjectMemory : public ValueObject
{
public:
- ValueObjectMemory (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- lldb::TypeSP &type_sp);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope,
+ const char *name,
+ const Address &address,
+ lldb::TypeSP &type_sp);
virtual
~ValueObjectMemory();
@@ -62,6 +63,11 @@
lldb::TypeSP m_type_sp;
private:
+ ValueObjectMemory (ExecutionContextScope *exe_scope,
+ const char *name,
+ const Address &address,
+ lldb::TypeSP &type_sp);
+
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Fri Apr 22 18:53:53 2011
@@ -26,7 +26,6 @@
class ValueObjectRegisterContext : public ValueObject
{
public:
- ValueObjectRegisterContext (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp);
virtual
~ValueObjectRegisterContext();
@@ -52,7 +51,7 @@
virtual uint32_t
CalculateNumChildren();
- virtual lldb::ValueObjectSP
+ virtual ValueObject *
CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
protected:
@@ -62,6 +61,7 @@
lldb::RegisterContextSP m_reg_ctx_sp;
private:
+ ValueObjectRegisterContext (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp);
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
@@ -71,7 +71,8 @@
class ValueObjectRegisterSet : public ValueObject
{
public:
- ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
virtual
~ValueObjectRegisterSet();
@@ -97,7 +98,7 @@
virtual uint32_t
CalculateNumChildren();
- virtual lldb::ValueObjectSP
+ virtual ValueObject *
CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
virtual lldb::ValueObjectSP
@@ -116,6 +117,9 @@
uint32_t m_reg_set_idx;
private:
+ friend class ValueObjectRegisterContext;
+ ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
+
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
@@ -125,8 +129,8 @@
class ValueObjectRegister : public ValueObject
{
public:
- ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
- ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
virtual
~ValueObjectRegister();
@@ -165,6 +169,11 @@
private:
void
ConstructObject ();
+
+ friend class ValueObjectRegisterSet;
+ ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
+ ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
+
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Fri Apr 22 18:53:53 2011
@@ -25,7 +25,8 @@
class ValueObjectVariable : public ValueObject
{
public:
- ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
+ static lldb::ValueObjectSP
+ Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
virtual
~ValueObjectVariable();
@@ -58,6 +59,7 @@
lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon
private:
+ ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
//------------------------------------------------------------------
// For ValueObject only
//------------------------------------------------------------------
Added: lldb/trunk/include/lldb/Utility/SharedCluster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharedCluster.h?rev=130035&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharedCluster.h (added)
+++ lldb/trunk/include/lldb/Utility/SharedCluster.h Fri Apr 22 18:53:53 2011
@@ -0,0 +1,106 @@
+//===---------------------SharedCluster.h --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_SharedCluster_h_
+#define utility_SharedCluster_h_
+
+#include "lldb/Utility/SharingPtr.h"
+#include "lldb/Host/Mutex.h"
+
+namespace lldb_private {
+
+namespace imp
+{
+ template <typename T>
+ class shared_ptr_refcount : public lldb_private::imp::shared_count
+ {
+ public:
+ template<class Y> shared_ptr_refcount (Y *in) : manager(in), shared_count (0) {}
+
+ shared_ptr_refcount() : shared_count (0) {}
+
+ virtual ~shared_ptr_refcount ()
+ {
+ }
+
+ virtual void on_zero_shared ()
+ {
+ manager->DecrementRefCount();
+ }
+ private:
+ T *manager;
+ };
+
+} // namespace imp
+
+template <class T>
+class ClusterManager
+{
+public:
+ ClusterManager () :
+ m_external_ref(0),
+ m_objects(),
+ m_mutex(Mutex::eMutexTypeNormal) {}
+
+ ~ClusterManager ()
+ {
+ size_t n_items = m_objects.size();
+ for (size_t i = 0; i < n_items; i++)
+ {
+ delete m_objects[i];
+ }
+ }
+
+ void ManageObject (T *new_object)
+ {
+ m_mutex.Lock();
+ if (!ContainsObject(new_object))
+ m_objects.push_back (new_object);
+ m_mutex.Unlock();
+ }
+
+ typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object)
+ {
+ m_mutex.Lock();
+ m_external_ref++;
+ assert (ContainsObject(desired_object));
+ m_mutex.Unlock();
+
+ return typename lldb_private::SharingPtr<T> (desired_object, new imp::shared_ptr_refcount<ClusterManager> (this));
+ }
+
+private:
+
+ bool ContainsObject (const T *desired_object)
+ {
+ typename std::vector<T *>::iterator pos;
+ pos = std::find(m_objects.begin(), m_objects.end(), desired_object);
+
+ return pos < m_objects.end();
+ }
+
+ void DecrementRefCount ()
+ {
+ m_mutex.Lock();
+ m_external_ref--;
+ if (m_external_ref == 0)
+ delete this;
+ else
+ m_mutex.Unlock();
+ }
+
+ friend class imp::shared_ptr_refcount<ClusterManager>;
+
+ std::vector<T *> m_objects;
+ int m_external_ref;
+ Mutex m_mutex;
+};
+
+} // namespace lldb_private
+#endif // utility_SharedCluster_h_
Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Fri Apr 22 18:53:53 2011
@@ -119,6 +119,7 @@
public:
SharingPtr();
template<class Y> explicit SharingPtr(Y* p);
+ template<class Y> explicit SharingPtr(Y* p, imp::shared_count *ctrl_block);
template<class Y> SharingPtr(const SharingPtr<Y>& r, element_type *p);
SharingPtr(const SharingPtr& r);
template<class Y>
@@ -184,6 +185,13 @@
template<class T>
template<class Y>
+SharingPtr<T>::SharingPtr(Y* p, imp::shared_count *cntrl_block)
+ : ptr_(p), cntrl_(cntrl_block)
+{
+}
+
+template<class T>
+template<class Y>
inline
SharingPtr<T>::SharingPtr(const SharingPtr<Y>& r, element_type *p)
: ptr_(p),
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Apr 22 18:53:53 2011
@@ -409,6 +409,7 @@
26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; };
26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; };
26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; };
+ 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */; };
4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; };
4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */; };
4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; };
@@ -1093,6 +1094,7 @@
4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV2.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h; sourceTree = "<group>"; };
4C1AB23A1263E5F400D0F04A /* ThreadPlanTestCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanTestCondition.cpp; path = source/Target/ThreadPlanTestCondition.cpp; sourceTree = "<group>"; };
4C1AB23E1263E61100D0F04A /* ThreadPlanTestCondition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanTestCondition.h; path = include/lldb/Target/ThreadPlanTestCondition.h; sourceTree = "<group>"; };
+ 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharedCluster.h; path = include/lldb/Utility/SharedCluster.h; sourceTree = "<group>"; };
4C43DEF9110641F300E55CBF /* ThreadPlanShouldStopHere.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanShouldStopHere.h; path = include/lldb/Target/ThreadPlanShouldStopHere.h; sourceTree = "<group>"; };
4C43DEFA110641F300E55CBF /* ThreadPlanShouldStopHere.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanShouldStopHere.cpp; path = source/Target/ThreadPlanShouldStopHere.cpp; sourceTree = "<group>"; };
4C43DF8511069BFD00E55CBF /* ThreadPlanStepInRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepInRange.h; path = include/lldb/Target/ThreadPlanStepInRange.h; sourceTree = "<group>"; };
@@ -1749,6 +1751,7 @@
961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */,
264723A511FA076E00DE380C /* CleanUp.h */,
261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */,
+ 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */,
261B5A5311C3F2AD00AABD0A /* SharingPtr.h */,
26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */,
26F996A8119B79C300412154 /* ARM_GCC_Registers.h */,
@@ -2584,6 +2587,7 @@
2671A0CE134825F6003A87BB /* ConnectionMachPort.h in Headers */,
4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */,
4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */,
+ 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Fri Apr 22 18:53:53 2011
@@ -351,6 +351,8 @@
SBFrame::FindVariable (const char *name, bool use_dynamic)
{
VariableSP var_sp;
+ SBValue sb_value;
+
if (m_opaque_sp && name && name[0])
{
VariableList variable_list;
@@ -373,8 +375,6 @@
}
}
- SBValue sb_value;
-
if (var_sp)
*sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic));
@@ -452,7 +452,7 @@
((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
(reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
{
- *sb_value = ValueObjectSP (new ValueObjectRegister (m_opaque_sp.get(), reg_ctx, reg_idx));
+ *sb_value = ValueObjectRegister::Create (m_opaque_sp.get(), reg_ctx, reg_idx);
}
}
}
@@ -472,7 +472,7 @@
((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
(reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
{
- *sb_value = ValueObjectSP (new ValueObjectRegisterSet (m_opaque_sp.get(), reg_ctx, set_idx));
+ *sb_value = ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx);
}
}
}
@@ -677,7 +677,7 @@
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
{
- value_list.Append(ValueObjectSP (new ValueObjectRegisterSet (m_opaque_sp.get(), reg_ctx, set_idx)));
+ value_list.Append(ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx));
}
}
}
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Fri Apr 22 18:53:53 2011
@@ -357,7 +357,7 @@
{
if (child_sp)
{
- lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true, child_sp);
+ lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true);
if (dynamic_sp)
child_sp = dynamic_sp;
}
@@ -410,7 +410,7 @@
{
if (child_sp)
{
- lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true, child_sp);
+ lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true);
if (dynamic_sp)
child_sp = dynamic_sp;
}
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Apr 22 18:53:53 2011
@@ -649,13 +649,6 @@
valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error);
if (valobj_sp)
{
-// if (use_dynamic)
-// {
-// lldb::ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue(true, valobj_sp);
-// if (dynamic_sp != NULL)
-// valobj_sp = dynamic_sp;
-// }
-//
if (m_options.format != eFormatDefault)
valobj_sp->SetFormat (m_options.format);
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Apr 22 18:53:53 2011
@@ -59,9 +59,11 @@
m_location_str (),
m_summary_str (),
m_object_desc_str (),
+ m_manager(parent.GetManager()),
m_children (),
m_synthetic_children (),
- m_dynamic_value_sp (),
+ m_dynamic_value (NULL),
+ m_deref_valobj(NULL),
m_format (eFormatDefault),
m_value_is_valid (false),
m_value_did_change (false),
@@ -70,6 +72,7 @@
m_pointers_point_to_load_addrs (false),
m_is_deref_of_parent (false)
{
+ m_manager->ManageObject(this);
}
//----------------------------------------------------------------------
@@ -88,9 +91,11 @@
m_location_str (),
m_summary_str (),
m_object_desc_str (),
+ m_manager(),
m_children (),
m_synthetic_children (),
- m_dynamic_value_sp (),
+ m_dynamic_value (NULL),
+ m_deref_valobj(NULL),
m_format (eFormatDefault),
m_value_is_valid (false),
m_value_did_change (false),
@@ -99,6 +104,8 @@
m_pointers_point_to_load_addrs (false),
m_is_deref_of_parent (false)
{
+ m_manager = new ValueObjectManager();
+ m_manager->ManageObject (this);
}
//----------------------------------------------------------------------
@@ -282,14 +289,15 @@
if (idx < GetNumChildren())
{
// Check if we have already made the child value object?
- if (can_create && m_children[idx].get() == NULL)
+ if (can_create && m_children[idx] == NULL)
{
// No we haven't created the child at this index, so lets have our
// subclass do it and cache the result for quick future access.
m_children[idx] = CreateChildAtIndex (idx, false, 0);
}
-
- child_sp = m_children[idx];
+
+ if (m_children[idx] != NULL)
+ return m_children[idx]->GetSP();
}
}
return child_sp;
@@ -377,10 +385,10 @@
m_name = name;
}
-ValueObjectSP
+ValueObject *
ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
- ValueObjectSP valobj_sp;
+ ValueObject *valobj;
if (UpdateValueIfNeeded())
{
@@ -420,22 +428,22 @@
if (!child_name_str.empty())
child_name.SetCString (child_name_str.c_str());
- valobj_sp.reset (new ValueObjectChild (*this,
- clang_ast,
- child_clang_type,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent));
+ valobj = new ValueObjectChild (*this,
+ clang_ast,
+ child_clang_type,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent);
if (m_pointers_point_to_load_addrs)
- valobj_sp->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs);
+ valobj->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs);
}
}
- return valobj_sp;
+ return valobj;
}
const char *
@@ -913,18 +921,18 @@
}
void
-ValueObject::AddSyntheticChild (const ConstString &key, ValueObjectSP& valobj_sp)
+ValueObject::AddSyntheticChild (const ConstString &key, ValueObject *valobj)
{
- m_synthetic_children[key] = valobj_sp;
+ m_synthetic_children[key] = valobj;
}
ValueObjectSP
ValueObject::GetSyntheticChild (const ConstString &key) const
{
ValueObjectSP synthetic_child_sp;
- std::map<ConstString, ValueObjectSP>::const_iterator pos = m_synthetic_children.find (key);
+ std::map<ConstString, ValueObject *>::const_iterator pos = m_synthetic_children.find (key);
if (pos != m_synthetic_children.end())
- synthetic_child_sp = pos->second;
+ synthetic_child_sp = pos->second->GetSP();
return synthetic_child_sp;
}
@@ -960,13 +968,17 @@
synthetic_child_sp = GetSyntheticChild (index_const_str);
if (!synthetic_child_sp)
{
+ ValueObject *synthetic_child;
// We haven't made a synthetic array member for INDEX yet, so
// lets make one and cache it for any future reference.
- synthetic_child_sp = CreateChildAtIndex(0, true, index);
+ synthetic_child = CreateChildAtIndex(0, true, index);
// Cache the value if we got one back...
- if (synthetic_child_sp)
- AddSyntheticChild(index_const_str, synthetic_child_sp);
+ if (synthetic_child)
+ {
+ AddSyntheticChild(index_const_str, synthetic_child);
+ synthetic_child_sp = synthetic_child->GetSP();
+ }
}
}
return synthetic_child_sp;
@@ -975,7 +987,7 @@
void
ValueObject::CalculateDynamicValue ()
{
- if (!m_dynamic_value_sp && !IsDynamic())
+ if (!m_dynamic_value && !IsDynamic())
{
Process *process = m_update_point.GetProcess();
bool worth_having_dynamic_value = false;
@@ -1005,33 +1017,25 @@
}
if (worth_having_dynamic_value)
- m_dynamic_value_sp.reset (new ValueObjectDynamicValue (*this));
- }
-}
+ m_dynamic_value = new ValueObjectDynamicValue (*this);
+
+// if (worth_having_dynamic_value)
+// printf ("Adding dynamic value %s (%p) to (%p) - manager %p.\n", m_name.GetCString(), m_dynamic_value, this, m_manager);
-lldb::ValueObjectSP
-ValueObject::GetDynamicValue (bool can_create)
-{
- if (!IsDynamic() && m_dynamic_value_sp == NULL && can_create)
- {
- CalculateDynamicValue();
}
- return m_dynamic_value_sp;
}
-lldb::ValueObjectSP
-ValueObject::GetDynamicValue (bool can_create, lldb::ValueObjectSP &owning_valobj_sp)
+ValueObjectSP
+ValueObject::GetDynamicValue (bool can_create)
{
- if (!IsDynamic() && m_dynamic_value_sp == NULL && can_create)
+ if (!IsDynamic() && m_dynamic_value == NULL && can_create)
{
CalculateDynamicValue();
- if (m_dynamic_value_sp)
- {
- ValueObjectDynamicValue *as_dynamic_value = static_cast<ValueObjectDynamicValue *>(m_dynamic_value_sp.get());
- as_dynamic_value->SetOwningSP (owning_valobj_sp);
- }
}
- return m_dynamic_value_sp;
+ if (m_dynamic_value)
+ return m_dynamic_value->GetSP();
+ else
+ return ValueObjectSP();
}
bool
@@ -1352,17 +1356,17 @@
m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0);
- valobj_sp.reset (new ValueObjectConstResult (exe_scope,
- ast,
- GetClangType(),
- name,
- data));
+ valobj_sp = ValueObjectConstResult::Create (exe_scope,
+ ast,
+ GetClangType(),
+ name,
+ data);
}
}
if (!valobj_sp)
{
- valobj_sp.reset (new ValueObjectConstResult (NULL, m_error));
+ valobj_sp = ValueObjectConstResult::Create (NULL, m_error);
}
return valobj_sp;
}
@@ -1370,8 +1374,8 @@
lldb::ValueObjectSP
ValueObject::Dereference (Error &error)
{
- if (m_deref_valobj_sp)
- return m_deref_valobj_sp;
+ if (m_deref_valobj)
+ return m_deref_valobj->GetSP();
const bool is_pointer_type = IsPointerType();
if (is_pointer_type)
@@ -1408,22 +1412,23 @@
if (!child_name_str.empty())
child_name.SetCString (child_name_str.c_str());
- m_deref_valobj_sp.reset (new ValueObjectChild (*this,
- clang_ast,
- child_clang_type,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class,
- child_is_deref_of_parent));
+ m_deref_valobj = new ValueObjectChild (*this,
+ clang_ast,
+ child_clang_type,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class,
+ child_is_deref_of_parent);
}
}
- if (m_deref_valobj_sp)
+ if (m_deref_valobj)
{
error.Clear();
+ return m_deref_valobj->GetSP();
}
else
{
@@ -1434,9 +1439,8 @@
error.SetErrorStringWithFormat("dereference failed: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
else
error.SetErrorStringWithFormat("not a pointer type: (%s) %s", GetTypeName().AsCString("<invalid type>"), strm.GetString().c_str());
+ return ValueObjectSP();
}
-
- return m_deref_valobj_sp;
}
lldb::ValueObjectSP
@@ -1472,13 +1476,13 @@
{
std::string name (1, '&');
name.append (m_name.AsCString(""));
- m_addr_of_valobj_sp.reset (new ValueObjectConstResult (GetExecutionContextScope(),
- ast,
- ClangASTContext::CreatePointerType (ast, clang_type),
- ConstString (name.c_str()),
- addr,
- eAddressTypeInvalid,
- m_data.GetAddressByteSize()));
+ m_addr_of_valobj_sp = ValueObjectConstResult::Create (GetExecutionContextScope(),
+ ast,
+ ClangASTContext::CreatePointerType (ast, clang_type),
+ ConstString (name.c_str()),
+ addr,
+ eAddressTypeInvalid,
+ m_data.GetAddressByteSize());
}
}
break;
Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Fri Apr 22 18:53:53 2011
@@ -26,6 +26,19 @@
using namespace lldb;
using namespace lldb_private;
+ValueObjectSP
+ValueObjectConstResult::Create
+(
+ ExecutionContextScope *exe_scope,
+ ByteOrder byte_order,
+ uint32_t addr_byte_size
+)
+{
+ return (new ValueObjectConstResult (exe_scope,
+ byte_order,
+ addr_byte_size))->GetSP();
+}
+
ValueObjectConstResult::ValueObjectConstResult
(
ExecutionContextScope *exe_scope,
@@ -44,6 +57,23 @@
m_pointers_point_to_load_addrs = true;
}
+ValueObjectSP
+ValueObjectConstResult::Create
+(
+ ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const DataExtractor &data
+)
+{
+ return (new ValueObjectConstResult (exe_scope,
+ clang_ast,
+ clang_type,
+ name,
+ data))->GetSP();
+}
+
ValueObjectConstResult::ValueObjectConstResult
(
ExecutionContextScope *exe_scope,
@@ -67,6 +97,27 @@
m_pointers_point_to_load_addrs = true;
}
+ValueObjectSP
+ValueObjectConstResult::Create
+(
+ ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ const lldb::DataBufferSP &data_sp,
+ lldb::ByteOrder data_byte_order,
+ uint8_t data_addr_size
+)
+{
+ return (new ValueObjectConstResult (exe_scope,
+ clang_ast,
+ clang_type,
+ name,
+ data_sp,
+ data_byte_order,
+ data_addr_size))->GetSP();
+}
+
ValueObjectConstResult::ValueObjectConstResult
(
ExecutionContextScope *exe_scope,
@@ -94,6 +145,27 @@
m_pointers_point_to_load_addrs = true;
}
+ValueObjectSP
+ValueObjectConstResult::Create
+(
+ ExecutionContextScope *exe_scope,
+ clang::ASTContext *clang_ast,
+ void *clang_type,
+ const ConstString &name,
+ lldb::addr_t address,
+ AddressType address_type,
+ uint8_t addr_byte_size
+)
+{
+ return (new ValueObjectConstResult (exe_scope,
+ clang_ast,
+ clang_type,
+ name,
+ address,
+ address_type,
+ addr_byte_size))->GetSP();
+}
+
ValueObjectConstResult::ValueObjectConstResult
(
ExecutionContextScope *exe_scope,
@@ -128,6 +200,17 @@
m_pointers_point_to_load_addrs = true;
}
+ValueObjectSP
+ValueObjectConstResult::Create
+(
+ ExecutionContextScope *exe_scope,
+ const Error& error
+)
+{
+ return (new ValueObjectConstResult (exe_scope,
+ error))->GetSP();
+}
+
ValueObjectConstResult::ValueObjectConstResult (
ExecutionContextScope *exe_scope,
const Error& error) :
Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Fri Apr 22 18:53:53 2011
@@ -39,14 +39,6 @@
m_address (),
m_type_sp()
{
- // THINK ABOUT: It looks ugly to doctor up the name like this. But if
- // people find it confusing to tell the difference, we may want to do something...
-
-// std::string dynamic_name ("<dynamic value for \"");
-// dynamic_name.append(parent.GetName().AsCString());
-// dynamic_name.append("\">");
-//
-// SetName (dynamic_name.c_str());
SetName (parent.GetName().AsCString());
}
Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectMemory.cpp Fri Apr 22 18:53:53 2011
@@ -30,9 +30,18 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-
+using namespace lldb;
using namespace lldb_private;
+ValueObjectSP
+ValueObjectMemory::Create (ExecutionContextScope *exe_scope,
+ const char *name,
+ const Address &address,
+ lldb::TypeSP &type_sp)
+{
+ return (new ValueObjectMemory (exe_scope, name, address, type_sp))->GetSP();
+}
+
ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope,
const char *name,
const Address &address,
Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp Fri Apr 22 18:53:53 2011
@@ -95,21 +95,29 @@
return m_error.Success();
}
-ValueObjectSP
+ValueObject *
ValueObjectRegisterContext::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
- ValueObjectSP valobj_sp;
-
+ ValueObject *new_valobj = NULL;
+
const uint32_t num_children = GetNumChildren();
if (idx < num_children)
- valobj_sp.reset (new ValueObjectRegisterSet(GetExecutionContextScope(), m_reg_ctx_sp, idx));
- return valobj_sp;
+ new_valobj = new ValueObjectRegisterSet(GetExecutionContextScope(), m_reg_ctx_sp, idx);
+
+ return new_valobj;
}
#pragma mark -
#pragma mark ValueObjectRegisterSet
+ValueObjectSP
+ValueObjectRegisterSet::Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx)
+{
+ return (new ValueObjectRegisterSet (exe_scope, reg_ctx_sp, set_idx))->GetSP();
+}
+
+
ValueObjectRegisterSet::ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx, uint32_t reg_set_idx) :
ValueObject (exe_scope),
m_reg_ctx_sp (reg_ctx),
@@ -199,30 +207,33 @@
}
-ValueObjectSP
+ValueObject *
ValueObjectRegisterSet::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
- ValueObjectSP valobj_sp;
+ ValueObject *valobj;
if (m_reg_ctx_sp && m_reg_set)
{
const uint32_t num_children = GetNumChildren();
if (idx < num_children)
- valobj_sp.reset (new ValueObjectRegister(*this, m_reg_ctx_sp, m_reg_set->registers[idx]));
+ valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, m_reg_set->registers[idx]);
}
- return valobj_sp;
+ return valobj;
}
lldb::ValueObjectSP
ValueObjectRegisterSet::GetChildMemberWithName (const ConstString &name, bool can_create)
{
- ValueObjectSP valobj_sp;
+ ValueObject *valobj = NULL;
if (m_reg_ctx_sp && m_reg_set)
{
const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName (name.AsCString());
if (reg_info != NULL)
- valobj_sp.reset (new ValueObjectRegister(*this, m_reg_ctx_sp, reg_info->kinds[eRegisterKindLLDB]));
+ valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, reg_info->kinds[eRegisterKindLLDB]);
}
- return valobj_sp;
+ if (valobj)
+ return valobj->GetSP();
+ else
+ return ValueObjectSP();
}
uint32_t
@@ -265,6 +276,12 @@
ConstructObject();
}
+ValueObjectSP
+ValueObjectRegister::Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num)
+{
+ return (new ValueObjectRegister (exe_scope, reg_ctx_sp, reg_num))->GetSP();
+}
+
ValueObjectRegister::ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx, uint32_t reg_num) :
ValueObject (exe_scope),
m_reg_ctx_sp (reg_ctx),
Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Fri Apr 22 18:53:53 2011
@@ -32,6 +32,12 @@
using namespace lldb_private;
+lldb::ValueObjectSP
+ValueObjectVariable::Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
+{
+ return (new ValueObjectVariable (exe_scope, var_sp))->GetSP();
+}
+
ValueObjectVariable::ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp) :
ValueObject(exe_scope),
m_variable_sp(var_sp)
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Apr 22 18:53:53 2011
@@ -987,13 +987,13 @@
// If the reference comes from the program, then the ClangExpressionVariable's
// live variable data hasn't been set up yet. Do this now.
- var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope (),
- var_sp->GetTypeFromUser().GetASTContext(),
- var_sp->GetTypeFromUser().GetOpaqueQualType(),
- var_sp->GetName(),
- mem,
- eAddressTypeLoad,
- pvar_byte_size));
+ var_sp->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope (),
+ var_sp->GetTypeFromUser().GetASTContext(),
+ var_sp->GetTypeFromUser().GetOpaqueQualType(),
+ var_sp->GetName(),
+ mem,
+ eAddressTypeLoad,
+ pvar_byte_size);
}
if (!var_sp->m_live_sp)
@@ -1082,13 +1082,13 @@
// Put the location of the spare memory into the live data of the ValueObject.
- var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope(),
- var_sp->GetTypeFromUser().GetASTContext(),
- var_sp->GetTypeFromUser().GetOpaqueQualType(),
- var_sp->GetName(),
- mem,
- eAddressTypeLoad,
- pvar_byte_size));
+ var_sp->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
+ var_sp->GetTypeFromUser().GetASTContext(),
+ var_sp->GetTypeFromUser().GetOpaqueQualType(),
+ var_sp->GetName(),
+ mem,
+ eAddressTypeLoad,
+ pvar_byte_size);
// Clear the flag if the variable will never be deallocated.
@@ -1347,13 +1347,13 @@
// Put the location of the spare memory into the live data of the ValueObject.
- expr_var->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope(),
- type.GetASTContext(),
- type.GetOpaqueQualType(),
- name,
- mem,
- eAddressTypeLoad,
- value_byte_size));
+ expr_var->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
+ type.GetASTContext(),
+ type.GetOpaqueQualType(),
+ name,
+ mem,
+ eAddressTypeLoad,
+ value_byte_size);
// Now write the location of the area into the struct.
Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Fri Apr 22 18:53:53 2011
@@ -29,7 +29,7 @@
m_parser_vars(),
m_jit_vars (),
m_flags (EVNone),
- m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size))
+ m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
{
}
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Apr 22 18:53:53 2011
@@ -570,7 +570,7 @@
{
error.SetErrorString ("Must have a process to evaluate expressions.");
- result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
+ result_valobj_sp = ValueObjectConstResult::Create (NULL, error);
return eExecutionSetupError;
}
@@ -590,7 +590,7 @@
else
error.SetErrorString (install_errors.GetString().c_str());
- result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
+ result_valobj_sp = ValueObjectConstResult::Create (NULL, error);
return eExecutionSetupError;
}
@@ -672,7 +672,7 @@
}
if (result_valobj_sp.get() == NULL)
- result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
+ result_valobj_sp = ValueObjectConstResult::Create (NULL, error);
return execution_results;
}
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Fri Apr 22 18:53:53 2011
@@ -628,7 +628,7 @@
var_path.erase(0, child_name.GetLength());
if (dynamic_value)
{
- ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp));
+ ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true));
if (dynamic_value_sp)
child_valobj_sp = dynamic_value_sp;
}
@@ -690,7 +690,7 @@
separator_idx = var_path.find_first_of(".-[");
if (dynamic_value)
{
- ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp));
+ ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true));
if (dynamic_value_sp)
child_valobj_sp = dynamic_value_sp;
}
@@ -825,14 +825,14 @@
{
if (m_variable_list_value_objects.GetSize() < num_variables)
m_variable_list_value_objects.Resize(num_variables);
- valobj_sp.reset (new ValueObjectVariable (this, variable_sp));
+ valobj_sp = ValueObjectVariable::Create (this, variable_sp);
m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
}
}
}
if (use_dynamic && valobj_sp)
{
- ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (true, valobj_sp);
+ ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (true);
if (dynamic_sp)
return dynamic_sp;
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Apr 22 18:53:53 2011
@@ -931,7 +931,7 @@
{
if (fetch_dynamic_value)
{
- ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(true, result_valobj_sp);
+ ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(true);
if (dynamic_sp)
result_valobj_sp = dynamic_sp;
}
Modified: lldb/trunk/test/objc-stepping/TestObjCStepping.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-stepping/TestObjCStepping.py?rev=130035&r1=130034&r2=130035&view=diff
==============================================================================
--- lldb/trunk/test/objc-stepping/TestObjCStepping.py (original)
+++ lldb/trunk/test/objc-stepping/TestObjCStepping.py Fri Apr 22 18:53:53 2011
@@ -86,6 +86,10 @@
self.assertTrue(mySource_isa.IsValid(), "Found mySource->isa local variable.")
mySource_isa.GetValue (thread.GetFrameAtIndex(0))
+ # Lets delete mySource so we can check that after stepping a child variable
+ # with no parent persists and is useful.
+ del (mySource)
+
# Now step in, that should leave us in the Source randomMethod:
thread.StepInto()
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
More information about the lldb-commits
mailing list