[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 11 10:08:54 PDT 2025


================
@@ -50,16 +50,22 @@ namespace lldb_dap {
 // }
 void ThreadsRequestHandler::operator()(
     const llvm::json::Object &request) const {
-  lldb::SBProcess process = dap.target.GetProcess();
   llvm::json::Object response;
   FillResponse(request, response);
 
-  const uint32_t num_threads = process.GetNumThreads();
   llvm::json::Array threads;
-  for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) {
-    lldb::SBThread thread = process.GetThreadAtIndex(thread_idx);
-    threads.emplace_back(CreateThread(thread, dap.thread_format));
-  }
+  // Client requests the baseline of currently existing threads after
+  // a successful launch or attach by sending a 'threads' request
+  // right after receiving the configurationDone response.
+  // If no thread has reported to the client, it prevents something
+  // like the pause request from working in the running state.
+  // Return the cache of initial threads as the process might have resumed
+  if (dap.initial_thread_list) {
+    threads = dap.initial_thread_list.value();
+    dap.initial_thread_list.reset();
+  } else
+    threads = GetThreads(dap.target.GetProcess(), dap.thread_format);
----------------
JDevlieghere wrote:

The no-braces rule doesn't apply if the other block has braces:
```suggestion
  } else {
    threads = GetThreads(dap.target.GetProcess(), dap.thread_format);
  }
```

https://github.com/llvm/llvm-project/pull/134339


More information about the lldb-commits mailing list