@@ -614,9 +614,7 @@ void Process::Finalize(bool destructing) {
614614 // contain events that have ProcessSP values in them which can keep this
615615 // process around forever. These events need to be cleared out.
616616 m_private_state_listener_sp->Clear ();
617- m_public_run_lock.TrySetRunning (); // This will do nothing if already locked
618617 m_public_run_lock.SetStopped ();
619- m_private_run_lock.TrySetRunning (); // This will do nothing if already locked
620618 m_private_run_lock.SetStopped ();
621619 m_structured_data_plugin_map.clear ();
622620}
@@ -1466,11 +1464,11 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
14661464Status Process::Resume () {
14671465 Log *log (GetLog (LLDBLog::State | LLDBLog::Process));
14681466 LLDB_LOGF (log, " (plugin = %s) -- locking run lock" , GetPluginName ().data ());
1469- if (!m_public_run_lock.TrySetRunning ()) {
1470- LLDB_LOGF (log, " (plugin = %s) -- TrySetRunning failed, not resuming." ,
1471- GetPluginName ().data ());
1467+ if (!m_public_run_lock.SetRunning ()) {
1468+ LLDB_LOGF (log, " (plugin = %s) -- SetRunning failed, not resuming." ,
1469+ GetPluginName ().data ());
14721470 return Status::FromErrorString (
1473- " Resume request failed - process still running. " );
1471+ " resume request failed - process already running" );
14741472 }
14751473 Status error = PrivateResume ();
14761474 if (!error.Success ()) {
@@ -1483,10 +1481,10 @@ Status Process::Resume() {
14831481Status Process::ResumeSynchronous (Stream *stream) {
14841482 Log *log (GetLog (LLDBLog::State | LLDBLog::Process));
14851483 LLDB_LOGF (log, " Process::ResumeSynchronous -- locking run lock" );
1486- if (!m_public_run_lock.TrySetRunning ()) {
1487- LLDB_LOGF (log, " Process::Resume: -- TrySetRunning failed, not resuming." );
1484+ if (!m_public_run_lock.SetRunning ()) {
1485+ LLDB_LOGF (log, " Process::Resume: -- SetRunning failed, not resuming." );
14881486 return Status::FromErrorString (
1489- " Resume request failed - process still running. " );
1487+ " resume request failed: process already running" );
14901488 }
14911489
14921490 ListenerSP listener_sp (
@@ -2818,13 +2816,8 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
28182816 SetPublicState (eStateLaunching, restarted);
28192817 m_should_detach = false ;
28202818
2821- if (m_public_run_lock.TrySetRunning ()) {
2822- // Now launch using these arguments.
2823- error = DoLaunch (exe_module, launch_info);
2824- } else {
2825- // This shouldn't happen
2826- error = Status::FromErrorString (" failed to acquire process run lock" );
2827- }
2819+ m_public_run_lock.SetRunning ();
2820+ error = DoLaunch (exe_module, launch_info);
28282821
28292822 if (error.Fail ()) {
28302823 if (GetID () != LLDB_INVALID_PROCESS_ID) {
@@ -3089,17 +3082,12 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
30893082 if (wait_for_launch) {
30903083 error = WillAttachToProcessWithName (process_name, wait_for_launch);
30913084 if (error.Success ()) {
3092- if (m_public_run_lock.TrySetRunning ()) {
3093- m_should_detach = true ;
3094- const bool restarted = false ;
3095- SetPublicState (eStateAttaching, restarted);
3096- // Now attach using these arguments.
3097- error = DoAttachToProcessWithName (process_name, attach_info);
3098- } else {
3099- // This shouldn't happen
3100- error =
3101- Status::FromErrorString (" failed to acquire process run lock" );
3102- }
3085+ m_public_run_lock.SetRunning ();
3086+ m_should_detach = true ;
3087+ const bool restarted = false ;
3088+ SetPublicState (eStateAttaching, restarted);
3089+ // Now attach using these arguments.
3090+ error = DoAttachToProcessWithName (process_name, attach_info);
31033091
31043092 if (error.Fail ()) {
31053093 if (GetID () != LLDB_INVALID_PROCESS_ID) {
@@ -3160,17 +3148,13 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
31603148 if (attach_pid != LLDB_INVALID_PROCESS_ID) {
31613149 error = WillAttachToProcessWithID (attach_pid);
31623150 if (error.Success ()) {
3151+ m_public_run_lock.SetRunning ();
31633152
3164- if (m_public_run_lock.TrySetRunning ()) {
3165- // Now attach using these arguments.
3166- m_should_detach = true ;
3167- const bool restarted = false ;
3168- SetPublicState (eStateAttaching, restarted);
3169- error = DoAttachToProcessWithID (attach_pid, attach_info);
3170- } else {
3171- // This shouldn't happen
3172- error = Status::FromErrorString (" failed to acquire process run lock" );
3173- }
3153+ // Now attach using these arguments.
3154+ m_should_detach = true ;
3155+ const bool restarted = false ;
3156+ SetPublicState (eStateAttaching, restarted);
3157+ error = DoAttachToProcessWithID (attach_pid, attach_info);
31743158
31753159 if (error.Success ()) {
31763160 SetNextEventAction (new Process::AttachCompletionHandler (
@@ -5951,10 +5935,9 @@ void Process::ClearPreResumeAction(PreResumeActionCallback callback, void *baton
59515935}
59525936
59535937ProcessRunLock &Process::GetRunLock () {
5954- if (m_private_state_thread. EqualsThread ( Host::GetCurrentThread () ))
5938+ if (Process::CurrentThreadIsPrivateStateThread ( ))
59555939 return m_private_run_lock;
5956- else
5957- return m_public_run_lock;
5940+ return m_public_run_lock;
59585941}
59595942
59605943bool Process::CurrentThreadIsPrivateStateThread ()
0 commit comments