C 程序运行时,如何运行调试器命令?

C 程序运行时,如何运行调试器命令?,c,debugging,visual-studio-code,C,Debugging,Visual Studio Code,我已经配置了我的launch.json和tasks.json,然后返回到我的文件.c并单击绿色箭头 我看到“附加图像”。单击“确定”以允许访问,然后我就可以使用我的调试器了,但不存在任何变量,我的选项(如step\u into,step\u over)消失,然后我发现自己也在同一个循环中 下面是启动和任务的JSON launch.json: { // Use IntelliSense to learn about possible attributes. // Hover to

我已经配置了我的
launch.json
tasks.json
,然后返回到我的
文件.c
并单击绿色箭头

我看到“附加图像”。单击“确定”以允许访问,然后我就可以使用我的调试器了,但不存在任何变量,我的选项(如
step\u into
step\u over
)消失,然后我发现自己也在同一个循环中

下面是启动和任务的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": "clang - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "preLaunchTask": "clang build active file"
        }
    ]
}
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                "/property:GenerateFullPaths=true",
                "/t:build",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "type": "shell",
            "label": "clang build active file",
            "command": "/usr/bin/clang",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}
tasks.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": "clang - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "preLaunchTask": "clang build active file"
        }
    ]
}
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                "/property:GenerateFullPaths=true",
                "/t:build",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "type": "shell",
            "label": "clang build active file",
            "command": "/usr/bin/clang",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

代码似乎没有“暂停”,因此在代码处于活动运行状态时,调试器将不会激活。尝试设置一个断点,看看是否可以解决问题。

如果可以,我会使用GDB。在我看来,它比VSCode更容易使用。@s.s.Anne感谢您的回复,我是C和StackOverflow的新手,自去年12月完成TeamTreeHouse前端开发TechDegree以来,我一直在使用VS Code:)该标记有效吗?它不会突出显示您的nameStack溢出不会突出显示名称,但我确实收到了通知。显然你的问题已经解决了。通过单击灰色复选标记,确保接受帮助您的答案。