由于须要在Windows下调试一个基于C语言的开源工具,调试环境为VS Code、Microsoft C/C++ Extension、GCC和GDB环境(Mingw-w64)。json
按照VS Code官方文档Using Mingw-w64 in VS Code一步一步搭建好调试环境,编译很顺利经过了。async
可是调试的时候出问题了。在VS Code中按F5启动Debug,VS的终端(Terminal)中输出了一段命令:c:\Users\efrey\.vscode\extensions\ms-vscode.cpptools-0.25.0\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-gkkeppw1.hde --stdout=Microsoft-MIEngine-Out-frcxsnxq.e4y --stderr=Microsoft-MIEngine-Error-htrolgld.kn1 --pid=Microsoft-MIEngine-Pid-mjgquuhh.yua --dbgExe=C:/mingw-w64/mingw64/bin/gdb.exe --interpreter=mi
,而后就一直停在那里了,VS Code的Debug视图左上角也一直在显示正在加载的滚动进度条。
此时除了终端窗口(Terminal)无响应,输出(Output)、调试控制台(Debug Console)也没有任何信息。工具
停掉调试器,在VS Code中配置开启日志,即将"logging": { "engineLogging": true },
加入到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": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "C:/mingw-w64/mingw64/bin/gdb.exe", "logging": { "engineLogging": true }, "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
重启按下F5启动调试,终端窗口仍是和以前同样,停在那里。不过在调试控制台里能够看到调试启动的日志了,发现其中有一段提示错误的信息:"\357\273\2771001-gdb-set target-async on
,Undefined command: \"\357\"
。spa
DEBUG CONSOLE 1: (119) LaunchOptions MIMode='gdb' 1: (119) LaunchOptions MIDebuggerPath='C:/mingw-w64/mingw64/bin/gdb.exe' ... 1: (496) ->(gdb) 1: (500) <-1001-gdb-set target-async on 1: (500) ->&"\357\273\2771001-gdb-set target-async on\n" 1: (500) ->&"Undefined command: \"\357\". Try \"help\".\n" 1: (500) ->^error,msg="Undefined command: \"\357\". Try \"help\"." ...
未定义的命令中的357看起来像是Unicode字符集的格式,致使了gdb没法识别所以报错。想起了本身好像在更改系统区域设置中开启了一个测试版的Unicode UTF8的特性支持。debug
在控制面板
中依次进入时钟和区域
>区域
,点击更改位置
,而后切换到管理
页,进入更改系统区域设置
,而后取消勾选Beta版:使用Unicode UTF8提供全球语言支持(U)
复选框。
重启电脑后,打开VS Code,按下F5,调试器正常的运行并停在源文件的断点位置了。调试