summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-04-19 01:40:33 +0000
committerJim Ingham <jingham@apple.com>2012-04-19 01:40:33 +0000
commit3b8285d90d358d41e985e7adcb46bcce4f85e16f (patch)
tree071fcccee1406d7e1687aaaa77a806f6a2e0148b /lldb/source/Target/Process.cpp
parent11ffde3d7e866e0a97f298f44a57966ff1f1e507 (diff)
downloadbcm5719-llvm-3b8285d90d358d41e985e7adcb46bcce4f85e16f.tar.gz
bcm5719-llvm-3b8285d90d358d41e985e7adcb46bcce4f85e16f.zip
Switch to setting the write side of the run lock when we call Resume. Then make a PrivateResume that doesn't switch the run-lock state, and use that where we are resuming without changing the public resume state.
llvm-svn: 155092
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index dd283c5f736..2a02bd52d17 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1293,6 +1293,10 @@ Process::SetPublicState (StateType new_state)
log->Printf("Process::SetPublicState (%s)", StateAsCString(new_state));
const StateType old_state = m_public_state.GetValue();
m_public_state.SetValue (new_state);
+
+ // On the transition from Run to Stopped, we unlock the writer end of the
+ // run lock. The lock gets locked in Resume, which is the public API
+ // to tell the program to run.
if (!IsHijackedForEvent(eBroadcastBitStateChanged))
{
const bool old_state_is_stopped = StateIsStoppedState(old_state, false);
@@ -1305,16 +1309,26 @@ Process::SetPublicState (StateType new_state)
log->Printf("Process::SetPublicState (%s) -- unlocking run lock", StateAsCString(new_state));
m_run_lock.WriteUnlock();
}
- else
- {
- if (log)
- log->Printf("Process::SetPublicState (%s) -- locking run lock", StateAsCString(new_state));
- m_run_lock.WriteLock();
- }
}
}
}
+Error
+Process::Resume ()
+{
+ LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf("Process::Resume -- locking run lock");
+ if (!m_run_lock.WriteTryLock())
+ {
+ Error error("Resume request failed - process still running.");
+ if (log)
+ log->Printf ("Process::Resume: -- WriteTryLock failed, not resuming.");
+ return error;
+ }
+ return PrivateResume();
+}
+
StateType
Process::GetPrivateState ()
{
@@ -2495,7 +2509,7 @@ Process::AttachCompletionHandler::PerformAction (lldb::EventSP &event_sp)
if (m_exec_count > 0)
{
--m_exec_count;
- m_process->Resume();
+ m_process->PrivateResume ();
return eEventActionRetry;
}
else
@@ -2797,7 +2811,7 @@ Process::ConnectRemote (const char *remote_url)
Error
-Process::Resume ()
+Process::PrivateResume ()
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
if (log)
@@ -3096,7 +3110,7 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
if (log)
log->Printf ("Process::ShouldBroadcastEvent (%p) Restarting process from state: %s", event_ptr, StateAsCString(state));
- Resume ();
+ PrivateResume ();
}
else
{
@@ -3503,6 +3517,8 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
{
// We've been asked to continue, so do that here.
SetRestarted(true);
+ // Use the public resume method here, since this is just
+ // extending a public resume.
m_process_sp->Resume();
}
else
@@ -4042,7 +4058,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
// Do the initial resume and wait for the running event before going further.
- Error resume_error = Resume ();
+ Error resume_error = PrivateResume ();
if (!resume_error.Success())
{
errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString());
OpenPOWER on IntegriCloud