2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBValue.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/Core/DataExtractor.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
#include "lldb/Core/ValueObject.h"
|
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/StackFrame.h"
|
2010-12-21 04:49:23 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
|
|
|
#include "lldb/API/SBTarget.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
|
|
|
#include "lldb/API/SBFrame.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
SBValue::SBValue () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (value_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBValue::SBValue(const SBValue &rhs) :
|
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBValue &
|
|
|
|
SBValue::operator = (const SBValue &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBValue::~SBValue()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::IsValid () const
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
// If this function ever changes to anything that does more than just
|
|
|
|
// check if the opaque shared pointer is non NULL, then we need to update
|
|
|
|
// all "if (m_opaque_sp)" code in this file.
|
|
|
|
return m_opaque_sp.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
SBError
|
|
|
|
SBValue::GetError()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
|
|
|
if (m_opaque_sp.get())
|
|
|
|
sb_error.SetError(m_opaque_sp->GetError());
|
|
|
|
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *
|
|
|
|
SBValue::GetName()
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *name = NULL;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
name = m_opaque_sp->GetName().GetCString();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name);
|
|
|
|
else
|
|
|
|
log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name);
|
|
|
|
}
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
return name;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetTypeName ()
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *name = NULL;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
name = m_opaque_sp->GetTypeName().GetCString();
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name);
|
|
|
|
else
|
|
|
|
log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBValue::GetByteSize ()
|
|
|
|
{
|
|
|
|
size_t result = 0;
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-23 09:19:29 +08:00
|
|
|
result = m_opaque_sp->GetByteSize();
|
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-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::IsInScope (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return IsInScope();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::IsInScope ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
result = m_opaque_sp->IsInScope ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
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-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::GetValue (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetValue ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *cstr = NULL;
|
2010-12-21 04:49:23 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
cstr = m_opaque_sp->GetValueAsCString ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (cstr)
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
else
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get());
|
2010-10-31 11:01:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return cstr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-27 11:32:59 +08:00
|
|
|
ValueType
|
|
|
|
SBValue::GetValueType ()
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
ValueType result = eValueTypeInvalid;
|
2010-10-27 11:32:59 +08:00
|
|
|
if (m_opaque_sp)
|
2010-10-31 11:01:06 +08:00
|
|
|
result = m_opaque_sp->GetValueType();
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
switch (result)
|
|
|
|
{
|
|
|
|
case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break;
|
|
|
|
case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break;
|
|
|
|
default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2010-10-27 11:32:59 +08:00
|
|
|
}
|
|
|
|
|
2010-09-11 07:12:17 +08:00
|
|
|
const char *
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::GetObjectDescription (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return GetObjectDescription ();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetObjectDescription ()
|
2010-09-11 07:12:17 +08:00
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *cstr = NULL;
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
cstr = m_opaque_sp->GetObjectDescription ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (cstr)
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
else
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get());
|
2010-10-31 11:01:06 +08:00
|
|
|
}
|
|
|
|
return cstr;
|
2010-09-11 07:12:17 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::GetValueDidChange (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return GetValueDidChange ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::GetValueDidChange ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
bool result = false;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
result = m_opaque_sp->GetValueDidChange ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetValueDidChange => %i", m_opaque_sp.get(), result);
|
2010-10-31 11:01:06 +08:00
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::GetSummary (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return GetSummary ();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetSummary ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *cstr = NULL;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
cstr = m_opaque_sp->GetSummaryAsCString();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (cstr)
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
else
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
|
2010-10-31 11:01:06 +08:00
|
|
|
}
|
|
|
|
return cstr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::GetLocation (const SBFrame &sb_frame)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return GetLocation ();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetLocation ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
const char *cstr = NULL;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
cstr = m_opaque_sp->GetLocationAsCString();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (cstr)
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
else
|
2011-03-31 08:19:25 +08:00
|
|
|
log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
|
2010-10-31 11:01:06 +08:00
|
|
|
}
|
|
|
|
return cstr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-12-21 04:49:23 +08:00
|
|
|
SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
|
2011-03-31 08:19:25 +08:00
|
|
|
{
|
|
|
|
return SetValueFromCString (value_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::SetValueFromCString (const char *value_str)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bool success = false;
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-03-31 08:19:25 +08:00
|
|
|
if (m_opaque_sp->GetUpdatePoint().GetTarget())
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex());
|
|
|
|
success = m_opaque_sp->SetValueFromCString (value_str);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::GetChildAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP child_sp;
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
child_sp = m_opaque_sp->GetChildAtIndex (idx, true);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue sb_value (child_sp);
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBValue::GetIndexOfChildWithName (const char *name)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
uint32_t idx = UINT32_MAX;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (idx == UINT32_MAX)
|
|
|
|
log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx);
|
|
|
|
else
|
|
|
|
log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx);
|
|
|
|
}
|
|
|
|
return idx;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::GetChildMemberWithName (const char *name)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP child_sp;
|
|
|
|
const ConstString str_name (name);
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBValue sb_value (child_sp);
|
2010-10-31 11:01:06 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBValue::GetNumChildren ()
|
|
|
|
{
|
|
|
|
uint32_t num_children = 0;
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-23 09:19:29 +08:00
|
|
|
num_children = m_opaque_sp->GetNumChildren();
|
2010-10-31 11:01:06 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return num_children;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::Dereference ()
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
SBValue sb_value;
|
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Error error;
|
|
|
|
sb_value = m_opaque_sp->Dereference (error);
|
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-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
|
|
|
|
|
|
|
|
return sb_value;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-10-31 11:01:06 +08:00
|
|
|
SBValue::TypeIsPointerType ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bool is_ptr_type = false;
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-23 09:19:29 +08:00
|
|
|
is_ptr_type = m_opaque_sp->IsPointerType();
|
2010-10-31 11:01:06 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return is_ptr_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
SBValue::GetOpaqueType()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-09-29 09:12:09 +08:00
|
|
|
return m_opaque_sp->GetClangType();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mimic shared pointer...
|
|
|
|
lldb_private::ValueObject *
|
|
|
|
SBValue::get() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ValueObject *
|
|
|
|
SBValue::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ValueObjectSP &
|
|
|
|
SBValue::operator*()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb::ValueObjectSP &
|
|
|
|
SBValue::operator*() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
bool
|
|
|
|
SBValue::GetExpressionPath (SBStream &description)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_opaque_sp->GetExpressionPath (description.ref(), false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
|
2010-10-31 11:01:06 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
|
|
|
SBValue::GetDescription (SBStream &description)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2010-10-29 12:59:35 +08:00
|
|
|
// Don't call all these APIs and cause more logging!
|
|
|
|
// const char *name = GetName();
|
|
|
|
// const char *type_name = GetTypeName ();
|
|
|
|
// size_t byte_size = GetByteSize ();
|
|
|
|
// uint32_t num_children = GetNumChildren ();
|
|
|
|
// bool is_stale = ValueIsStale ();
|
|
|
|
// description.Printf ("name: '%s', type: %s, size: %d", (name != NULL ? name : "<unknown name>"),
|
|
|
|
// (type_name != NULL ? type_name : "<unknown type name>"), (int) byte_size);
|
|
|
|
// if (num_children > 0)
|
|
|
|
// description.Printf (", num_children: %d", num_children);
|
|
|
|
//
|
|
|
|
// if (is_stale)
|
|
|
|
// description.Printf (" [value is stale]");
|
|
|
|
|
|
|
|
description.Printf ("name: '%s'", m_opaque_sp->GetName().GetCString());
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-06 02:43:15 +08:00
|
|
|
|
|
|
|
lldb::Format
|
|
|
|
SBValue::GetFormat () const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetFormat();
|
|
|
|
return eFormatDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBValue::SetFormat (lldb::Format format)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetFormat(format);
|
|
|
|
}
|
|
|
|
|