1 //===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Expression/ClangExpressionVariable.h"
14 // Other libraries and framework includes
16 #include "clang/AST/ASTContext.h"
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Core/DataExtractor.h"
19 #include "lldb/Core/Stream.h"
20 #include "lldb/Core/Value.h"
21 #include "lldb/Core/ValueObjectConstResult.h"
22 #include "lldb/Target/ExecutionContext.h"
23 #include "lldb/Target/Process.h"
25 using namespace lldb_private;
26 using namespace clang;
28 ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
32 m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
36 ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
40 m_frozen_sp (valobj_sp)
44 //----------------------------------------------------------------------
45 /// Return the variable's size in bytes
46 //----------------------------------------------------------------------
48 ClangExpressionVariable::GetByteSize ()
50 return m_frozen_sp->GetByteSize();
54 ClangExpressionVariable::GetName ()
56 return m_frozen_sp->GetName();
60 ClangExpressionVariable::GetValueObject()
66 ClangExpressionVariable::GetRegisterInfo()
68 return m_frozen_sp->GetValue().GetRegisterInfo();
72 ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
74 return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
78 ClangExpressionVariable::GetClangType()
80 return m_frozen_sp->GetClangType();
84 ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
86 m_frozen_sp->GetValue().SetClangType(clang_type);
91 ClangExpressionVariable::GetTypeFromUser()
93 TypeFromUser tfu (m_frozen_sp->GetClangType());
98 ClangExpressionVariable::GetValueBytes()
100 const size_t byte_size = m_frozen_sp->GetByteSize();
103 if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
105 m_frozen_sp->GetValue().ResizeData(byte_size);
106 m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
108 return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
114 ClangExpressionVariable::SetName (const ConstString &name)
116 m_frozen_sp->SetName (name);
120 ClangExpressionVariable::ValueUpdated ()
122 m_frozen_sp->ValueUpdated ();
126 ClangExpressionVariable::TransferAddress (bool force)
128 if (m_live_sp.get() == NULL)
131 if (m_frozen_sp.get() == NULL)
134 if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
135 m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());