summaryrefslogtreecommitdiffstats
path: root/lldb/source/API
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-02-07 18:23:56 +0000
committerEnrico Granata <egranata@apple.com>2013-02-07 18:23:56 +0000
commit85425d77b8ed75fb5996b2df795530ca163d79d5 (patch)
treed26a2d6c0cf775829e9fc64904038dc64138e924 /lldb/source/API
parent63f700e4d1876abcce74276dbf9838f9902e7664 (diff)
downloadbcm5719-llvm-85425d77b8ed75fb5996b2df795530ca163d79d5.tar.gz
bcm5719-llvm-85425d77b8ed75fb5996b2df795530ca163d79d5.zip
<rdar://problem/13107151>
SBValueList was backed by a ValueObjectList. This caused us to lose track of the additional metadata in the ValueImpl that backs SBValue. This checkin fixes that by backing SBValueList with ValueListImpl (that essentially wraps a vector<SBValue>). llvm-svn: 174638
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBFrame.cpp5
-rw-r--r--lldb/source/API/SBModule.cpp3
-rw-r--r--lldb/source/API/SBTarget.cpp3
-rw-r--r--lldb/source/API/SBValueList.cpp111
4 files changed, 90 insertions, 32 deletions
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 8b7cacca988..1283758a83b 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -1159,8 +1159,7 @@ SBFrame::GetVariables (bool arguments,
if (log)
{
- log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
- value_list.get());
+ log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList", frame);
}
return value_list;
@@ -1210,7 +1209,7 @@ SBFrame::GetRegisters ()
}
if (log)
- log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.get());
+ log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList", frame);
return value_list;
}
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 681d416c2ae..461950f29e9 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -467,14 +467,13 @@ SBModule::FindGlobalVariables (SBTarget &target, const char *name, uint32_t max_
if (match_count > 0)
{
- ValueObjectList &value_object_list = sb_value_list.ref();
for (uint32_t i=0; i<match_count; ++i)
{
lldb::ValueObjectSP valobj_sp;
TargetSP target_sp (target.GetSP());
valobj_sp = ValueObjectVariable::Create (target_sp.get(), variable_list.GetVariableAtIndex(i));
if (valobj_sp)
- value_object_list.Append(valobj_sp);
+ sb_value_list.Append(SBValue(valobj_sp));
}
}
}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 115703e81f8..c41051ff327 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -2219,12 +2219,11 @@ SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == NULL)
exe_scope = target_sp.get();
- ValueObjectList &value_object_list = sb_value_list.ref();
for (uint32_t i=0; i<match_count; ++i)
{
lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
if (valobj_sp)
- value_object_list.Append(valobj_sp);
+ sb_value_list.Append(SBValue(valobj_sp));
}
}
}
diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp
index 2142f476adc..2ec4a7bee24 100644
--- a/lldb/source/API/SBValueList.cpp
+++ b/lldb/source/API/SBValueList.cpp
@@ -14,9 +14,78 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectList.h"
+#include <vector>
+
using namespace lldb;
using namespace lldb_private;
+namespace {
+ class ValueListImpl
+ {
+ public:
+ ValueListImpl () :
+ m_values()
+ {
+ }
+
+ ValueListImpl (const ValueListImpl& rhs) :
+ m_values(rhs.m_values)
+ {
+ }
+
+ ValueListImpl&
+ operator = (const ValueListImpl& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ m_values = rhs.m_values;
+ return *this;
+ };
+
+ uint32_t
+ GetSize ()
+ {
+ return m_values.size();
+ }
+
+ void
+ Append (const lldb::SBValue& sb_value)
+ {
+ m_values.push_back(sb_value);
+ }
+
+ void
+ Append (const ValueListImpl& list)
+ {
+ for (auto val : list.m_values)
+ Append (val);
+ }
+
+ lldb::SBValue
+ GetValueAtIndex (uint32_t index)
+ {
+ if (index >= GetSize())
+ return lldb::SBValue();
+ return m_values[index];
+ }
+
+ lldb::SBValue
+ FindValueByUID (lldb::user_id_t uid)
+ {
+ for (auto val : m_values)
+ {
+ if (val.IsValid() && val.GetID() == uid)
+ return val;
+ }
+ return lldb::SBValue();
+ }
+
+ private:
+ std::vector<lldb::SBValue> m_values;
+ };
+}
+
+
SBValueList::SBValueList () :
m_opaque_ap ()
{
@@ -28,7 +97,7 @@ SBValueList::SBValueList (const SBValueList &rhs) :
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (rhs.IsValid())
- m_opaque_ap.reset (new ValueObjectList (*rhs));
+ m_opaque_ap.reset (new ValueListImpl (*rhs));
if (log)
{
@@ -38,13 +107,13 @@ SBValueList::SBValueList (const SBValueList &rhs) :
}
}
-SBValueList::SBValueList (const ValueObjectList *lldb_object_ptr) :
+SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
m_opaque_ap ()
{
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (lldb_object_ptr)
- m_opaque_ap.reset (new ValueObjectList (*lldb_object_ptr));
+ m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
if (log)
{
@@ -76,32 +145,32 @@ SBValueList::operator = (const SBValueList &rhs)
if (this != &rhs)
{
if (rhs.IsValid())
- m_opaque_ap.reset (new ValueObjectList (*rhs));
+ m_opaque_ap.reset (new ValueListImpl (*rhs));
else
m_opaque_ap.reset ();
}
return *this;
}
-ValueObjectList *
+ValueListImpl *
SBValueList::operator->()
{
return m_opaque_ap.get();
}
-ValueObjectList &
+ValueListImpl &
SBValueList::operator*()
{
return *m_opaque_ap;
}
-const ValueObjectList *
+const ValueListImpl *
SBValueList::operator->() const
{
return m_opaque_ap.get();
}
-const ValueObjectList &
+const ValueListImpl &
SBValueList::operator*() const
{
return *m_opaque_ap;
@@ -110,12 +179,8 @@ SBValueList::operator*() const
void
SBValueList::Append (const SBValue &val_obj)
{
- ValueObjectSP value_sp (val_obj.GetSP());
- if (value_sp)
- {
- CreateIfNeeded ();
- m_opaque_ap->Append (value_sp);
- }
+ CreateIfNeeded ();
+ m_opaque_ap->Append (val_obj);
}
void
@@ -124,7 +189,7 @@ SBValueList::Append (lldb::ValueObjectSP& val_obj_sp)
if (val_obj_sp)
{
CreateIfNeeded ();
- m_opaque_ap->Append (val_obj_sp);
+ m_opaque_ap->Append (SBValue(val_obj_sp));
}
}
@@ -148,19 +213,15 @@ SBValueList::GetValueAtIndex (uint32_t idx) const
// log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
SBValue sb_value;
- ValueObjectSP value_sp;
if (m_opaque_ap.get())
- {
- value_sp = m_opaque_ap->GetValueObjectAtIndex (idx);
- sb_value.SetSP (value_sp);
- }
+ sb_value = m_opaque_ap->GetValueAtIndex (idx);
if (log)
{
SBStream sstr;
sb_value.GetDescription (sstr);
log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')",
- m_opaque_ap.get(), idx, value_sp.get(), sstr.GetData());
+ m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
}
return sb_value;
@@ -188,7 +249,7 @@ void
SBValueList::CreateIfNeeded ()
{
if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new ValueObjectList());
+ m_opaque_ap.reset (new ValueListImpl());
}
@@ -197,17 +258,17 @@ SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
{
SBValue sb_value;
if (m_opaque_ap.get())
- sb_value.SetSP (m_opaque_ap->FindValueObjectByUID (uid));
+ sb_value = m_opaque_ap->FindValueByUID(uid);
return sb_value;
}
-ValueObjectList *
+ValueListImpl *
SBValueList::get ()
{
return m_opaque_ap.get();
}
-ValueObjectList &
+ValueListImpl &
SBValueList::ref ()
{
CreateIfNeeded();
OpenPOWER on IntegriCloud