Extended the IR interpreter to handle the variables
"_cmd", "this", and "self". These variables are handled
differently from all other external variables used by
the expression. Other variables are used indirectly
through the $__lldb_arg operand; only _cmd, this, and
self are passed directly through the ABI.
There are two modifications:
- I added a function to ClangExpressionDeclMap that
retrives the value of one of these variables by name;
and
- I made IRInterpreter fetch these values when needed,
and ensured that the proper level of indirection is
used.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@143065 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 1093932..64dea9c 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -959,7 +959,12 @@
if (!expr_var_sp->m_parser_vars.get() || !expr_var_sp->m_parser_vars->m_lldb_var)
return Value();
- return *GetVariableValue(exe_ctx, expr_var_sp->m_parser_vars->m_lldb_var, NULL);
+ std::auto_ptr<Value> value(GetVariableValue(exe_ctx, expr_var_sp->m_parser_vars->m_lldb_var, NULL));
+
+ if (value.get())
+ return *value;
+ else
+ return Value();
}
else if (persistent_var_sp)
{
@@ -969,7 +974,7 @@
m_parser_vars->m_exe_ctx->GetProcessSP() &&
m_parser_vars->m_exe_ctx->GetProcessSP()->IsAlive())
{
- return persistent_var_sp->m_live_sp->GetValue();
+ return persistent_var_sp->m_live_sp->GetValue();
}
else
{
@@ -986,6 +991,39 @@
}
}
+Value
+ClangExpressionDeclMap::GetSpecialValue (const ConstString &name)
+{
+ assert(m_parser_vars.get());
+
+ if (!m_parser_vars->m_exe_ctx)
+ return Value();
+
+ StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr();
+
+ if (!frame)
+ return Value();
+
+ VariableList *vars = frame->GetVariableList(false);
+
+ if (!vars)
+ return Value();
+
+ lldb::VariableSP var = vars->FindVariable(name);
+
+ if (!var ||
+ !var->IsInScope(frame) ||
+ !var->LocationIsValidForFrame (frame))
+ return Value();
+
+ std::auto_ptr<Value> value(GetVariableValue(*m_parser_vars->m_exe_ctx, var, NULL));
+
+ if (value.get())
+ return *value;
+ else
+ return Value();
+}
+
// Interface for CommandObjectExpression
bool
@@ -1535,8 +1573,8 @@
Error allocate_error;
mem = process->AllocateMemory(pvar_byte_size,
- lldb::ePermissionsReadable | lldb::ePermissionsWritable,
- allocate_error);
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ allocate_error);
if (mem == LLDB_INVALID_ADDRESS)
{
@@ -1577,9 +1615,9 @@
// Now write the location of the area into the struct.
Error write_error;
if (!process->WriteScalarToMemory (addr,
- var_sp->m_live_sp->GetValue().GetScalar(),
- process->GetAddressByteSize(),
- write_error))
+ var_sp->m_live_sp->GetValue().GetScalar(),
+ process->GetAddressByteSize(),
+ write_error))
{
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString());
return false;