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"
11 #include "clang/AST/ASTContext.h"
12 #include "lldb/Core/ConstString.h"
13 #include "lldb/Core/DataExtractor.h"
14 #include "lldb/Core/Stream.h"
15 #include "lldb/Core/Value.h"
16 #include "lldb/Core/ValueObjectConstResult.h"
17 #include "lldb/Target/ExecutionContext.h"
18 #include "lldb/Target/Process.h"
20 using namespace lldb_private;
21 using namespace clang;
23 ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
27 m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
31 ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
33 const ConstString &name,
38 m_frozen_sp (ValueObjectConstResult::Create (exe_scope, value, name))
42 ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
46 m_frozen_sp (valobj_sp)
50 //----------------------------------------------------------------------
51 /// Return the variable's size in bytes
52 //----------------------------------------------------------------------
54 ClangExpressionVariable::GetByteSize ()
56 return m_frozen_sp->GetByteSize();
60 ClangExpressionVariable::GetName ()
62 return m_frozen_sp->GetName();
66 ClangExpressionVariable::GetValueObject()
72 ClangExpressionVariable::GetRegisterInfo()
74 return m_frozen_sp->GetValue().GetRegisterInfo();
78 ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
80 return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
84 ClangExpressionVariable::GetClangType()
86 return m_frozen_sp->GetClangType();
90 ClangExpressionVariable::SetClangType(const ClangASTType &clang_type)
92 m_frozen_sp->GetValue().SetClangType(clang_type);
97 ClangExpressionVariable::GetTypeFromUser()
99 TypeFromUser tfu (m_frozen_sp->GetClangType());
104 ClangExpressionVariable::GetValueBytes()
106 const size_t byte_size = m_frozen_sp->GetByteSize();
109 if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
111 m_frozen_sp->GetValue().ResizeData(byte_size);
112 m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
114 return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
120 ClangExpressionVariable::SetName (const ConstString &name)
122 m_frozen_sp->SetName (name);
126 ClangExpressionVariable::ValueUpdated ()
128 m_frozen_sp->ValueUpdated ();
132 ClangExpressionVariable::TransferAddress (bool force)
134 if (m_live_sp.get() == NULL)
137 if (m_frozen_sp.get() == NULL)
140 if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
141 m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());