Have the Process hold a weak_ptr to the Target.
llvm-svn: 246578
diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp
index 7c13da8..8e8ab6d 100644
--- a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp
@@ -121,9 +121,9 @@
// Static functions.
ProcessSP
-ProcessWindows::CreateInstance(Target &target, Listener &listener, const FileSpec *)
+ProcessWindows::CreateInstance(lldb::TargetSP target_sp, Listener &listener, const FileSpec *)
{
- return ProcessSP(new ProcessWindows(target, listener));
+ return ProcessSP(new ProcessWindows(target_sp, listener));
}
void
@@ -142,8 +142,8 @@
//------------------------------------------------------------------------------
// Constructors and destructors.
-ProcessWindows::ProcessWindows(Target &target, Listener &listener)
- : lldb_private::Process(target, listener)
+ProcessWindows::ProcessWindows(lldb::TargetSP target_sp, Listener &listener)
+ : lldb_private::Process(target_sp, listener)
{
}
@@ -788,13 +788,13 @@
}
bool
-ProcessWindows::CanDebug(Target &target, bool plugin_specified_by_name)
+ProcessWindows::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
if (plugin_specified_by_name)
return true;
// For now we are just making sure the file exists for a given module
- ModuleSP exe_module_sp(target.GetExecutableModule());
+ ModuleSP exe_module_sp(target_sp->GetExecutableModule());
if (exe_module_sp.get())
return exe_module_sp->GetFileSpec().Exists();
// However, if there is no executable module, we return true since we might be preparing to attach.
@@ -807,10 +807,14 @@
// No need to acquire the lock since m_session_data isn't accessed.
WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %u exited with code %u", GetID(), exit_code);
- ModuleSP executable_module = GetTarget().GetExecutableModule();
- ModuleList unloaded_modules;
- unloaded_modules.Append(executable_module);
- GetTarget().ModulesDidUnload(unloaded_modules, true);
+ TargetSP target = m_target_sp.lock();
+ if (target)
+ {
+ ModuleSP executable_module = target->GetExecutableModule();
+ ModuleList unloaded_modules;
+ unloaded_modules.Append(executable_module);
+ target->ModulesDidUnload(unloaded_modules, true);
+ }
SetProcessExitStatus(nullptr, GetID(), true, 0, exit_code);
SetPrivateState(eStateExited);
diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.h b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.h
index 478819e..fa8d7f1 100644
--- a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.h
@@ -41,7 +41,7 @@
// Static functions.
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance(lldb_private::Target& target,
+ CreateInstance(lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *);
@@ -60,7 +60,7 @@
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
- ProcessWindows(lldb_private::Target& target,
+ ProcessWindows(lldb::TargetSP target_sp,
lldb_private::Listener &listener);
~ProcessWindows();
@@ -90,7 +90,7 @@
void RefreshStateAfterStop() override;
lldb::addr_t GetImageInfoAddress() override;
- bool CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
+ bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
bool
DestroyRequiresHalt() override
{
diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
index d8c70fd..f2e9aa4 100644
--- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
+++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
@@ -104,26 +104,26 @@
lldb::ProcessSP
-ProcessWinMiniDump::CreateInstance(Target &target, Listener &listener, const FileSpec *crash_file)
+ProcessWinMiniDump::CreateInstance(lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file)
{
lldb::ProcessSP process_sp;
if (crash_file)
{
- process_sp.reset(new ProcessWinMiniDump(target, listener, *crash_file));
+ process_sp.reset(new ProcessWinMiniDump(target_sp, listener, *crash_file));
}
return process_sp;
}
bool
-ProcessWinMiniDump::CanDebug(Target &target, bool plugin_specified_by_name)
+ProcessWinMiniDump::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
// TODO(amccarth): Eventually, this needs some actual logic.
return true;
}
-ProcessWinMiniDump::ProcessWinMiniDump(Target& target, Listener &listener,
+ProcessWinMiniDump::ProcessWinMiniDump(lldb::TargetSP target_sp, Listener &listener,
const FileSpec &core_file) :
- Process(target, listener),
+ Process(target_sp, listener),
m_data_up(new Data)
{
m_data_up->m_core_file = core_file;
@@ -163,7 +163,7 @@
return error;
}
- m_target.SetArchitecture(DetermineArchitecture());
+ GetTarget().SetArchitecture(DetermineArchitecture());
ReadModuleList();
ReadExceptionRecord();
diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
index 4339014..2151c9e 100644
--- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
+++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
@@ -23,7 +23,7 @@
{
public:
static lldb::ProcessSP
- CreateInstance (lldb_private::Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *crash_file_path);
@@ -39,7 +39,7 @@
static const char *
GetPluginDescriptionStatic();
- ProcessWinMiniDump(lldb_private::Target& target,
+ ProcessWinMiniDump(lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec &core_file);
@@ -47,7 +47,7 @@
~ProcessWinMiniDump();
bool
- CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
+ CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
lldb_private::Error
DoLoadCore() override;
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index ebd36b4..697a1c4 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -57,7 +57,7 @@
lldb::ProcessSP
-ProcessElfCore::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file)
+ProcessElfCore::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file)
{
lldb::ProcessSP process_sp;
if (crash_file)
@@ -75,7 +75,7 @@
if (elf_header.Parse(data, &data_offset))
{
if (elf_header.e_type == llvm::ELF::ET_CORE)
- process_sp.reset(new ProcessElfCore (target, listener, *crash_file));
+ process_sp.reset(new ProcessElfCore (target_sp, listener, *crash_file));
}
}
}
@@ -83,12 +83,12 @@
}
bool
-ProcessElfCore::CanDebug(Target &target, bool plugin_specified_by_name)
+ProcessElfCore::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
// For now we are just making sure the file exists for a given module
if (!m_core_module_sp && m_core_file.Exists())
{
- ModuleSpec core_module_spec(m_core_file, target.GetArchitecture());
+ ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture());
Error error (ModuleList::GetSharedModule (core_module_spec, m_core_module_sp,
NULL, NULL, NULL));
if (m_core_module_sp)
@@ -104,9 +104,9 @@
//----------------------------------------------------------------------
// ProcessElfCore constructor
//----------------------------------------------------------------------
-ProcessElfCore::ProcessElfCore(Target& target, Listener &listener,
+ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp, Listener &listener,
const FileSpec &core_file) :
- Process (target, listener),
+ Process (target_sp, listener),
m_core_module_sp (),
m_core_file (core_file),
m_dyld_plugin_name (),
@@ -233,7 +233,7 @@
// it to match the core file which is always single arch.
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.IsValid())
- m_target.SetArchitecture(arch);
+ GetTarget().SetArchitecture(arch);
SetUnixSignals(UnixSignals::Create(GetArchitecture()));
@@ -370,12 +370,11 @@
lldb::addr_t
ProcessElfCore::GetImageInfoAddress()
{
- Target *target = &GetTarget();
- ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
- Address addr = obj_file->GetImageInfoAddress(target);
+ ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(&GetTarget());
if (addr.IsValid())
- return addr.GetLoadAddress(target);
+ return addr.GetLoadAddress(&GetTarget());
return LLDB_INVALID_ADDRESS;
}
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 538deac..40eb4e1 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -37,7 +37,7 @@
// Constructors and Destructors
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance (lldb_private::Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *crash_file_path);
@@ -56,9 +56,9 @@
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ProcessElfCore(lldb_private::Target& target,
- lldb_private::Listener &listener,
- const lldb_private::FileSpec &core_file);
+ ProcessElfCore(lldb::TargetSP target_sp,
+ lldb_private::Listener &listener,
+ const lldb_private::FileSpec &core_file);
virtual
~ProcessElfCore();
@@ -66,7 +66,7 @@
//------------------------------------------------------------------
// Check if a given Process
//------------------------------------------------------------------
- bool CanDebug(lldb_private::Target &target, bool plugin_specified_by_name) override;
+ bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
//------------------------------------------------------------------
// Creating a new process, or attaching to an existing one
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index aac3df1..17036d9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -333,22 +333,22 @@
lldb::ProcessSP
-ProcessGDBRemote::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file_path)
+ProcessGDBRemote::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file_path)
{
lldb::ProcessSP process_sp;
if (crash_file_path == NULL)
- process_sp.reset (new ProcessGDBRemote (target, listener));
+ process_sp.reset (new ProcessGDBRemote (target_sp, listener));
return process_sp;
}
bool
-ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name)
+ProcessGDBRemote::CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
if (plugin_specified_by_name)
return true;
// For now we are just making sure the file exists for a given module
- Module *exe_module = target.GetExecutableModulePointer();
+ Module *exe_module = target_sp->GetExecutableModulePointer();
if (exe_module)
{
ObjectFile *exe_objfile = exe_module->GetObjectFile();
@@ -377,8 +377,8 @@
//----------------------------------------------------------------------
// ProcessGDBRemote constructor
//----------------------------------------------------------------------
-ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
- Process (target, listener),
+ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener) :
+ Process (target_sp, listener),
m_flags (0),
m_gdb_comm (),
m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
@@ -804,15 +804,16 @@
if (GetTarget().GetNonStopModeEnabled())
HandleStopReplySequence();
- if (!m_target.GetArchitecture().IsValid())
+ Target &target = GetTarget();
+ if (!target.GetArchitecture().IsValid())
{
if (m_gdb_comm.GetProcessArchitecture().IsValid())
{
- m_target.SetArchitecture(m_gdb_comm.GetProcessArchitecture());
+ target.SetArchitecture(m_gdb_comm.GetProcessArchitecture());
}
else
{
- m_target.SetArchitecture(m_gdb_comm.GetHostArchitecture());
+ target.SetArchitecture(m_gdb_comm.GetHostArchitecture());
}
}
@@ -946,7 +947,7 @@
lldb_utility::PseudoTerminal pty;
const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0;
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (disable_stdio)
{
// set to /dev/null unless redirected to a file above
@@ -1002,7 +1003,7 @@
m_gdb_comm.SetDisableASLR (launch_flags & eLaunchFlagDisableASLR);
m_gdb_comm.SetDetachOnError (launch_flags & eLaunchFlagDetachOnError);
- m_gdb_comm.SendLaunchArchPacket (m_target.GetArchitecture().GetArchitectureName());
+ m_gdb_comm.SendLaunchArchPacket (GetTarget().GetArchitecture().GetArchitectureName());
const char * launch_event_data = launch_info.GetLaunchEventData();
if (launch_event_data != NULL && *launch_event_data != '\0')
@@ -1069,13 +1070,13 @@
if (process_arch.IsValid())
{
- m_target.MergeArchitecture(process_arch);
+ GetTarget().MergeArchitecture(process_arch);
}
else
{
const ArchSpec &host_arch = m_gdb_comm.GetHostArchitecture();
if (host_arch.IsValid())
- m_target.MergeArchitecture(host_arch);
+ GetTarget().MergeArchitecture(host_arch);
}
SetPrivateState (SetThreadStopInfo (response));
@@ -3991,10 +3992,10 @@
}
else
{
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (platform_sp)
{
- m_thread_create_bp_sp = platform_sp->SetThreadCreationBreakpoint(m_target);
+ m_thread_create_bp_sp = platform_sp->SetThreadCreationBreakpoint(GetTarget());
if (m_thread_create_bp_sp)
{
if (log && log->GetVerbose())
@@ -4774,7 +4775,7 @@
if (new_modules.GetSize() > 0)
{
- Target & target = m_target;
+ Target &target = GetTarget();
new_modules.ForEach ([&target](const lldb::ModuleSP module_sp) -> bool
{
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index c2a99ba..0048004 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -46,7 +46,7 @@
// Constructors and Destructors
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance (Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
Listener &listener,
const FileSpec *crash_file_path);
@@ -68,7 +68,7 @@
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ProcessGDBRemote(Target& target, Listener &listener);
+ ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener);
virtual
~ProcessGDBRemote();
@@ -77,7 +77,7 @@
// Check if a given Process
//------------------------------------------------------------------
bool
- CanDebug (Target &target, bool plugin_specified_by_name) override;
+ CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
CommandObject *
GetPluginCommandObject() override;
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 0e3711b..b199ec60 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -64,7 +64,7 @@
lldb::ProcessSP
-ProcessMachCore::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file)
+ProcessMachCore::CreateInstance (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file)
{
lldb::ProcessSP process_sp;
if (crash_file)
@@ -80,7 +80,7 @@
if (ObjectFileMachO::ParseHeader(data, &data_offset, mach_header))
{
if (mach_header.filetype == llvm::MachO::MH_CORE)
- process_sp.reset(new ProcessMachCore (target, listener, *crash_file));
+ process_sp.reset(new ProcessMachCore (target_sp, listener, *crash_file));
}
}
@@ -89,7 +89,7 @@
}
bool
-ProcessMachCore::CanDebug(Target &target, bool plugin_specified_by_name)
+ProcessMachCore::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
{
if (plugin_specified_by_name)
return true;
@@ -121,8 +121,8 @@
//----------------------------------------------------------------------
// ProcessMachCore constructor
//----------------------------------------------------------------------
-ProcessMachCore::ProcessMachCore(Target& target, Listener &listener, const FileSpec &core_file) :
- Process (target, listener),
+ProcessMachCore::ProcessMachCore(lldb::TargetSP target_sp, Listener &listener, const FileSpec &core_file) :
+ Process (target_sp, listener),
m_core_aranges (),
m_core_module_sp (),
m_core_file (core_file),
@@ -360,10 +360,10 @@
ArchSpec arch (m_core_module_sp->GetArchitecture());
if (arch.GetCore() == ArchSpec::eCore_x86_32_i486)
{
- arch.SetTriple ("i386", m_target.GetPlatform().get());
+ arch.SetTriple ("i386", GetTarget().GetPlatform().get());
}
if (arch.IsValid())
- m_target.SetArchitecture(arch);
+ GetTarget().SetArchitecture(arch);
return error;
}
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index d4825ec..27b30d5 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -30,7 +30,7 @@
// Constructors and Destructors
//------------------------------------------------------------------
static lldb::ProcessSP
- CreateInstance (lldb_private::Target& target,
+ CreateInstance (lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec *crash_file_path);
@@ -49,7 +49,7 @@
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ProcessMachCore(lldb_private::Target& target,
+ ProcessMachCore(lldb::TargetSP target_sp,
lldb_private::Listener &listener,
const lldb_private::FileSpec &core_file);
@@ -59,57 +59,57 @@
//------------------------------------------------------------------
// Check if a given Process
//------------------------------------------------------------------
- virtual bool
- CanDebug (lldb_private::Target &target,
- bool plugin_specified_by_name);
+ bool
+ CanDebug (lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) override;
//------------------------------------------------------------------
// Creating a new process, or attaching to an existing one
//------------------------------------------------------------------
- virtual lldb_private::Error
- DoLoadCore ();
+ lldb_private::Error
+ DoLoadCore () override;
- virtual lldb_private::DynamicLoader *
- GetDynamicLoader ();
+ lldb_private::DynamicLoader *
+ GetDynamicLoader () override;
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
- virtual lldb_private::ConstString
- GetPluginName();
+ lldb_private::ConstString
+ GetPluginName() override;
- virtual uint32_t
- GetPluginVersion();
+ uint32_t
+ GetPluginVersion() override;
//------------------------------------------------------------------
// Process Control
//------------------------------------------------------------------
- virtual lldb_private::Error
- DoDestroy ();
+ lldb_private::Error
+ DoDestroy () override;
- virtual void
- RefreshStateAfterStop();
+ void
+ RefreshStateAfterStop() override;
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------
- virtual bool
- IsAlive ();
+ bool
+ IsAlive () override;
- virtual bool
- WarnBeforeDetach () const;
+ bool
+ WarnBeforeDetach () const override;
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
- virtual size_t
- ReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error);
+ size_t
+ ReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
- virtual size_t
- DoReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error);
+ size_t
+ DoReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
- virtual lldb::addr_t
- GetImageInfoAddress ();
+ lldb::addr_t
+ GetImageInfoAddress () override;
protected:
friend class ThreadMachCore;
@@ -119,7 +119,7 @@
virtual bool
UpdateThreadList (lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &new_thread_list);
+ lldb_private::ThreadList &new_thread_list) override;
lldb_private::ObjectFile *
GetCoreObjectFile ();
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 0185a8d..531a14c 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -648,7 +648,7 @@
}
ProcessSP
-Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
+Process::FindPlugin (lldb::TargetSP target_sp, const char *plugin_name, Listener &listener, const FileSpec *crash_file_path)
{
static uint32_t g_process_unique_id = 0;
@@ -660,10 +660,10 @@
create_callback = PluginManager::GetProcessCreateCallbackForPluginName (const_plugin_name);
if (create_callback)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, true))
+ if (process_sp->CanDebug(target_sp, true))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
}
@@ -676,10 +676,10 @@
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetProcessCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- process_sp = create_callback(target, listener, crash_file_path);
+ process_sp = create_callback(target_sp, listener, crash_file_path);
if (process_sp)
{
- if (process_sp->CanDebug(target, false))
+ if (process_sp->CanDebug(target_sp, false))
{
process_sp->m_process_unique_id = ++g_process_unique_id;
break;
@@ -702,18 +702,18 @@
//----------------------------------------------------------------------
// Process constructor
//----------------------------------------------------------------------
-Process::Process(Target &target, Listener &listener) :
- Process(target, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
+Process::Process(lldb::TargetSP target_sp, Listener &listener) :
+ Process(target_sp, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
{
// This constructor just delegates to the full Process constructor,
// defaulting to using the Host's UnixSignals.
}
-Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
+Process::Process(lldb::TargetSP target_sp, Listener &listener, const UnixSignalsSP &unix_signals_sp) :
ProcessProperties (this),
UserID (LLDB_INVALID_PROCESS_ID),
- Broadcaster (&(target.GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
- m_target (target),
+ Broadcaster (&(target_sp->GetDebugger()), Process::GetStaticBroadcasterClass().AsCString()),
+ m_target_sp (target_sp),
m_public_state (eStateUnloaded),
m_private_state (eStateUnloaded),
m_private_state_broadcaster (NULL, "lldb.process.internal_state_broadcaster"),
@@ -2095,7 +2095,7 @@
Process::GetABI()
{
if (!m_abi_sp)
- m_abi_sp = ABI::FindPlugin(m_target.GetArchitecture());
+ m_abi_sp = ABI::FindPlugin(GetTarget().GetArchitecture());
return m_abi_sp;
}
@@ -2275,22 +2275,22 @@
load_addr = ResolveIndirectFunction (&symbol_address, error);
if (!error.Success() && show_error)
{
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- symbol->GetLoadAddress(&m_target),
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to resolve indirect function at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ symbol->GetLoadAddress(&GetTarget()),
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
return LLDB_INVALID_BREAK_ID;
}
Address resolved_address(load_addr);
- load_addr = resolved_address.GetOpcodeLoadAddress (&m_target);
+ load_addr = resolved_address.GetOpcodeLoadAddress (&GetTarget());
owner->SetIsIndirect(true);
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
}
else
- load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target);
+ load_addr = owner->GetAddress().GetOpcodeLoadAddress (&GetTarget());
if (load_addr != LLDB_INVALID_ADDRESS)
{
@@ -2323,11 +2323,11 @@
if (show_error)
{
// Report error for setting breakpoint...
- m_target.GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- load_addr,
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unknown error");
+ GetTarget().GetDebugger().GetErrorFile()->Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ load_addr,
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unknown error");
}
}
}
@@ -2385,9 +2385,9 @@
size_t
Process::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
{
- PlatformSP platform_sp (m_target.GetPlatform());
+ PlatformSP platform_sp (GetTarget().GetPlatform());
if (platform_sp)
- return platform_sp->GetSoftwareBreakpointTrapOpcode (m_target, bp_site);
+ return platform_sp->GetSoftwareBreakpointTrapOpcode (GetTarget(), bp_site);
return 0;
}
@@ -3165,7 +3165,7 @@
m_process_input_reader.reset();
m_stop_info_override_callback = NULL;
- Module *exe_module = m_target.GetExecutableModulePointer();
+ Module *exe_module = GetTarget().GetExecutableModulePointer();
if (exe_module)
{
char local_exec_file_path[PATH_MAX];
@@ -3512,7 +3512,7 @@
else
{
ProcessInstanceInfoList process_infos;
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
if (platform_sp)
{
@@ -3614,7 +3614,7 @@
if (process_arch.IsValid())
{
- m_target.SetArchitecture(process_arch);
+ GetTarget().SetArchitecture(process_arch);
if (log)
{
const char *triple_str = process_arch.GetTriple().getTriple().c_str ();
@@ -3626,19 +3626,19 @@
// We just attached. If we have a platform, ask it for the process architecture, and if it isn't
// the same as the one we've already set, switch architectures.
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
assert (platform_sp.get());
if (platform_sp)
{
- const ArchSpec &target_arch = m_target.GetArchitecture();
+ const ArchSpec &target_arch = GetTarget().GetArchitecture();
if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture (target_arch, false, NULL))
{
ArchSpec platform_arch;
platform_sp = platform_sp->GetPlatformForArchitecture (target_arch, &platform_arch);
if (platform_sp)
{
- m_target.SetPlatform (platform_sp);
- m_target.SetArchitecture(platform_arch);
+ GetTarget().SetPlatform (platform_sp);
+ GetTarget().SetArchitecture(platform_arch);
if (log)
log->Printf ("Process::%s switching platform to %s and architecture to %s based on info from attach", __FUNCTION__, platform_sp->GetName().AsCString (""), platform_arch.GetTriple().getTriple().c_str ());
}
@@ -3648,9 +3648,9 @@
ProcessInstanceInfo process_info;
platform_sp->GetProcessInfo (GetID(), process_info);
const ArchSpec &process_arch = process_info.GetArchitecture();
- if (process_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(process_arch))
+ if (process_arch.IsValid() && !GetTarget().GetArchitecture().IsExactMatch(process_arch))
{
- m_target.SetArchitecture (process_arch);
+ GetTarget().SetArchitecture (process_arch);
if (log)
log->Printf ("Process::%s switching architecture to %s based on info the platform retrieved for pid %" PRIu64, __FUNCTION__, process_arch.GetTriple().getTriple().c_str (), GetID ());
}
@@ -3665,7 +3665,7 @@
dyld->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after DynamicLoader::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3681,7 +3681,7 @@
system_runtime->DidAttach();
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after SystemRuntime::DidAttach(), target executable is %s (using %s plugin)",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
@@ -3691,7 +3691,7 @@
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
- const ModuleList &target_modules = m_target.GetImages();
+ const ModuleList &target_modules = GetTarget().GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
ModuleSP new_executable_module_sp;
@@ -3701,17 +3701,17 @@
ModuleSP module_sp (target_modules.GetModuleAtIndexUnlocked (i));
if (module_sp && module_sp->IsExecutable())
{
- if (m_target.GetExecutableModulePointer() != module_sp.get())
+ if (GetTarget().GetExecutableModulePointer() != module_sp.get())
new_executable_module_sp = module_sp;
break;
}
}
if (new_executable_module_sp)
{
- m_target.SetExecutableModule (new_executable_module_sp, false);
+ GetTarget().SetExecutableModule (new_executable_module_sp, false);
if (log)
{
- ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ ModuleSP exe_module_sp = GetTarget().GetExecutableModule ();
log->Printf ("Process::%s after looping through modules, target executable is %s",
__FUNCTION__,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>");
@@ -4136,13 +4136,13 @@
lldb::ByteOrder
Process::GetByteOrder () const
{
- return m_target.GetArchitecture().GetByteOrder();
+ return GetTarget().GetArchitecture().GetByteOrder();
}
uint32_t
Process::GetAddressByteSize () const
{
- return m_target.GetArchitecture().GetAddressByteSize();
+ return GetTarget().GetArchitecture().GetAddressByteSize();
}
@@ -4549,7 +4549,7 @@
// events) and we do need the IO handler to be pushed and popped
// correctly.
- if (is_hijacked || m_target.GetDebugger().IsHandlingEvents() == false)
+ if (is_hijacked || GetTarget().GetDebugger().IsHandlingEvents() == false)
PopProcessIOHandler ();
}
}
@@ -4989,13 +4989,13 @@
lldb::TargetSP
Process::CalculateTarget ()
{
- return m_target.shared_from_this();
+ return m_target_sp.lock();
}
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
- exe_ctx.SetTargetPtr (&m_target);
+ exe_ctx.SetTargetPtr (&GetTarget());
exe_ctx.SetProcessPtr (this);
exe_ctx.SetThreadPtr(NULL);
exe_ctx.SetFramePtr (NULL);
@@ -5323,7 +5323,7 @@
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().IsTopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().IsTopIOHandler (io_handler_sp);
return false;
}
bool
@@ -5337,7 +5337,7 @@
log->Printf("Process::%s pushing IO handler", __FUNCTION__);
io_handler_sp->SetIsDone(false);
- m_target.GetDebugger().PushIOHandler (io_handler_sp);
+ GetTarget().GetDebugger().PushIOHandler (io_handler_sp);
return true;
}
return false;
@@ -5348,7 +5348,7 @@
{
IOHandlerSP io_handler_sp (m_process_input_reader);
if (io_handler_sp)
- return m_target.GetDebugger().PopIOHandler (io_handler_sp);
+ return GetTarget().GetDebugger().PopIOHandler (io_handler_sp);
return false;
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index b63a1e0..ecb1895 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -203,7 +203,7 @@
Target::CreateProcess (Listener &listener, const char *plugin_name, const FileSpec *crash_file)
{
DeleteCurrentProcess ();
- m_process_sp = Process::FindPlugin(*this, plugin_name, listener, crash_file);
+ m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener, crash_file);
return m_process_sp;
}