首页 > 解决方案 > 如何在已编译的可执行文件中调试 vscode?

问题描述

尝试在 vscode 中调试时,vscode 会生成launch.json配置文件。当我尝试调试时,它首先尝试编译源代码,然后调试 exe。我只想调试已经编译的可执行文件(使用gcc -g选项编译)。

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": "gcc-10 - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [
                "-pthread",
                "common.c"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc-10 build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

我能否以某种方式使 vsode编译,而只是使用已编译的源代码进行调试"program":"${fileDirname}/${fileBasenameNoExtension}",我已经编译为相同的名称 - 当前目录中没有扩展名,正如属性所建议的那样。那么如何让vscode把这个可执行文件作为它的调试文件呢?

标签: cjsonvisual-studio-codevscode-debugger

解决方案


推荐阅读