loc*_*e14 1 python breakpoints visual-studio-code vscode-settings vscode-debugger
我正在使用VSCode调试python应用程序。
我从启动调试器的地方有一个主要的python文件。我可以在此文件中放置断点,但是如果要将断点放置在主文件调用的其他文件中,则将其作为“未验证的断点”获取,调试器将忽略它们。
如何更改我的位置,launch.json以便能够在项目中的所有文件上设置断点?
这是我目前的情况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"
]
}
]
}Run Code Online (Sandbox Code Playgroud)
谢谢
这可能是“ justMyCode ”配置选项的结果,因为它默认为true。
虽然提供程序的描述是“ ...仅将调试限制为用户编写的代码。设置为False还可以启用标准库功能的调试。”但我认为它们的意思是当前站点包中的所有内容python环境不会被调试。
我想调试Django堆栈,以确定源于我代码的异常在哪里被吞没了,因此我对VSCode的调试器的启动配置进行了此操作:
{
// 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
}
]
}
Run Code Online (Sandbox Code Playgroud)
这样做之后,调试器就删除了“未验证的断点”消息,并允许我针对正在使用的虚拟环境(包含Django)调试站点程序包中的文件。
我应该注意,调试器的“断点”部分向我提示了为何未验证断点以及对启动配置进行哪些调整:
还有一点需要注意:“-noreload”参数也很重要。在使用Flask调试其他应用程序时,调试器不会在任何断点处停止,除非我将其添加到启动配置中。
| 归档时间: |
|
| 查看次数: |
640 次 |
| 最近记录: |