diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 703e13563327..9c4c05d2410c 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -314,7 +314,12 @@ CommandObjectExpression::EvaluateExpression CommandReturnObject *result ) { - Target *target = m_exe_ctx.GetTargetPtr(); + // Don't use m_exe_ctx as this might be called asynchronously + // after the command object DoExecute has finished when doing + // multi-line expression that use an input reader... + ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); + + Target *target = exe_ctx.GetTargetPtr(); if (!target) target = Host::GetDummyTarget(m_interpreter.GetDebugger()).get(); @@ -337,7 +342,7 @@ CommandObjectExpression::EvaluateExpression .SetTimeoutUsec(m_command_options.timeout); exe_results = target->EvaluateExpression (expr, - m_exe_ctx.GetFramePtr(), + exe_ctx.GetFramePtr(), result_valobj_sp, options); @@ -347,7 +352,7 @@ CommandObjectExpression::EvaluateExpression uint32_t start_frame = 0; uint32_t num_frames = 1; uint32_t num_frames_with_source = 0; - Thread *thread = m_exe_ctx.GetThreadPtr(); + Thread *thread = exe_ctx.GetThreadPtr(); if (thread) { thread->GetStatus (result->GetOutputStream(), @@ -357,7 +362,7 @@ CommandObjectExpression::EvaluateExpression } else { - Process *process = m_exe_ctx.GetProcessPtr(); + Process *process = exe_ctx.GetProcessPtr(); if (process) { bool only_threads_with_stop_reason = true;