VS Code 中多个文件中的断点? [英] Breakpoints in multiple files in VS Code?

查看:20
本文介绍了VS Code 中多个文件中的断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个文件/模块的 Python 项目,我正在尝试调试.我安装了

如果您不想调试其他模块或做其他事情,您可以创建不同的配置.

I have a Python project with multiple files/modules, that I'm trying to debug. I have the Python extension installed, and I put a bunch of breakpoints in - some in the current file and some in another file/module. Breakpoints in the current file are working fine, however, the breakpoints in other file(s) are not. Is there a step I'm missing in setting the debugger up? Couldn't find anything on Google for this specific problem, the tutorials only show debugging in one file and that is working fine. If I try to right click and go to the definition of any function in another module, that also works fine so the project is aware of the multiple modules (I have the whole directory open in VS Code), the breakpoints don't.

解决方案

Ran into the same issue. In case you still need to know, this is how I resolved it.

  1. Create a workspace in vscode
  2. Add the folders you want into the workspace with all the files you need. We need to do this to create the launch.json file
  3. Click on the Debug Icon or Ctrl+Shift+D
  4. Click the gear icon in the debug sidebar at the top. It will say open launch.json
  5. If one is not created, it will automatically create it for and it should look like:

{
    // 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}",
            "console": "integratedTerminal"
        }
    ]
}

  1. Add in justMyCode, but set to false

{
    // 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}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

  1. Save and start debugging. You should be able to step into other modules now.

A screenshot of what the debug screen configuration should now look like:

You can create different configs if you don't want to debug other modules or do things as well.

这篇关于VS Code 中多个文件中的断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆