diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-11-17 04:46:02 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-11-17 04:46:02 +0000 |
| commit | e24c4acf6cd5ecbfed993c3b598dbc2fe24ab7ab (patch) | |
| tree | dced64b42d76833da5cbbbc9da056f4c23fc57b2 /lldb/source | |
| parent | 857f9d6e5eef4efe9a9df1fd22f20210eeac5fc6 (diff) | |
| download | bcm5719-llvm-e24c4acf6cd5ecbfed993c3b598dbc2fe24ab7ab.tar.gz bcm5719-llvm-e24c4acf6cd5ecbfed993c3b598dbc2fe24ab7ab.zip | |
Fixed the issue that was causing our monitor process threads to crash, it
turned out to be unitialized data in the ProcessLaunchInfo default constructor.
Turning on MallocScribble in the environment helped track this down.
When we launch and attach using the host layer, we now inform the process that
it shouldn't detach when by calling an accessor.
llvm-svn: 144882
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Core/Debugger.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 33 |
5 files changed, 48 insertions, 4 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 6f95bd7a276..e2dd2e56bd3 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -272,7 +272,7 @@ Debugger::Clear() ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); if (process_sp) { - if (process_sp->AttachedToProcess()) + if (process_sp->GetShouldDetach()) process_sp->Detach(); else process_sp->Destroy(); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index df01e94cb14..fed40e0ff1b 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -97,6 +97,11 @@ ProcessKDP::ProcessKDP(Target& target, Listener &listener) : ProcessKDP::~ProcessKDP() { Clear(); + // We need to call finalize on the process before destroying ourselves + // to make sure all of the broadcaster cleanup goes as planned. If we + // destruct this class, then Process::~Process() might have problems + // trying to fully destroy the broadcaster. + Finalize(); } //---------------------------------------------------------------------- @@ -620,7 +625,6 @@ ProcessKDP::DisableWatchpoint (Watchpoint *wp) void ProcessKDP::Clear() { - Mutex::Locker locker (m_thread_list.GetMutex ()); m_thread_list.Clear(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 1aa3c920a08..95d452f65bb 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1171,6 +1171,9 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) { // thread in big endian hex tid = Args::StringToUInt32 (value.c_str(), 0, 16); + // m_thread_list does have its own mutex, but we need to + // hold onto the mutex between the call to m_thread_list.FindThreadByID(...) + // and the m_thread_list.AddThread(...) so it doesn't change on us Mutex::Locker locker (m_thread_list.GetMutex ()); thread_sp = m_thread_list.FindThreadByID(tid, false); if (!thread_sp) diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 3b780428836..dbd4e405809 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -581,6 +581,14 @@ Platform::DebugProcess (ProcessLaunchInfo &launch_info, { ProcessAttachInfo attach_info (launch_info); process_sp = Attach (attach_info, debugger, target, listener, error); + if (process_sp) + { + // Since we attached to the process, it will think it needs to detach + // if the process object just goes away without an explicit call to + // Process::Kill() or Process::Detach(), so let it know to kill the + // process if this happens. + process_sp->SetShouldDetach (false); + } } } return process_sp; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 3d917a6f758..d132eb2f69d 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -774,7 +774,7 @@ Process::Process(Target &target, Listener &listener) : m_stderr_data (), m_memory_cache (*this), m_allocated_memory_cache (*this), - m_attached_to_process (false), + m_should_detach (false), m_next_event_action_ap(), m_can_jit(eCanJITYes) { @@ -818,6 +818,29 @@ Process::~Process() void Process::Finalize() { + switch (GetPrivateState()) + { + case eStateConnected: + case eStateAttaching: + case eStateLaunching: + case eStateStopped: + case eStateRunning: + case eStateStepping: + case eStateCrashed: + case eStateSuspended: + if (GetShouldDetach()) + Detach(); + else + Destroy(); + break; + + case eStateInvalid: + case eStateUnloaded: + case eStateDetached: + case eStateExited: + break; + } + // Clear our broadcaster before we proceed with destroying Broadcaster::Clear(); @@ -1183,6 +1206,9 @@ Process::UpdateThreadListIfNeeded () if (StateIsStoppedState (state, true)) { Mutex::Locker locker (m_thread_list.GetMutex ()); + // m_thread_list does have its own mutex, but we need to + // hold onto the mutex between the call to UpdateThreadList(...) + // and the os->UpdateThreadList(...) so it doesn't change on us ThreadList new_thread_list(this); // Always update the thread list with the protocol specific // thread list @@ -2209,6 +2235,7 @@ Process::Launch (const ProcessLaunchInfo &launch_info) if (error.Success()) { SetPublicState (eStateLaunching); + m_should_detach = false; // Now launch using these arguments. error = DoLaunch (exe_module, launch_info); @@ -2351,6 +2378,8 @@ Process::Attach (ProcessAttachInfo &attach_info) error = WillAttachToProcessWithName(process_name, wait_for_launch); if (error.Success()) { + m_should_detach = true; + SetPublicState (eStateAttaching); error = DoAttachToProcessWithName (process_name, wait_for_launch); if (error.Fail()) @@ -2416,6 +2445,7 @@ Process::Attach (ProcessAttachInfo &attach_info) error = WillAttachToProcessWithID(attach_pid); if (error.Success()) { + m_should_detach = true; SetPublicState (eStateAttaching); error = DoAttachToProcessWithID (attach_pid); @@ -2516,7 +2546,6 @@ Process::CompleteAttach () { // Let the process subclass figure out at much as it can about the process // before we go looking for a dynamic loader plug-in. - m_attached_to_process = true; DidAttach(); // We just attached. If we have a platform, ask it for the process architecture, and if it isn't |

