Open philippguevorguian opened 1 month ago
debugpy afaik doesn't support attaching to a process pid.
You either need to launch the application directly for debugging or use a listen approach documented in https://github.com/microsoft/debugpy?tab=readme-ov-file#debugging-a-script-file
Not sure what you mean with toggling between processes. If you start multiple debug sessions you can switch sessions via the sessions widget.
Let me clarify, I'm launching the script directly with the configuration below, which starts two processes. I'm able to set a breakpoint at which both processes stop. However, when I step, the debugger only steps for one of the processes. I'm not sufficiently familiar with the internals here, am I able to switch between these processes using the sessions API such that I can step with the other process?
{
"version": "0.2.0",
"configurations": [
{
"name": "titan",
"type": "debugpy",
"request": "launch",
"module": "torch.distributed.run",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"--nproc_per_node",
"2",
"--rdzv_backend",
"c10d",
"--rdzv_endpoint",
"localhost:10015",
"--local-ranks-filter",
"0",
"--role",
"rank",
"--tee",
"3",
"train.py",
"--job.config_file",
"./train_configs/debug_model.toml"
],
"env": {
"CUDA_VISIBLE_DEVICES": "0,1",
"WORLD_SIZE": "2"
}
}
]
}
am I able to switch between these processes using the sessions API such that I can step with the other process?
You should be. I currently use a command like this:
local widgets = require('dap.ui.widgets')
local sessions_bar = widgets.sidebar(widgets.sessions, {}, '5 sp | setlocal winfixheight')
vim.api.nvim_create_user_command("DapSessions", sessions_bar.toggle, { nargs = 0 })
You can then run :DapSessions
and should see one session per sub-process. If you put the cursor over one of the sessions you can press <CR>
to set it as active session.
As far as I understand, nvim-dap has an API for selecting a process in a menu. I've not seen it documented here or used in debugpy configs (only found examples with JS). Is this possible to do? The launch.json I use allows me to start multiprocessing python scripts with modules and correctly represents the state of one of the processes, and I can step over / into on that process until I am sufficiently out of sync with the other process and get an error. So my question is if there is a way already implement to switch between processes or any examples of how to set this up in my nvim-dap configuration?
If this is a more appropriate question for the debugpy repo, let me know. Thanks !