Add SBValue::GetDynamicValue and SBValue::GetStaticValue API's.

<rdar://problem/10545069>

llvm-svn: 146173
This commit is contained in:
Jim Ingham 2011-12-08 19:44:08 +00:00
parent 6ccae15ef0
commit 60dbabbaa7
7 changed files with 86 additions and 0 deletions

View File

@ -84,6 +84,15 @@ public:
const char *
GetObjectDescription ();
lldb::SBValue
GetDynamicValue (lldb::DynamicValueType use_dynamic);
lldb::SBValue
GetStaticValue ();
bool
IsDynamic();
const char *
GetLocation ();

View File

@ -725,6 +725,9 @@ public:
lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
virtual lldb::ValueObjectSP
GetStaticValue ();
lldb::ValueObjectSP
GetSyntheticValue (lldb::SyntheticValueType use_synthetic);

View File

@ -73,6 +73,12 @@ public:
return NULL;
}
virtual lldb::ValueObjectSP
GetStaticValue ()
{
return m_parent->GetSP();
}
void
SetOwningSP (lldb::ValueObjectSP &owning_sp)
{

View File

@ -118,6 +118,15 @@ public:
const char *
GetObjectDescription ();
lldb::SBValue
GetDynamicValue (lldb::DynamicValueType use_dynamic);
lldb::SBValue
GetStaticValue ();
bool
IsDynamic();
const char *
GetLocation ();

View File

@ -596,6 +596,50 @@ SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dy
return sb_value;
}
lldb::SBValue
SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic)
{
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
return SBValue (m_opaque_sp->GetDynamicValue(use_dynamic));
}
}
return SBValue();
}
lldb::SBValue
SBValue::GetStaticValue ()
{
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
return SBValue(m_opaque_sp->GetStaticValue());
}
}
return SBValue();
}
bool
SBValue::IsDynamic()
{
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
return m_opaque_sp->IsDynamic();
}
}
return false;
}
lldb::SBValue
SBValue::GetValueForExpressionPath(const char* expr_path)
{

View File

@ -1920,6 +1920,12 @@ ValueObject::GetDynamicValue (DynamicValueType use_dynamic)
return ValueObjectSP();
}
ValueObjectSP
ValueObject::GetStaticValue()
{
return GetSP();
}
// GetDynamicValue() returns a NULL SharedPointer if the object is not dynamic
// or we do not really want a dynamic VO. this method instead returns this object
// itself when making it synthetic has no meaning. this makes it much simpler

View File

@ -153,6 +153,15 @@ class DynamicValueTestCase(TestBase):
this_dynamic = frame.FindVariable ('this', use_dynamic)
self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc)
# Now make sure that the "GetDynamicValue" works:
# This doesn't work currently because we can't get dynamic values from ConstResult objects.
fetched_dynamic_value = this_static.GetDynamicValue(use_dynamic)
self.examine_value_object_of_this_ptr (this_static, fetched_dynamic_value, myB_loc)
# And conversely that the GetDynamicValue() interface also works:
fetched_static_value = this_dynamic.GetStaticValue()
self.examine_value_object_of_this_ptr (fetched_static_value, this_dynamic, myB_loc)
# Get "this" using FindValue, make sure that works too:
this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, no_dynamic)
this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, use_dynamic)