0
Files
src/docs/vscode_python.md
Ryan Heise 7e36b15b99 Fix local Python VSCode debugger instructions
Change-Id: I86a9b0e4d74f57cf1e20976084504cacc1883b63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2480804
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: Ryan Heise <heiserya@google.com>
Auto-Submit: Ryan Heise <heiserya@google.com>
Cr-Commit-Position: refs/heads/master@{#817967}
2020-10-16 16:55:33 +00:00

1.7 KiB
Raw Blame History

Debugging Chromium Python With The VSCode Debugger

Before You Begin

  1. Patch in this CL.
  2. Run gclient sync.

Via SSH

SSH is useful if youre modifying and debugging code on another device, such as the desktop sitting at your office desk. To do so:

  1. Set up VSCode to work with normal development by following the instructions in the Remote Visual Studio Code section here.

  2. Open the Connection Dialog of Chromes SSH plugin: open
dialog

  3. Create a new connection and set the username, hostname, port, and SSH relay server options as you normally would. Then, set SSH arguments to "-2 -L 50371:localhost:50371"

    a. You can replace 50371 with a different value, so long as it's consistent with step 7b.

  4. Open a connection, and set this window aside.

  5. In VSCode, open the code you want to set a breakpoint in, and add the following:

import debugpy

# Your code here!
debugpy.listen(50371)
print("Wait for attach...")
debugpy.wait_for_attach()
debugpy.brerakpoint()

Note: The port passed to debugpy.listen() should match the port configured in (3).

  1. Click on the Debug tab

  2. Click Run. A dialog will appear asking you to set up a debug configuration. Do so, and select “Remote Debug”.

    a. Leave the hostname as-is

    b. Set the port to 50371

  3. Run your program on the remote machine. It should stop executing at “Wait for attach”.

  4. Start the debugger in VSCode. It should attach!

Locally

Follow the same steps as above, but start from step 5.