DATA ANALYTICS REFERENCE DOCUMENT |
|
---|---|
Document Title: | Setting up Cygwin |
Document No.: | 1570875139 |
Author(s): | Gerhard van der Linde, Rita Raher |
Contributor(s): |
REVISION HISTORY
Revision | Details of Modification(s) | Reason for modification | Date | By |
---|---|---|---|---|
0 | Draft release | Document the setup of cygwin | 2019/10/12 10:12 | Gerhard van der Linde |
Rerun the cygwin installer(setup-x86_64.exe), located in downloads or moved to cywin folder in c:\cygwin64
Click through the installer and select gdb, you might have to use search to locate it.
Click skip to select gdb and click net to complete the installation.
The gdb.exe file will now appear in c:\cygwin64\bin folder.
No set up the debugger extension in VS Code if not already installed.
The debugger can now be configured in VS Code.
{
// 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:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc.exe build active file"
}
]
}
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "type": "shell", "label": "gcc.exe build active file", "command": "C:\\cygwin64\\bin\\gcc.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "C:\\cygwin64\\bin" }, "problemMatcher": [ "$gcc" ], "group": "build" } ] }
Right click and save the two json configuration files above into a subfolder named .vscode
.
This folder should be in the same folder where your c files that you want to debug resides.
"logging": { "engineLogging": true }
* https://github.com/microsoft/vscode-cpptools/issues/1527
So the issue is caused in gb and the extra escaped character returned on line three in the VS Code debugger window as shown below.
1: (2308) ->(gdb) 1: (2317) <-1001-gdb-set target-async on 1: (2318) ->&"\357\273\2771001-gdb-set target-async on\n" 1: (2319) ->&"Undefined command: \"\". Try \"help\".\n" 1: (2320) ->^error,msg="Undefined command: \"\". Try \"help\"." 1: (2320) ->(gdb)
As a workaround to fix this add a “gdb-with-chcp.cmd” within to your project (eg, “c:\cywin64\bin\gdp-with-chcp.cmd”):
@:: gdb-with-chcp.cmd @chcp 1257 >NUL 2>&1 && @"gdb.exe" %*
This sets the codepage for GDB and fixes the problem cause above when running the PC set to UTF-8 codepage.
Amend the current json code launching the debugger to point to the cmd file just created.
// use "PATHTO/gdb-with-chcp.cmd" as "miDebuggerPath" within "launch.json" // eg // ... "miDebuggerPath": "${workspaceFolder}/dbin/gdb-with-chcp.cmd", // ...
This resolved my gcc debugger issues.