Skip to content

Commit 2f8dc76

Browse files
committed
[lldb] Make SBProcess thread related actions listen to StopLocker
1 parent 747d4a9 commit 2f8dc76

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lldb/source/API/SBProcess.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,11 @@ uint32_t SBProcess::GetNumThreads() {
193193
if (process_sp) {
194194
Process::StopLocker stop_locker;
195195

196-
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
197-
std::lock_guard<std::recursive_mutex> guard(
198-
process_sp->GetTarget().GetAPIMutex());
199-
num_threads = process_sp->GetThreadList().GetSize(can_update);
196+
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
197+
std::lock_guard<std::recursive_mutex> guard(
198+
process_sp->GetTarget().GetAPIMutex());
199+
num_threads = process_sp->GetThreadList().GetSize();
200+
}
200201
}
201202

202203
return num_threads;
@@ -393,11 +394,12 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) {
393394
ProcessSP process_sp(GetSP());
394395
if (process_sp) {
395396
Process::StopLocker stop_locker;
396-
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
397-
std::lock_guard<std::recursive_mutex> guard(
398-
process_sp->GetTarget().GetAPIMutex());
399-
thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
400-
sb_thread.SetThread(thread_sp);
397+
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
398+
std::lock_guard<std::recursive_mutex> guard(
399+
process_sp->GetTarget().GetAPIMutex());
400+
thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, false);
401+
sb_thread.SetThread(thread_sp);
402+
}
401403
}
402404

403405
return sb_thread;

lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Test lldb-dap setBreakpoints request
2+
Test lldb-dap attach request
33
"""
44

55

0 commit comments

Comments
 (0)