Implemented a major overhaul of the way variables are handled
by LLDB. Instead of being materialized into the input structure
passed to the expression, variables are left in place and pointers
to them are materialzied into the structure. Variables not resident
in memory (notably, registers) get temporary memory regions allocated
for them.
Persistent variables are the most complex part of this, because they
are made in various ways and there are different expectations about
their lifetime. Persistent variables now have flags indicating their
status and what the expectations for longevity are. They can be
marked as residing in target memory permanently -- this is the
default for result variables from expressions entered on the command
line and for explicitly declared persistent variables (but more on
that below). Other result variables have their memory freed.
Some major improvements resulting from this include being able to
properly take the address of variables, better and cleaner support
for functions that return references, and cleaner C++ support in
general. One problem that remains is the problem of explicitly
declared persistent variables; I have not yet implemented the code
that makes references to them into indirect references, so currently
materialization and dematerialization of these variables is broken.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123371 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
index 79a7e4f..bf1a3da 100644
--- a/source/Expression/ClangExpressionVariable.cpp
+++ b/source/Expression/ClangExpressionVariable.cpp
@@ -28,14 +28,16 @@
ClangExpressionVariable::ClangExpressionVariable(lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
m_parser_vars(),
m_jit_vars (),
- m_valojb_sp (new ValueObjectConstResult(byte_order, addr_byte_size))
+ m_frozen_sp (new ValueObjectConstResult(byte_order, addr_byte_size)),
+ m_flags (EVNone)
{
}
ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
m_parser_vars(),
m_jit_vars (),
- m_valojb_sp (valobj_sp)
+ m_frozen_sp (valobj_sp),
+ m_flags (EVNone)
{
}
@@ -45,76 +47,76 @@
size_t
ClangExpressionVariable::GetByteSize ()
{
- return m_valojb_sp->GetByteSize();
+ return m_frozen_sp->GetByteSize();
}
const ConstString &
ClangExpressionVariable::GetName ()
{
- return m_valojb_sp->GetName();
+ return m_frozen_sp->GetName();
}
lldb::ValueObjectSP
ClangExpressionVariable::GetValueObject()
{
- return m_valojb_sp;
+ return m_frozen_sp;
}
lldb::RegisterInfo *
ClangExpressionVariable::GetRegisterInfo()
{
- return m_valojb_sp->GetValue().GetRegisterInfo();
+ return m_frozen_sp->GetValue().GetRegisterInfo();
}
void
ClangExpressionVariable::SetRegisterInfo (const lldb::RegisterInfo *reg_info)
{
- return m_valojb_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<lldb::RegisterInfo *>(reg_info));
+ return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<lldb::RegisterInfo *>(reg_info));
}
lldb::clang_type_t
ClangExpressionVariable::GetClangType()
{
- return m_valojb_sp->GetClangType();
+ return m_frozen_sp->GetClangType();
}
void
ClangExpressionVariable::SetClangType(lldb::clang_type_t clang_type)
{
- m_valojb_sp->GetValue().SetContext(Value::eContextTypeClangType, clang_type);
+ m_frozen_sp->GetValue().SetContext(Value::eContextTypeClangType, clang_type);
}
clang::ASTContext *
ClangExpressionVariable::GetClangAST()
{
- return m_valojb_sp->GetClangAST();
+ return m_frozen_sp->GetClangAST();
}
void
ClangExpressionVariable::SetClangAST (clang::ASTContext *ast)
{
- m_valojb_sp->SetClangAST (ast);
+ m_frozen_sp->SetClangAST (ast);
}
TypeFromUser
ClangExpressionVariable::GetTypeFromUser()
{
- TypeFromUser tfu (m_valojb_sp->GetClangType(), m_valojb_sp->GetClangAST());
+ TypeFromUser tfu (m_frozen_sp->GetClangType(), m_frozen_sp->GetClangAST());
return tfu;
}
uint8_t *
ClangExpressionVariable::GetValueBytes()
{
- const size_t byte_size = m_valojb_sp->GetByteSize();
+ const size_t byte_size = m_frozen_sp->GetByteSize();
if (byte_size > 0)
{
- if (m_valojb_sp->GetDataExtractor().GetByteSize() < byte_size)
+ if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
{
- m_valojb_sp->GetValue().ResizeData(byte_size);
- m_valojb_sp->GetValue().GetData (m_valojb_sp->GetDataExtractor());
+ m_frozen_sp->GetValue().ResizeData(byte_size);
+ m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
}
- return const_cast<uint8_t *>(m_valojb_sp->GetDataExtractor().GetDataStart());
+ return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
}
return NULL;
}
@@ -122,12 +124,12 @@
void
ClangExpressionVariable::SetName (const ConstString &name)
{
- m_valojb_sp->SetName (name);
+ m_frozen_sp->SetName (name);
}
void
ClangExpressionVariable::ValueUpdated ()
{
- m_valojb_sp->ValueUpdated ();
+ m_frozen_sp->ValueUpdated ();
}