Reputation: 1375
I'm debugging my python application using VSCode.
I have a main python file from where I start the debugger. I'm able to put breakpoints in this file, but if I want to put breakpoints in other files which are called by the main file, I get them as 'Unverified breakpoint' and the debugger ignores them.
How can I change my launch.json
so that I'm able to put breakpoints on all the files in my project?
Here's my current launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "${workspaceFolder}/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "nf.session.session"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "1",
"VAR2": "2"
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}
Thanks
Upvotes: 1
Views: 1393
Reputation: 6394
This may be a result of the "justMyCode" configuration option, as it defaults to true.
While the description from the provider is "...restricts debugging to user-written code only. Set to False to also enable debugging of standard library functions.", I think what they mean is that anything in the site-packages for the current python environment will not be debugged.
I wanted to debug the Django stack to determine where an exception originating in my code was being eaten-up and not surfaced, so I did this to my VSCode's debugger's launch configuration:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Control Center",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload"
],
"justMyCode": false, // I want to debug through Django framework code sometimes
"django": true
}
]
}
As soon as I did that, the debugger removed the "Unverified breakpoint" message and allowed me to debug files in the site-packages for the virtual environment I was working on, which contained Django.
I should note that the Breakpoint section of the debugger gave me a hint as to why the breakpoint was unverified and what tweaks to make to the launch config:
One additional note: that "--noreload" argument is also important. In debugging a different application using Flask, the debugger wouldn't stop at any breakpoint until I added it to the launch config.
Upvotes: 5
Reputation: 1375
The imports for the other modules were inside strings and called using the execute
function. That's why VSCode couldn't very the breakpoints in the other files as it didn't know that these other files are used by the main file..
Upvotes: 1