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-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/Core/DataExtractor.h"
|
|
|
|
#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"
|
|
|
|
#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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue::~SBValue()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::IsValid () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return (m_opaque_sp.get() != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetName()
|
|
|
|
{
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetName().AsCString();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetTypeName ()
|
|
|
|
{
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetTypeName().AsCString();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBValue::GetByteSize ()
|
|
|
|
{
|
|
|
|
size_t result = 0;
|
|
|
|
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
result = m_opaque_sp->GetByteSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::IsInScope (const SBFrame &frame)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
result = m_opaque_sp->IsInScope (frame.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetValue (const SBFrame &frame)
|
|
|
|
{
|
|
|
|
const char *value_string = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if ( m_opaque_sp)
|
2010-09-02 10:59:18 +08:00
|
|
|
value_string = m_opaque_sp->GetValueAsCString (frame.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return value_string;
|
|
|
|
}
|
|
|
|
|
2010-09-11 07:12:17 +08:00
|
|
|
const char *
|
|
|
|
SBValue::GetObjectDescription (const SBFrame &frame)
|
|
|
|
{
|
|
|
|
const char *value_string = NULL;
|
|
|
|
if ( m_opaque_sp)
|
|
|
|
value_string = m_opaque_sp->GetObjectDescription (frame.get());
|
|
|
|
return value_string;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-09-02 10:59:18 +08:00
|
|
|
SBValue::GetValueDidChange (const SBFrame &frame)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (IsValid())
|
2010-09-02 10:59:18 +08:00
|
|
|
return m_opaque_sp->GetValueDidChange (frame.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetSummary (const SBFrame &frame)
|
|
|
|
{
|
|
|
|
const char *value_string = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if ( m_opaque_sp)
|
|
|
|
value_string = m_opaque_sp->GetSummaryAsCString(frame.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return value_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBValue::GetLocation (const SBFrame &frame)
|
|
|
|
{
|
|
|
|
const char *value_string = NULL;
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
value_string = m_opaque_sp->GetLocationAsCString(frame.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return value_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::SetValueFromCString (const SBFrame &frame, const char *value_str)
|
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
success = m_opaque_sp->SetValueFromCString (frame.get(), value_str);
|
2010-06-09 00:52:24 +08:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::GetChildAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP child_sp;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
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);
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBValue::GetIndexOfChildWithName (const char *name)
|
|
|
|
{
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
|
2010-06-09 00:52:24 +08:00
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::GetChildMemberWithName (const char *name)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP child_sp;
|
|
|
|
const ConstString str_name (name);
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
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);
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBValue::GetNumChildren ()
|
|
|
|
{
|
|
|
|
uint32_t num_children = 0;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
num_children = m_opaque_sp->GetNumChildren();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return num_children;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::ValueIsStale ()
|
|
|
|
{
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
result = m_opaque_sp->GetValueIsValid();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBValue
|
|
|
|
SBValue::Dereference ()
|
|
|
|
{
|
|
|
|
if (IsValid())
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp->IsPointerType())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return GetChildAtIndex(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBValue::TypeIsPtrType ()
|
|
|
|
{
|
|
|
|
bool is_ptr_type = false;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
is_ptr_type = m_opaque_sp->IsPointerType();
|
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)
|
|
|
|
return m_opaque_sp->GetOpaqueClangQualType();
|
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
|
|
|
}
|