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"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (rhs.IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap.reset (new lldb_private::ValueObjectList (*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
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList::SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (lldb_object_ptr)
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap.reset (new lldb_private::ValueObjectList (*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
|
|
|
}
|
|
|
|
|
|
|
|
const SBValueList &
|
|
|
|
SBValueList::operator = (const SBValueList &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
|
|
|
if (rhs.IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap.reset (new lldb_private::ValueObjectList (*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;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ValueObjectList *
|
|
|
|
SBValueList::operator->()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ValueObjectList &
|
|
|
|
SBValueList::operator*()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::ValueObjectList *
|
|
|
|
SBValueList::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::ValueObjectList &
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (val_obj.get())
|
|
|
|
{
|
|
|
|
CreateIfNeeded ();
|
2010-06-23 09:19:29 +08:00
|
|
|
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 ();
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap->Append (val_obj_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValueList::GetValueAtIndex (uint32_t idx) const
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::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())
|
|
|
|
*sb_value = m_opaque_ap->GetValueObjectAtIndex (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')",
|
2010-10-29 12:59:35 +08:00
|
|
|
m_opaque_ap.get(), idx, sb_value.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
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::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)
|
|
|
|
m_opaque_ap.reset (new ValueObjectList());
|
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())
|
2010-06-23 09:19:29 +08:00
|
|
|
*sb_value = m_opaque_ap->FindValueObjectByUID (uid);
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
lldb_private::ValueObjectList *
|
|
|
|
SBValueList::get ()
|
|
|
|
{
|
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|
|
|
|
|