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

Greg Clayton via All-commits all-commits at lists.llvm.org
Thu Mar 3 16:20:44 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 63e512100ac62efd5f009c6b490194e973a9d1ce
      https://github.com/llvm/llvm-project/commit/63e512100ac62efd5f009c6b490194e973a9d1ce
  Author: Greg Clayton <gclayton at fb.com>
  Date:   2022-03-03 (Thu, 03 Mar 2022)

  Changed paths:
    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.

This is a modified version of a previous patch that was reverted: https://reviews.llvm.org/D119797
This version only waits for the process to stop when using "launchCommands" or "attachCommands"...

...and doesn't play with the async mode when doing normal launch/attach.

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 "launchCommands" or "attachCommands" are run to ensure that we have a stopped process point that is ready for the debug session to proceed. We spin up the thread that listens for process events before we start the launch or attach, but we don't want stop events being delivered through the DAP protocol until the "configurationDone" packet is received. We now always ignore the stop event with a stop ID of 1, which is the first stop. All normal launch and attach scenarios use the synchronous mode, and "launchCommands and "attachCommands" run an array of LLDB commands in async mode.

This should make our launch with "launchCommands" and attach with "attachCommands" avoid a race condition when the process is being launched or attached.

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




More information about the All-commits mailing list