【问题标题】:How can I run my debugger commands while the program is running?如何在程序运行时运行调试器命令?
【发布时间】:2020-03-27 23:32:42
【问题描述】:

我已经配置了我的launch.jsontasks.json,然后返回到我的file.c 并点击绿色箭头。

我看到了“附加图片”。单击“确定”以允许访问,然后我只剩下我的调试器,但不存在任何变量,我的 step_intostep_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"
        }
    ]
}

tasks.json:

{
    // 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 的 Frond End Dev TechDegree 以来,我一直在使用 VS Code :) 那个标签有效吗?它不会突出显示您的名字
  • Stack Overflow 没有突出显示名称,但我确实收到了通知。不过,显然你的问题已经解决了。点击灰色复选标记,确保接受对您有帮助的答案。

标签: c debugging visual-studio-code


【解决方案1】:

看起来代码没有“暂停”,所以在代码运行时调试器不会激活。尝试设置断点,看看是否能解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多