I am having trouble getting the F5 debugger to work properly.
I have been trying to follow the Microsoft tutorial to get things going, but after building successfully the debugging process never really works out the way it should.
When I use the Ctrl + Shift + B command to build, it successfully creates a main.exe file, but I cannot change the launch.json file in a way that works hand-in-hand.
While tasks.json has this
"-o","${fileDirname}\\${fileBasenameNoExtension}.exe" as the object path/name, 'main.cpp' is compiled into main.exe.
So, initially, I had tried to set launch.json to have program": ${fileDirname}\\${fileBasenameNoExtension}.exe. Which would be neat and effective, matching the build file that would be produced.
Next, I tried to change launch.json to run as a.exe hardcoded. In the PS terminal within VSCode, I ran g++ .\main.cpp and produced an a.exe file. Which successfully allows F5 debugging giving me an exit code '0' in the debug console when I changed launch.json to have "program": "${workspaceFolder}\\a.exe".
I have also tried to use ${workspaceFolder}\\${fileBasenameNoExtension}.exe with no luck.
It makes no logical sense to me that the same parameters for cwd with the same object name in tasks won't run successfully for debugging in launch.
The entire tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cpp.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\cpp.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\\msys64\\mingw64\\bin\\cpp.exe"
}
]
}
The entire launch.json:
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
Could someone please take a look for me? This is infuriating.. Thanks in advance!
