【发布时间】:2019-12-18 15:55:10
【问题描述】:
我有一个 C 文件,我正在尝试调试但失败了。 我在 Windows 10 上使用 vscode。 文件比较大,这里就不复制了。
这就是我的 launch.json 文件在我正在工作的文件夹中的 .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": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc.exe build active file"
}
]
}
这就是我的 tasks.json 在同一个 .vscode 文件夹中的样子:
{
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\MinGW\\bin"
}
}
],
"version": "2.0.0"
}
当我按下“开始调试”按钮时,屏幕冻结,程序停止,然后 vscode 崩溃
【问题讨论】:
-
编译后,可执行文件是否也在其他所有文件(头文件、c文件等)所在的文件夹中?尝试“硬编码”程序的路径,例如
"program": "${workspaceFolder}/message_queue.exe"。 workspaceFolder 是我的文件夹,在 vs code 中打开,message_queue.exe 是我的 .exe 文件。 -
请尝试在没有 vs 代码的情况下运行 gdb.exe。它有效吗?
C:\mingw\bin\gdb.exe YOUR_PROGRAM_NAME.exe -
@derallbert 没有任何工作,我想我别无选择,只能下载 Visual Studio。啊啊啊好烦
标签: debugging visual-studio-code