2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBValueList.cpp -----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/API/SBValueList.h"
|
|
|
|
#include "lldb/API/SBValue.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList::SBValueList () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList::SBValueList (const SBValueList &rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-06-30 06:09:02 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (rhs.IsValid())
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap.reset (new ValueListImpl (*rhs));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-27 07:49:36 +08:00
|
|
|
log->Printf ("SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
|
2010-12-21 04:49:23 +08:00
|
|
|
(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
|
|
|
|
m_opaque_ap.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-06-30 06:09:02 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (lldb_object_ptr)
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
|
|
|
|
lldb_object_ptr,
|
2010-10-27 07:49:36 +08:00
|
|
|
m_opaque_ap.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList::~SBValueList ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValueList::IsValid () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return (m_opaque_ap.get() != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 04:39:44 +08:00
|
|
|
void
|
|
|
|
SBValueList::Clear()
|
|
|
|
{
|
|
|
|
m_opaque_ap.reset();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const SBValueList &
|
|
|
|
SBValueList::operator = (const SBValueList &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
|
|
|
if (rhs.IsValid())
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap.reset (new ValueListImpl (*rhs));
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap.reset ();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
ValueListImpl *
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList::operator->()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
ValueListImpl &
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList::operator*()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
const ValueListImpl *
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
const ValueListImpl &
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValueList::operator*() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBValueList::Append (const SBValue &val_obj)
|
|
|
|
{
|
2013-02-08 02:23:56 +08:00
|
|
|
CreateIfNeeded ();
|
|
|
|
m_opaque_ap->Append (val_obj);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBValueList::Append (lldb::ValueObjectSP& val_obj_sp)
|
|
|
|
{
|
|
|
|
if (val_obj_sp)
|
|
|
|
{
|
|
|
|
CreateIfNeeded ();
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap->Append (SBValue(val_obj_sp));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
void
|
|
|
|
SBValueList::Append (const lldb::SBValueList& value_list)
|
|
|
|
{
|
|
|
|
if (value_list.IsValid())
|
|
|
|
{
|
|
|
|
CreateIfNeeded ();
|
|
|
|
m_opaque_ap->Append (*value_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValueList::GetValueAtIndex (uint32_t idx) const
|
|
|
|
{
|
2011-06-30 06:09:02 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
//if (log)
|
|
|
|
// log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValue sb_value;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
2013-02-08 02:23:56 +08:00
|
|
|
sb_value = m_opaque_ap->GetValueAtIndex (idx);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_value.GetDescription (sstr);
|
2010-10-27 07:49:36 +08:00
|
|
|
log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')",
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBValueList::GetSize () const
|
|
|
|
{
|
2011-06-30 06:09:02 +08:00
|
|
|
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
//if (log)
|
|
|
|
// log->Printf ("SBValueList::GetSize ()");
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t size = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
size = m_opaque_ap->GetSize();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-27 07:49:36 +08:00
|
|
|
log->Printf ("SBValueList::GetSize (this.ap=%p) => %d", m_opaque_ap.get(), size);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBValueList::CreateIfNeeded ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get() == NULL)
|
2013-02-08 02:23:56 +08:00
|
|
|
m_opaque_ap.reset (new ValueListImpl());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
|
|
|
|
{
|
|
|
|
SBValue sb_value;
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_ap.get())
|
2013-02-08 02:23:56 +08:00
|
|
|
sb_value = m_opaque_ap->FindValueByUID(uid);
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
2013-02-08 06:22:27 +08:00
|
|
|
void *
|
2013-02-08 06:57:46 +08:00
|
|
|
SBValueList::opaque_ptr ()
|
2010-10-27 07:49:36 +08:00
|
|
|
{
|
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|
2013-02-08 02:23:56 +08:00
|
|
|
ValueListImpl &
|
2011-06-30 06:09:02 +08:00
|
|
|
SBValueList::ref ()
|
|
|
|
{
|
|
|
|
CreateIfNeeded();
|
|
|
|
return *m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|