[all-commits] [llvm/llvm-project] 9febd1: Fix race condition when launching and attaching.

Greg Clayton via All-commits all-commits at lists.llvm.org
Thu Feb 17 13:19:06 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9febd1e573fb8b3d1de5844b7bfd33eb998f0106
      https://github.com/llvm/llvm-project/commit/9febd1e573fb8b3d1de5844b7bfd33eb998f0106
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2022-02-17 (Thu, 17 Feb 2022)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
    M lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
    M lldb/tools/lldb-vscode/VSCode.cpp
    M lldb/tools/lldb-vscode/VSCode.h
    M lldb/tools/lldb-vscode/lldb-vscode.cpp
    M lldb/tools/lldb-vscode/package.json

  Log Message:
  -----------
  Fix race condition when launching and attaching.

We discovered that when using "launchCommands" or "attachCommands" that there was an issue where these commands were not being run synchronously. There were further problems in this case where we would get thread events for the process that was just launched or attached before the IDE was ready, which is after "configurationDone" was sent to lldb-vscode.

This fix introduces the ability to wait for the process to stop after the run or attach to ensure that we have a stopped process at the entry point that is ready for the debug session to proceed. This also allows us to run the normal launch or attach without needing to play with the async flag the debugger. We spin up the thread that listens for process events before we start the launch or attach, but we stop the first eStateStopped (with stop ID of zero) event from being delivered through the DAP protocol because the "configurationDone" request handler will deliver it manually as the IDE expects a stop after configuration done. The request_configurationDone will also only deliver the stop packet if the "stopOnEntry" is False in the launch configuration.

Also added a new "timeout" to the launch and attach launch configuration arguments that can be set and defaults to 30 seconds. Since we now poll to detect when the process is stopped, we need a timeout that can be changed in case certain workflows take longer that 30 seconds to attach. If the process is not stopped by the timeout, an error will be retured for the launch or attach.

Added a flag to the vscode.py protocol classes that detects and ensures that no "stopped" events are sent prior to "configurationDone" has been sent and will raise an error if it does happen.

This should make our launching and attaching more reliable and avoid some deadlocks that were being seen (https://reviews.llvm.org/D119548).

Differential Revision: https://reviews.llvm.org/D119797




More information about the All-commits mailing list