Add "-o" option to "expression" which prints the object description if available.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115115 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
index 37fc6c2..f406583 100644
--- a/source/Expression/ClangExpressionVariable.cpp
+++ b/source/Expression/ClangExpressionVariable.cpp
@@ -50,23 +50,14 @@
{
Error err;
- if (!m_data_vars.get() || !m_data_vars->m_data)
+ Value val;
+ if (!PointValueAtData (val, &exe_ctx))
{
err.SetErrorToGenericError();
err.SetErrorStringWithFormat("Variable doesn't contain a value");
return err;
}
- Value val;
-
- clang::ASTContext *ast_context = m_user_type.GetASTContext();
-
- val.SetContext (Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType ());
- val.SetValueType (Value::eValueTypeHostAddress);
- val.GetScalar() = (uint64_t)m_data_vars->m_data->GetBytes ();
-
- val.ResolveValue (&exe_ctx, ast_context);
-
if (val.GetContextType () == Value::eContextTypeInvalid &&
val.GetValueType () == Value::eValueTypeScalar &&
format == lldb::eFormatDefault)
@@ -77,6 +68,8 @@
return err;
}
+ clang::ASTContext *ast_context = m_user_type.GetASTContext();
+
// The expression result is more complex and requires special handling
DataExtractor data;
Error expr_error = val.GetValueAsData (&exe_ctx, ast_context, data, 0);
@@ -165,14 +158,18 @@
}
bool
-ClangExpressionVariable::PointValueAtData(Value &value)
+ClangExpressionVariable::PointValueAtData(Value &value, ExecutionContext *exe_ctx)
{
- if (!m_data_vars.get())
+ if (!m_data_vars.get() || !m_data_vars->m_data)
return false;
value.SetContext(Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType());
value.SetValueType(Value::eValueTypeHostAddress);
value.GetScalar() = (uint64_t)m_data_vars->m_data->GetBytes();
+ clang::ASTContext *ast_context = m_user_type.GetASTContext();
+
+ if (exe_ctx)
+ value.ResolveValue (exe_ctx, ast_context);
return true;
}
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index aaff16d..7f8d3ae 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -667,7 +667,8 @@
// Thread we ran the function in may have gone away because we ran the target
// Check that it's still there.
exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get();
- exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get();
+ if (exe_ctx.thread)
+ exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get();
// Also restore the current process'es selected frame & thread, since this function calling may
// be done behind the user's back.