diff options
| -rw-r--r-- | lldb/include/lldb/Core/State.h | 36 | ||||
| -rw-r--r-- | lldb/source/API/SBDebugger.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Core/State.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/macosx/Host.mm | 13 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 32 |
7 files changed, 69 insertions, 25 deletions
diff --git a/lldb/include/lldb/Core/State.h b/lldb/include/lldb/Core/State.h index 3e667c2a6e7..8057b3e0584 100644 --- a/lldb/include/lldb/Core/State.h +++ b/lldb/include/lldb/Core/State.h @@ -32,12 +32,44 @@ namespace lldb_private { const char * StateAsCString (lldb::StateType state); +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is running. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is running, \b false otherwise. +//------------------------------------------------------------------ bool StateIsRunningState (lldb::StateType state); +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is stopped. Stopped can mean stopped when the process is still +/// around, or stopped when the process has exited or doesn't exist +/// yet. The \a must_exist argument tells us which of these cases is +/// desired. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @param[in] must_exist +/// A boolean that indicates the thread must also be alive +/// so states like unloaded or exited won't return true. +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is stopped. If \a must_exist is +/// \b true, then the process can't be exited or unloaded, +/// otherwise exited and unloaded or other states where the +/// process no longer exists are considered to be stopped. +//------------------------------------------------------------------ bool -StateIsStoppedState (lldb::StateType state); - +StateIsStoppedState (lldb::StateType state, bool must_exist); + const char * GetPermissionsAsCString (uint32_t permissions); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index b15bc3d7611..b8be227f557 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -452,7 +452,7 @@ SBDebugger::StateIsStoppedState (StateType state) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const bool result = lldb_private::StateIsStoppedState (state); + const bool result = lldb_private::StateIsStoppedState (state, false); if (log) log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i", StateAsCString (state), result); diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index e048182d04b..d618c04633b 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -284,7 +284,8 @@ public: if (synchronous_execution) { state = process->WaitForProcessToStop (NULL); - if (!StateIsStoppedState(state)) + const bool must_be_alive = true; + if (!StateIsStoppedState(state, must_be_alive)) { result.AppendErrorWithFormat ("process isn't stopped: %s", StateAsCString(state)); } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 3ee3ab85c8c..bbbca5e921f 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -82,7 +82,7 @@ DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bo lldb::pid_t pid = process_sp->GetID(); StateType state = process_sp->GetState(); if (show_stopped_process_status) - show_process_status = StateIsStoppedState(state); + show_process_status = StateIsStoppedState(state, true); const char *state_cstr = StateAsCString (state); if (pid != LLDB_INVALID_PROCESS_ID) strm.Printf ("%spid=%i", properties++ > 0 ? ", " : " ( ", pid); diff --git a/lldb/source/Core/State.cpp b/lldb/source/Core/State.cpp index 8cb748ff67f..c660477f1c4 100644 --- a/lldb/source/Core/State.cpp +++ b/lldb/source/Core/State.cpp @@ -90,7 +90,7 @@ lldb_private::StateIsRunningState (StateType state) } bool -lldb_private::StateIsStoppedState (StateType state) +lldb_private::StateIsStoppedState (StateType state, bool must_exist) { switch (state) { @@ -105,9 +105,11 @@ lldb_private::StateIsStoppedState (StateType state) break; case eStateUnloaded: + case eStateExited: + return !must_exist; + case eStateStopped: case eStateCrashed: - case eStateExited: case eStateSuspended: return true; } diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 7a84bdec557..db5c8e26ceb 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -68,6 +68,9 @@ extern "C" using namespace lldb; using namespace lldb_private; +static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; +static pthread_key_t g_thread_create_key = 0; + class MacOSXDarwinThread { public: @@ -98,12 +101,17 @@ public: ~MacOSXDarwinThread() { if (m_pool) + { [m_pool release]; + m_pool = nil; + } } static void PThreadDestructor (void *v) { - delete (MacOSXDarwinThread*)v; + if (v) + delete static_cast<MacOSXDarwinThread*>(v); + ::pthread_setspecific (g_thread_create_key, NULL); } protected: @@ -112,9 +120,6 @@ private: DISALLOW_COPY_AND_ASSIGN (MacOSXDarwinThread); }; -static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; -static pthread_key_t g_thread_create_key = 0; - static void InitThreadCreated() { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index ff5d7182468..3d917a6f758 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1179,16 +1179,20 @@ Process::UpdateThreadListIfNeeded () const uint32_t stop_id = GetStopID(); if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID()) { - Mutex::Locker locker (m_thread_list.GetMutex ()); - ThreadList new_thread_list(this); - // Always update the thread list with the protocol specific - // thread list - UpdateThreadList (m_thread_list, new_thread_list); - OperatingSystem *os = GetOperatingSystem (); - if (os) - os->UpdateThreadList (m_thread_list, new_thread_list); - m_thread_list.Update (new_thread_list); - m_thread_list.SetStopID (stop_id); + const StateType state = GetPrivateState(); + if (StateIsStoppedState (state, true)) + { + Mutex::Locker locker (m_thread_list.GetMutex ()); + ThreadList new_thread_list(this); + // Always update the thread list with the protocol specific + // thread list + UpdateThreadList (m_thread_list, new_thread_list); + OperatingSystem *os = GetOperatingSystem (); + if (os) + os->UpdateThreadList (m_thread_list, new_thread_list); + m_thread_list.Update (new_thread_list); + m_thread_list.SetStopID (stop_id); + } } } @@ -1236,7 +1240,7 @@ Process::SetPrivateState (StateType new_state) if (state_changed) { m_private_state.SetValueNoLock (new_state); - if (StateIsStoppedState(new_state)) + if (StateIsStoppedState(new_state, false)) { m_mod_id.BumpStopID(); m_memory_cache.Clear(); @@ -2167,7 +2171,7 @@ Process::WaitForProcessStopPrivate (const TimeValue *timeout, EventSP &event_sp) event_sp.reset(); state = WaitForStateChangedEventsPrivate (timeout, event_sp); - if (StateIsStoppedState(state)) + if (StateIsStoppedState(state, false)) break; // If state is invalid, then we timed out @@ -2683,7 +2687,7 @@ Process::Halt () } else { - if (StateIsStoppedState (state)) + if (StateIsStoppedState (state, false)) { // We caused the process to interrupt itself, so mark this // as such in the stop event so clients can tell an interrupted @@ -4247,7 +4251,7 @@ void Process::GetStatus (Stream &strm) { const StateType state = GetState(); - if (StateIsStoppedState(state)) + if (StateIsStoppedState(state, false)) { if (state == eStateExited) { |

