diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index ed674ee1275c7..9bc745d967fe9 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1005,7 +1005,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) if (log_callback) m_callback_handler_sp = std::make_shared(log_callback, baton); - m_command_interpreter_up->Initialize(); + // Always add our default platform to the platform list PlatformSP default_platform_sp(Platform::GetHostPlatform()); assert(default_platform_sp); @@ -1023,6 +1023,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) } assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?"); + m_command_interpreter_up->Initialize(); + OptionValueUInt64 *term_width = m_collection_sp->GetPropertyAtIndexAsOptionValueUInt64( ePropertyTerminalWidth); @@ -1221,8 +1223,8 @@ void Debugger::RedrawStatusline(bool update) { } ExecutionContext Debugger::GetSelectedExecutionContext() { - bool adopt_selected = true; - ExecutionContextRef exe_ctx_ref(GetSelectedTarget().get(), adopt_selected); + ExecutionContextRef exe_ctx_ref(&GetSelectedOrDummyTarget(), + /*adopt_selected=*/true); return ExecutionContext(exe_ctx_ref); } diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp index 393d427241021..cfed40ac7fb2b 100644 --- a/lldb/source/Core/Statusline.cpp +++ b/lldb/source/Core/Statusline.cpp @@ -134,11 +134,7 @@ void Statusline::Redraw(bool update) { } ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext(); - - // For colors and progress events, the format entity needs access to the - // debugger, which requires a target in the execution context. - if (!exe_ctx.HasTargetScope()) - exe_ctx.SetTargetPtr(&m_debugger.GetSelectedOrDummyTarget()); + assert(exe_ctx.HasTargetScope() && "format entity needs a target"); SymbolContext symbol_ctx; if (ProcessSP process_sp = exe_ctx.GetProcessSP()) { diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 129646ebddb94..1bdec93c1f8c4 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -147,7 +147,7 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) { // we don't want any CommandObject instances to keep any of these objects // around longer than for a single command. Every command should call // CommandObject::Cleanup() after it has completed. - assert(!m_exe_ctx.GetTargetPtr()); + assert(!m_exe_ctx.GetTargetPtr() || m_exe_ctx.GetTargetRef().IsDummyTarget()); assert(!m_exe_ctx.GetProcessPtr()); assert(!m_exe_ctx.GetThreadPtr()); assert(!m_exe_ctx.GetFramePtr());