summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp38
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp24
2 files changed, 46 insertions, 16 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 3540a4d0783..6c7b2a87dff 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -588,7 +588,12 @@ ClangExpressionDeclMap::Materialize
m_material_vars->m_process = exe_ctx.process;
- bool result = DoMaterialize(false /* dematerialize */, exe_ctx, NULL, err);
+ bool result = DoMaterialize(false /* dematerialize */,
+ exe_ctx,
+ LLDB_INVALID_ADDRESS /* top of stack frame */,
+ LLDB_INVALID_ADDRESS /* bottom of stack frame */,
+ NULL, /* result SP */
+ err);
if (result)
struct_address = m_material_vars->m_materialized_location;
@@ -717,10 +722,12 @@ ClangExpressionDeclMap::Dematerialize
(
ExecutionContext &exe_ctx,
ClangExpressionVariableSP &result_sp,
+ lldb::addr_t stack_frame_top,
+ lldb::addr_t stack_frame_bottom,
Error &err
)
{
- return DoMaterialize(true, exe_ctx, &result_sp, err);
+ return DoMaterialize(true, exe_ctx, stack_frame_top, stack_frame_bottom, &result_sp, err);
DidDematerialize();
}
@@ -825,6 +832,8 @@ ClangExpressionDeclMap::DoMaterialize
(
bool dematerialize,
ExecutionContext &exe_ctx,
+ lldb::addr_t stack_frame_top,
+ lldb::addr_t stack_frame_bottom,
lldb::ClangExpressionVariableSP *result_sp_ptr,
Error &err
)
@@ -948,7 +957,9 @@ ClangExpressionDeclMap::DoMaterialize
if (!DoMaterializeOnePersistentVariable (dematerialize,
exe_ctx,
member_sp,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ stack_frame_top,
+ stack_frame_bottom,
err))
return false;
}
@@ -1027,6 +1038,8 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
ExecutionContext &exe_ctx,
ClangExpressionVariableSP &var_sp,
lldb::addr_t addr,
+ lldb::addr_t stack_frame_top,
+ lldb::addr_t stack_frame_bottom,
Error &err
)
{
@@ -1103,10 +1116,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
log->Printf("Dematerializing %s from 0x%llx", var_sp->GetName().GetCString(), (uint64_t)mem);
// Read the contents of the spare memory area
-
- if (log)
- log->Printf("Read");
-
+
var_sp->ValueUpdated ();
if (exe_ctx.process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
{
@@ -1114,6 +1124,20 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
return false;
}
+ if (stack_frame_top != LLDB_INVALID_ADDRESS &&
+ stack_frame_bottom != LLDB_INVALID_ADDRESS &&
+ mem >= stack_frame_bottom &&
+ mem <= stack_frame_top)
+ {
+ // If the variable is resident in the stack frame created by the expression,
+ // then it cannot be relied upon to stay around. We treat it as needing
+ // reallocation.
+
+ var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
+ var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
+ var_sp->m_flags &= ~ClangExpressionVariable::EVIsProgramReference;
+ }
+
var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsFreezeDry;
}
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index f1dd49f64dd..6eafd7be7fe 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -421,7 +421,8 @@ ClangUserExpression::GetThreadPlanToExecuteJITExpression (Stream &error_stream,
bool
ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
ExecutionContext &exe_ctx,
- lldb::ClangExpressionVariableSP &result)
+ lldb::ClangExpressionVariableSP &result,
+ lldb::addr_t function_stack_pointer)
{
Error expr_error;
@@ -444,8 +445,11 @@ ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
log->Printf(" Structure contents:\n%s", args.GetData());
}
}
+
+ lldb::addr_t function_stack_bottom = function_stack_pointer - Host::GetPageSize();
+
- if (!m_expr_decl_map->Dematerialize(exe_ctx, result, expr_error))
+ if (!m_expr_decl_map->Dematerialize(exe_ctx, result, function_stack_pointer, function_stack_bottom, expr_error))
{
error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
return false;
@@ -497,6 +501,8 @@ ClangUserExpression::Execute (Stream &error_stream,
if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL))
return eExecutionSetupError;
+
+ lldb::addr_t function_stack_pointer = static_cast<ThreadPlanCallFunction *>(call_plan_sp.get())->GetFunctionStackPointer();
call_plan_sp->SetPrivate(true);
@@ -506,12 +512,12 @@ ClangUserExpression::Execute (Stream &error_stream,
log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --");
ExecutionResults execution_result = exe_ctx.process->RunThreadPlan (exe_ctx,
- call_plan_sp,
- stop_others,
- try_all_threads,
- discard_on_error,
- single_thread_timeout_usec,
- error_stream);
+ call_plan_sp,
+ stop_others,
+ try_all_threads,
+ discard_on_error,
+ single_thread_timeout_usec,
+ error_stream);
if (log)
log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --");
@@ -531,7 +537,7 @@ ClangUserExpression::Execute (Stream &error_stream,
return execution_result;
}
- if (FinalizeJITExecution (error_stream, exe_ctx, result))
+ if (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_pointer))
return eExecutionCompleted;
else
return eExecutionSetupError;
OpenPOWER on IntegriCloud