[Lldb-commits] [lldb] r246578 - Have the Process hold a weak_ptr to the Target.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 1 13:02:30 PDT 2015
Author: zturner
Date: Tue Sep 1 15:02:29 2015
New Revision: 246578
URL: http://llvm.org/viewvc/llvm-project?rev=246578&view=rev
Log:
Have the Process hold a weak_ptr to the Target.
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-private-interfaces.h
lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.h
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Sep 1 15:02:29 2015
@@ -955,13 +955,13 @@ public:
/// Construct with a shared pointer to a target, and the Process listener.
/// Uses the Host UnixSignalsSP by default.
//------------------------------------------------------------------
- Process(Target &target, Listener &listener);
+ Process(lldb::TargetSP target_sp, Listener &listener);
//------------------------------------------------------------------
/// Construct with a shared pointer to a target, the Process listener,
/// and the appropriate UnixSignalsSP for the process.
//------------------------------------------------------------------
- Process(Target &target, Listener &listener, const lldb::UnixSignalsSP &unix_signals_sp);
+ Process(lldb::TargetSP target_sp, Listener &listener, const lldb::UnixSignalsSP &unix_signals_sp);
//------------------------------------------------------------------
/// Destructor.
@@ -990,7 +990,7 @@ public:
/// @see Process::CanDebug ()
//------------------------------------------------------------------
static lldb::ProcessSP
- FindPlugin (Target &target,
+ FindPlugin (lldb::TargetSP target_sp,
const char *plugin_name,
Listener &listener,
const FileSpec *crash_file_path);
@@ -1041,7 +1041,7 @@ public:
/// debug the executable, \b false otherwise.
//------------------------------------------------------------------
virtual bool
- CanDebug (Target &target,
+ CanDebug (lldb::TargetSP target,
bool plugin_specified_by_name) = 0;
@@ -1847,7 +1847,7 @@ public:
Target &
GetTarget ()
{
- return m_target;
+ return *m_target_sp.lock();
}
//------------------------------------------------------------------
@@ -1860,7 +1860,7 @@ public:
const Target &
GetTarget () const
{
- return m_target;
+ return *m_target_sp.lock();
}
//------------------------------------------------------------------
@@ -3315,7 +3315,7 @@ protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
- Target & m_target; ///< The target that owns this process.
+ std::weak_ptr<Target> m_target_sp; ///< The target that owns this process.
ThreadSafeValue<lldb::StateType> m_public_state;
ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process
Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener.
Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Tue Sep 1 15:02:29 2015
@@ -33,7 +33,7 @@ namespace lldb_private
typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject) (CommandInterpreter& interpreter);
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
- typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
+ typedef lldb::ProcessSP (*ProcessCreateInstance) (lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file_path);
typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(CommandInterpreter &interpreter);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp Tue Sep 1 15:02:29 2015
@@ -121,9 +121,9 @@ class ProcessWindowsData
// 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 @@ ProcessWindows::Initialize()
//------------------------------------------------------------------------------
// 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 @@ ProcessWindows::GetImageInfoAddress()
}
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 @@ ProcessWindows::OnExitProcess(uint32_t e
// 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);
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.h Tue Sep 1 15:02:29 2015
@@ -41,7 +41,7 @@ public:
// 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 @@ public:
//------------------------------------------------------------------
// Constructors and destructors
//------------------------------------------------------------------
- ProcessWindows(lldb_private::Target& target,
+ ProcessWindows(lldb::TargetSP target_sp,
lldb_private::Listener &listener);
~ProcessWindows();
@@ -90,7 +90,7 @@ public:
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
{
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp Tue Sep 1 15:02:29 2015
@@ -104,26 +104,26 @@ ProcessWinMiniDump::Terminate()
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 @@ ProcessWinMiniDump::DoLoadCore()
return error;
}
- m_target.SetArchitecture(DetermineArchitecture());
+ GetTarget().SetArchitecture(DetermineArchitecture());
ReadModuleList();
ReadExceptionRecord();
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h Tue Sep 1 15:02:29 2015
@@ -23,7 +23,7 @@ class ProcessWinMiniDump : public lldb_p
{
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 @@ public:
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 @@ public:
~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;
Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Tue Sep 1 15:02:29 2015
@@ -57,7 +57,7 @@ ProcessElfCore::Terminate()
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 @@ ProcessElfCore::CreateInstance (Target &
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 @@ ProcessElfCore::CreateInstance (Target &
}
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::CanDebug(Target &target,
//----------------------------------------------------------------------
// 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 @@ ProcessElfCore::DoLoadCore ()
// 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 @@ ProcessElfCore::Initialize()
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;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h Tue Sep 1 15:02:29 2015
@@ -37,7 +37,7 @@ public:
// 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 @@ public:
//------------------------------------------------------------------
// 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 @@ public:
//------------------------------------------------------------------
// 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
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Sep 1 15:02:29 2015
@@ -333,22 +333,22 @@ ProcessGDBRemote::Terminate()
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::CanDebug (Target &targ
//----------------------------------------------------------------------
// 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 @@ ProcessGDBRemote::DoConnectRemote (Strea
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 @@ ProcessGDBRemote::DoLaunch (Module *exe_
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 @@ ProcessGDBRemote::DoLaunch (Module *exe_
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 @@ ProcessGDBRemote::DoLaunch (Module *exe_
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 @@ ProcessGDBRemote::StartNoticingNewThread
}
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 @@ ProcessGDBRemote::LoadModules ()
if (new_modules.GetSize() > 0)
{
- Target & target = m_target;
+ Target &target = GetTarget();
new_modules.ForEach ([&target](const lldb::ModuleSP module_sp) -> bool
{
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Tue Sep 1 15:02:29 2015
@@ -46,7 +46,7 @@ public:
// 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 @@ public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- ProcessGDBRemote(Target& target, Listener &listener);
+ ProcessGDBRemote(lldb::TargetSP target_sp, Listener &listener);
virtual
~ProcessGDBRemote();
@@ -77,7 +77,7 @@ public:
// 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;
Modified: lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp Tue Sep 1 15:02:29 2015
@@ -64,7 +64,7 @@ ProcessMachCore::Terminate()
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 @@ ProcessMachCore::CreateInstance (Target
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 @@ ProcessMachCore::CreateInstance (Target
}
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::CanDebug(Target &target
//----------------------------------------------------------------------
// 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 @@ ProcessMachCore::DoLoadCore ()
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;
}
Modified: lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.h?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.h (original)
+++ lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.h Tue Sep 1 15:02:29 2015
@@ -30,7 +30,7 @@ public:
// 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 @@ public:
//------------------------------------------------------------------
// 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 @@ public:
//------------------------------------------------------------------
// 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 @@ protected:
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 ();
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Sep 1 15:02:29 2015
@@ -648,7 +648,7 @@ ProcessInstanceInfoMatch::Clear()
}
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 @@ Process::FindPlugin (Target &target, con
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 @@ Process::FindPlugin (Target &target, con
{
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::GetStaticBroadcasterClass ()
//----------------------------------------------------------------------
// 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 @@ const lldb::ABISP &
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 @@ Process::CreateBreakpointSite (const Bre
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 @@ Process::CreateBreakpointSite (const Bre
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 @@ Process::RemoveBreakpointOpcodesFromBuff
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 @@ Process::Launch (ProcessLaunchInfo &laun
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 @@ Process::Attach (ProcessAttachInfo &atta
else
{
ProcessInstanceInfoList process_infos;
- PlatformSP platform_sp (m_target.GetPlatform ());
+ PlatformSP platform_sp (GetTarget().GetPlatform ());
if (platform_sp)
{
@@ -3614,7 +3614,7 @@ Process::CompleteAttach ()
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 @@ Process::CompleteAttach ()
// 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 @@ Process::CompleteAttach ()
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 @@ Process::CompleteAttach ()
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 @@ Process::CompleteAttach ()
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 @@ Process::CompleteAttach ()
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 @@ Process::CompleteAttach ()
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 @@ Process::GetUnixSignals ()
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 @@ Process::HandlePrivateEvent (EventSP &ev
// 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 @@ Process::ProcessEventData::SetUpdateStat
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 @@ Process::ProcessIOHandlerIsActive ()
{
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 @@ Process::PushProcessIOHandler ()
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 @@ Process::PopProcessIOHandler ()
{
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;
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=246578&r1=246577&r2=246578&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Sep 1 15:02:29 2015
@@ -203,7 +203,7 @@ const lldb::ProcessSP &
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;
}
More information about the lldb-commits
mailing list