https://github.com/kusmour updated https://github.com/llvm/llvm-project/pull/134339
>From 12de149a1d2067e1d942cddfcc8576fb6fe7cee5 Mon Sep 17 00:00:00 2001 From: Wanyi Ye <wa...@meta.com> Date: Thu, 3 Apr 2025 22:29:13 -0700 Subject: [PATCH] [lldb] Make SBProcess thread related actions listen to StopLocker --- lldb/source/API/SBProcess.cpp | 20 ++++++++++--------- .../tools/lldb-dap/attach/TestDAP_attach.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 23ea449b30cca..ba77b2beed5ea 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -193,10 +193,11 @@ uint32_t SBProcess::GetNumThreads() { if (process_sp) { Process::StopLocker stop_locker; - const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - std::lock_guard<std::recursive_mutex> guard( - process_sp->GetTarget().GetAPIMutex()); - num_threads = process_sp->GetThreadList().GetSize(can_update); + if (stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + num_threads = process_sp->GetThreadList().GetSize(); + } } return num_threads; @@ -393,11 +394,12 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) { ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; - const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - std::lock_guard<std::recursive_mutex> guard( - process_sp->GetTarget().GetAPIMutex()); - thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); - sb_thread.SetThread(thread_sp); + if (stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, false); + sb_thread.SetThread(thread_sp); + } } return sb_thread; diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index 9df44cc454d5d..b9fbf2c8d14f9 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -1,5 +1,5 @@ """ -Test lldb-dap setBreakpoints request +Test lldb-dap attach request """ _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits