summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2011-04-22 23:53:53 +0000
committerJim Ingham <jingham@apple.com>2011-04-22 23:53:53 +0000
commit58b59f9522a0aafd4c2efe0781a9c88f005b7e00 (patch)
tree5e036735ce45e937a4d7f19579f0034ea2b6be00 /lldb/source/Core
parent0ff2b2eda3509727fdb93e2b7f45ace85c4b3767 (diff)
downloadbcm5719-llvm-58b59f9522a0aafd4c2efe0781a9c88f005b7e00.tar.gz
bcm5719-llvm-58b59f9522a0aafd4c2efe0781a9c88f005b7e00.zip
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. llvm-svn: 130035
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/ValueObject.cpp152
-rw-r--r--lldb/source/Core/ValueObjectConstResult.cpp83
-rw-r--r--lldb/source/Core/ValueObjectDynamicValue.cpp8
-rw-r--r--lldb/source/Core/ValueObjectMemory.cpp11
-rw-r--r--lldb/source/Core/ValueObjectRegister.cpp41
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp6
6 files changed, 206 insertions, 95 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index d95806cf192..2b1beed3872 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -59,9 +59,11 @@ ValueObject::ValueObject (ValueObject &parent) :
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 @@ ValueObject::ValueObject (ValueObject &parent) :
m_pointers_point_to_load_addrs (false),
m_is_deref_of_parent (false)
{
+ m_manager->ManageObject(this);
}
//----------------------------------------------------------------------
@@ -88,9 +91,11 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope) :
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 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope) :
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 @@ ValueObject::GetChildAtIndex (uint32_t idx, bool can_create)
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 @@ ValueObject::SetName (const ConstString &name)
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 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3
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 @@ ValueObject::GetObjectRuntimeLanguage ()
}
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 @@ ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create)
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 @@ ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create)
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 @@ ValueObject::CalculateDynamicValue ()
}
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 @@ ValueObject::CreateConstantValue (const ConstString &name)
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 @@ ValueObject::CreateConstantValue (const ConstString &name)
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 @@ ValueObject::Dereference (Error &error)
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 @@ ValueObject::Dereference (Error &error)
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 @@ ValueObject::AddressOf (Error &error)
{
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;
diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp
index ff5d265a4f8..fbb35eb42aa 100644
--- a/lldb/source/Core/ValueObjectConstResult.cpp
+++ b/lldb/source/Core/ValueObjectConstResult.cpp
@@ -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 @@ ValueObjectConstResult::ValueObjectConstResult
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 @@ ValueObjectConstResult::ValueObjectConstResult
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 @@ ValueObjectConstResult::ValueObjectConstResult
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 @@ ValueObjectConstResult::ValueObjectConstResult
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) :
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 2b80ae513e3..17eb90a335f 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -39,14 +39,6 @@ ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent) :
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());
}
diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index d3998488eba..aa9ff0ae263 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -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,
diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index 979c28c996f..df80ce3ff29 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -95,21 +95,29 @@ ValueObjectRegisterContext::UpdateValue ()
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 &reg_ctx_sp, uint32_t set_idx)
+{
+ return (new ValueObjectRegisterSet (exe_scope, reg_ctx_sp, set_idx))->GetSP();
+}
+
+
ValueObjectRegisterSet::ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx, uint32_t reg_set_idx) :
ValueObject (exe_scope),
m_reg_ctx_sp (reg_ctx),
@@ -199,30 +207,33 @@ ValueObjectRegisterSet::UpdateValue ()
}
-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 @@ ValueObjectRegister::ValueObjectRegister (ValueObject &parent, lldb::RegisterCon
ConstructObject();
}
+ValueObjectSP
+ValueObjectRegister::Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num)
+{
+ return (new ValueObjectRegister (exe_scope, reg_ctx_sp, reg_num))->GetSP();
+}
+
ValueObjectRegister::ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx, uint32_t reg_num) :
ValueObject (exe_scope),
m_reg_ctx_sp (reg_ctx),
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 7bab591105b..882b7021f49 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -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)
OpenPOWER on IntegriCloud