summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBValue.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-07-15 19:31:49 +0000
committerGreg Clayton <gclayton@apple.com>2011-07-15 19:31:49 +0000
commitf660248238023bbb44deed53068d9f56e74fd1c6 (patch)
treeeeb6d2606b47d3fc8bb8d163e3f7fb759683db9d /lldb/source/API/SBValue.cpp
parentb45111556da27c93a2d515167150ca14292707dc (diff)
downloadbcm5719-llvm-f660248238023bbb44deed53068d9f56e74fd1c6.tar.gz
bcm5719-llvm-f660248238023bbb44deed53068d9f56e74fd1c6.zip
Added the ability to get synthetic child values from SBValue objects that
represent pointers and arrays by adding an extra parameter to the SBValue SBValue::GetChildAtIndex (uint32_t idx, DynamicValueType use_dynamic, bool can_create_synthetic); The new "can_create_synthetic" will allow you to create child values that aren't actually a part of the original type. So if you code like: int *foo_ptr = ... And you have a SBValue that contains the value for "foo_ptr": SBValue foo_value = ... You can now get the "foo_ptr[12]" item by doing this: v = foo_value.GetChiltAtIndex (12, lldb.eNoDynamicValues, True); Normall the "foo_value" would only have one child value (an integer), but we can create "synthetic" child values by treating the pointer as an array. Likewise if you have code like: int array[2]; array_value = .... v = array_value.GetChiltAtIndex (0); // Success, v will be valid v = array_value.GetChiltAtIndex (1); // Success, v will be valid v = array_value.GetChiltAtIndex (2); // Fail, v won't be valid, "2" is not a valid zero based index in "array" But if you use the ability to create synthetic children: v = array_value.GetChiltAtIndex (0, lldb.eNoDynamicValues, True); // Success, v will be valid v = array_value.GetChiltAtIndex (1, lldb.eNoDynamicValues, True); // Success, v will be valid v = array_value.GetChiltAtIndex (2, lldb.eNoDynamicValues, True); // Success, v will be valid llvm-svn: 135292
Diffstat (limited to 'lldb/source/API/SBValue.cpp')
-rw-r--r--lldb/source/API/SBValue.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index aeabb1740bf..5956784bbc7 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -361,17 +361,15 @@ SBValue::SetValueFromCString (const char *value_str)
SBValue
SBValue::GetChildAtIndex (uint32_t idx)
{
+ const bool can_create_synthetic = false;
+ lldb::DynamicValueType use_dynamic = eNoDynamicValues;
if (m_opaque_sp)
- {
- lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
- return GetChildAtIndex (idx, use_dynamic_value);
- }
- else
- return GetChildAtIndex (idx, eNoDynamicValues);
+ use_dynamic = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue();
+ return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
}
SBValue
-SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic)
+SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
{
lldb::ValueObjectSP child_sp;
@@ -380,13 +378,25 @@ SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic)
if (m_opaque_sp->GetUpdatePoint().GetTarget())
{
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
-
- child_sp = m_opaque_sp->GetChildAtIndex (idx, true);
- if (use_dynamic != lldb::eNoDynamicValues)
+ const bool can_create = true;
+ child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create);
+ if (can_create_synthetic && !child_sp)
{
- if (child_sp)
+ if (m_opaque_sp->IsPointerType())
+ {
+ child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
+ }
+ else if (m_opaque_sp->IsArrayType())
+ {
+ child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
+ }
+ }
+
+ if (child_sp)
+ {
+ if (use_dynamic != lldb::eNoDynamicValues)
{
- lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic);
+ lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic));
if (dynamic_sp)
child_sp = dynamic_sp;
}
OpenPOWER on IntegriCloud