From d43d912b4bf8f4886ca375225d4ebd7d512ea7cf Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 26 Aug 2019 09:20:59 +0000 Subject: [PATCH] [lldb] Construct the dummy target when the first Debugger object is constructed Summary: We should always have a dummy target, so we might as well construct it directly when we create a Debugger object. The idea is that if this patch doesn't cause any problems that we can get rid of all the logic that handles situations where we don't have a dummy target (as all that code is currently untested as there seems to be no way to have no dummy target in LLDB). Reviewers: labath, jingham Reviewed By: labath, jingham Subscribers: jingham, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66581 llvm-svn: 369885 --- lldb/include/lldb/Core/Debugger.h | 3 ++- lldb/source/Core/Debugger.cpp | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 8e857e009a1b..2b5bf5136510 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -311,7 +311,7 @@ public: // selected target, or if no target is present you want to prime the dummy // target with entities that will be copied over to new targets. Target *GetSelectedOrDummyTarget(bool prefer_dummy = false); - Target *GetDummyTarget(); + Target *GetDummyTarget() { return m_dummy_target_sp.get(); } lldb::BroadcasterManagerSP GetBroadcasterManager() { return m_broadcaster_manager_sp; @@ -400,6 +400,7 @@ protected: Broadcaster m_sync_broadcaster; lldb::ListenerSP m_forward_listener_sp; llvm::once_flag m_clear_once; + lldb::TargetSP m_dummy_target_sp; // Events for m_sync_broadcaster enum { diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 513ea7a0d04f..683ecefe097b 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -721,6 +721,9 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) assert(default_platform_sp); m_platform_list.Append(default_platform_sp, true); + m_dummy_target_sp = m_target_list.GetDummyTarget(*this); + assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?"); + m_collection_sp->Initialize(g_debugger_properties); m_collection_sp->AppendProperty( ConstString("target"), @@ -1603,10 +1606,6 @@ void Debugger::JoinIOHandlerThread() { } } -Target *Debugger::GetDummyTarget() { - return m_target_list.GetDummyTarget(*this).get(); -} - Target *Debugger::GetSelectedOrDummyTarget(bool prefer_dummy) { Target *target = nullptr; if (!prefer_dummy) {