@@ -614,9 +614,7 @@ void Process::Finalize(bool destructing) {
614
614
// contain events that have ProcessSP values in them which can keep this
615
615
// process around forever. These events need to be cleared out.
616
616
m_private_state_listener_sp->Clear ();
617
- m_public_run_lock.TrySetRunning (); // This will do nothing if already locked
618
617
m_public_run_lock.SetStopped ();
619
- m_private_run_lock.TrySetRunning (); // This will do nothing if already locked
620
618
m_private_run_lock.SetStopped ();
621
619
m_structured_data_plugin_map.clear ();
622
620
}
@@ -1466,11 +1464,11 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
1466
1464
Status Process::Resume () {
1467
1465
Log *log (GetLog (LLDBLog::State | LLDBLog::Process));
1468
1466
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 ());
1472
1470
return Status::FromErrorString (
1473
- " Resume request failed - process still running. " );
1471
+ " resume request failed - process already running" );
1474
1472
}
1475
1473
Status error = PrivateResume ();
1476
1474
if (!error.Success ()) {
@@ -1483,10 +1481,10 @@ Status Process::Resume() {
1483
1481
Status Process::ResumeSynchronous (Stream *stream) {
1484
1482
Log *log (GetLog (LLDBLog::State | LLDBLog::Process));
1485
1483
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." );
1488
1486
return Status::FromErrorString (
1489
- " Resume request failed - process still running. " );
1487
+ " resume request failed: process already running" );
1490
1488
}
1491
1489
1492
1490
ListenerSP listener_sp (
@@ -2818,13 +2816,8 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
2818
2816
SetPublicState (eStateLaunching, restarted);
2819
2817
m_should_detach = false ;
2820
2818
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);
2828
2821
2829
2822
if (error.Fail ()) {
2830
2823
if (GetID () != LLDB_INVALID_PROCESS_ID) {
@@ -3089,17 +3082,12 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
3089
3082
if (wait_for_launch) {
3090
3083
error = WillAttachToProcessWithName (process_name, wait_for_launch);
3091
3084
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);
3103
3091
3104
3092
if (error.Fail ()) {
3105
3093
if (GetID () != LLDB_INVALID_PROCESS_ID) {
@@ -3160,17 +3148,13 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
3160
3148
if (attach_pid != LLDB_INVALID_PROCESS_ID) {
3161
3149
error = WillAttachToProcessWithID (attach_pid);
3162
3150
if (error.Success ()) {
3151
+ m_public_run_lock.SetRunning ();
3163
3152
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);
3174
3158
3175
3159
if (error.Success ()) {
3176
3160
SetNextEventAction (new Process::AttachCompletionHandler (
@@ -5951,10 +5935,9 @@ void Process::ClearPreResumeAction(PreResumeActionCallback callback, void *baton
5951
5935
}
5952
5936
5953
5937
ProcessRunLock &Process::GetRunLock () {
5954
- if (m_private_state_thread. EqualsThread ( Host::GetCurrentThread () ))
5938
+ if (Process::CurrentThreadIsPrivateStateThread ( ))
5955
5939
return m_private_run_lock;
5956
- else
5957
- return m_public_run_lock;
5940
+ return m_public_run_lock;
5958
5941
}
5959
5942
5960
5943
bool Process::CurrentThreadIsPrivateStateThread ()
0 commit comments