c - Visual Studio 代码 - 调试停止工作 [gdb, mingw, windows 10]
问题描述
我搜索了一个星期的解决方案,但如果不在这里发布就无法解决这个问题。
我在 Vs 代码中用 C 编写代码,到目前为止(在笔记本电脑上)我没有任何问题。前几天调试突然停止工作;这是怎么回事:简单的代码,如:
#include <stdio.h>
int main(){
int x;
x=1;
x*=10;
printf("\ntest %d",x);
}
我按下绿色箭头播放按钮来运行它。我编译和构建很好(根据task.json),但是没有命中断点,并且“printf”在集成终端中也没有得到任何结果。“调试控制台”也没有显示
这是我的 task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe compile active file",
"command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"isDefault": true,
"kind": "build",
},
"detail": "compiler: C:\\msys64\\mingw64\\bin\\gcc.exe"
}
]
}
和我的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": "gcc.exe - Compile and run debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Abilita la riformattazione per gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe compile active file"
}
]
}
我还尝试并重新安装了所有 Vs 代码、C/C++ Intellisense、扩展运行代码,未安装 mingw 并按照“https://code.visualstudio.com/docs/cpp/config-mingw”中的步骤重新安装它. 但是“缺少调试”的行为仍然存在。
另一方面,如果我通过简单地键入“.\test.exe”在集成终端(powewrshell)中手动运行 test.exe,它工作正常。
有什么想法吗,谢谢
解决方案
olyBlackCat 在评论中给出了接受的答案,我在这里引用它以将其标记为接受的答案:
我看到很多这样的问题。也许试试这个扩展而不是默认的 C++ 扩展?它适用于我在 Linux 上。– HolyBlackCat 8 月 16 日 17:28
找到错误报告。github.com/microsoft/vscode-cpptools/issues/7971有一些建议
推荐阅读
- android - 一个Activity的Adapter和另一个Activity的通信
- javascript - 根据给定的百分比执行功能
- python - 在 PyQT 应用程序中使用 distancewidget 渲染 vtk
- ruby - 用 ruby 数组中的值替换字符串中的模式
- sql - 选择不同的值
- php - jQuery中的PHP连接$ i
- sql - 如何根据sql中的其他列创建列?
- c# - 在asp.net c#中将数据表转换为具有15k条记录的xml
- python - 如果项目打包到 .exe 中,pywin32 无法调试
- firebase - Firebase 远程配置:未捕获的类型错误:firebase.remoteConfig 不是函数