2010-06-09 00:52:24 +08:00
|
|
|
//===-- ClangExpressionVariable.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/Expression/ClangExpressionVariable.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
2010-08-20 09:02:30 +08:00
|
|
|
#include "lldb/Core/ConstString.h"
|
|
|
|
#include "lldb/Core/DataExtractor.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/Value.h"
|
2010-10-05 08:00:42 +08:00
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2010-09-14 05:34:21 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace clang;
|
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
|
2010-10-05 08:00:42 +08:00
|
|
|
m_parser_vars(),
|
|
|
|
m_jit_vars (),
|
2011-04-12 03:41:40 +08:00
|
|
|
m_flags (EVNone),
|
2011-04-23 07:53:53 +08:00
|
|
|
m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-09 07:13:56 +08:00
|
|
|
ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
|
|
|
|
Value &value,
|
|
|
|
const ConstString &name,
|
|
|
|
uint16_t flags) :
|
|
|
|
m_parser_vars(),
|
|
|
|
m_jit_vars (),
|
|
|
|
m_flags (flags),
|
|
|
|
m_frozen_sp (ValueObjectConstResult::Create (exe_scope, value, name))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
|
|
|
|
m_parser_vars(),
|
|
|
|
m_jit_vars (),
|
2011-04-12 03:41:40 +08:00
|
|
|
m_flags (EVNone),
|
|
|
|
m_frozen_sp (valobj_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
/// Return the variable's size in bytes
|
|
|
|
//----------------------------------------------------------------------
|
2014-07-07 01:54:58 +08:00
|
|
|
size_t
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariable::GetByteSize ()
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
return m_frozen_sp->GetByteSize();
|
2014-07-07 01:54:58 +08:00
|
|
|
}
|
2010-09-30 08:54:27 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
const ConstString &
|
|
|
|
ClangExpressionVariable::GetName ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
return m_frozen_sp->GetName();
|
2014-07-07 01:54:58 +08:00
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
|
|
lldb::ValueObjectSP
|
|
|
|
ClangExpressionVariable::GetValueObject()
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
return m_frozen_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
RegisterInfo *
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariable::GetRegisterInfo()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
return m_frozen_sp->GetValue().GetRegisterInfo();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-05 08:00:42 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
void
|
2011-03-25 05:19:54 +08:00
|
|
|
ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2011-03-25 05:19:54 +08:00
|
|
|
return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
|
|
|
|
2013-07-12 06:46:58 +08:00
|
|
|
ClangASTType
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariable::GetClangType()
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
return m_frozen_sp->GetClangType();
|
2014-07-07 01:54:58 +08:00
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
|
|
void
|
2013-07-12 06:46:58 +08:00
|
|
|
ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
|
2010-12-14 10:59:59 +08:00
|
|
|
{
|
2013-07-12 06:46:58 +08:00
|
|
|
m_frozen_sp->GetValue().SetClangType(clang_type);
|
2014-07-07 01:54:58 +08:00
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
TypeFromUser
|
|
|
|
ClangExpressionVariable::GetTypeFromUser()
|
|
|
|
{
|
2013-07-12 06:46:58 +08:00
|
|
|
TypeFromUser tfu (m_frozen_sp->GetClangType());
|
2010-12-14 10:59:59 +08:00
|
|
|
return tfu;
|
2014-07-07 01:54:58 +08:00
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
|
|
|
|
uint8_t *
|
|
|
|
ClangExpressionVariable::GetValueBytes()
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
const size_t byte_size = m_frozen_sp->GetByteSize();
|
2010-12-14 10:59:59 +08:00
|
|
|
if (byte_size > 0)
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
|
2010-10-05 08:00:42 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
m_frozen_sp->GetValue().ResizeData(byte_size);
|
|
|
|
m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2011-01-13 16:53:35 +08:00
|
|
|
return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
2010-12-14 10:59:59 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionVariable::SetName (const ConstString &name)
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
m_frozen_sp->SetName (name);
|
2010-12-14 10:59:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionVariable::ValueUpdated ()
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
m_frozen_sp->ValueUpdated ();
|
2010-10-05 08:00:42 +08:00
|
|
|
}
|
|
|
|
|
2012-01-06 08:35:38 +08:00
|
|
|
void
|
|
|
|
ClangExpressionVariable::TransferAddress (bool force)
|
|
|
|
{
|
|
|
|
if (m_live_sp.get() == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_frozen_sp.get() == NULL)
|
|
|
|
return;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2012-01-06 08:35:38 +08:00
|
|
|
if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
|
|
|
|
m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
|
|
|
|
}
|