blob: 47c973bf8f6e82b52f80964ac8e0021a0c73d9f7 [file] [log] [blame] [view]
Ryan Heise9a711432020-10-14 23:55:391# Debugging Chromium Python With The VSCode Debugger
2
3## Before You Begin
4
51. Patch in [this CL](https://chromium-review.googlesource.com/c/chromium/src/+/2466896).
62. Run gclient sync.
7
8## Via SSH
9
10SSH is useful if youre modifying and debugging code on another device, such as
11the desktop sitting at your office desk. To do so:
12
131. Set up VSCode to work with normal development by following the instructions
14 in the Remote Visual Studio Code section
15 [here](https://docs.google.com/document/d/1ZlG8VQxudxvDs-EtpQvaPVcAPfSMdYlXr42s_487wLo/edit#bookmark=id.j10hyv6nlkws).
162. Open the Connection Dialog of Chromes SSH plugin: ![open
17 dialog](images/vscode_python_connection_dialog.png)
183. Create a new connection and set the username, hostname, port, and SSH relay
19 server options as you normally would. Then, set SSH arguments to "-2 -L
20 50371:localhost:50371"
21
22 a. You can replace 50371 with a different value, so long as it's consistent
23 with step 7b.
24
254. Open a connection, and set this window aside.
265. In VSCode, open the code you want to set a breakpoint in, and add the
27 following:
28
29```
30import debugpy
31
32# Your code here!
33debugpy.listen(50371)
34print("Wait for attach...")
35debugpy.wait_for_attach()
36debugpy.brerakpoint()
37```
38
39Note: The port passed to debugpy.listen() should match the port configured in (3).
40
416. Click on the Debug tab
427. Click Run. A dialog will appear asking you to set up a debug configuration.
43 Do so, and select “Remote Debug”.
44
45 a. Leave the hostname as-is
46
47 b. Set the port to 50371
48
498. Run your program on the remote machine. It should stop executing at “Wait for
50 attach”.
519. Start the debugger in VSCode. It should attach!
52
53## Locally
54
Ryan Heise7e36b152020-10-16 16:55:3355Follow the same steps as above, but start from step 5.