Reputation: 21
I am trying to run a debugger in VS Code but every time I hit a breakpoint instead source file I am presented with a source file in a path that repeats to times, see blow: Source file + path, Source file it tries to open during debug
As you can see on the second image the path to the source file debugger is trying to open is:
C:\Users\user\Documents\AdvancedC\S2\C\Users\user\Documents\AdvancedC\S2\main.c
and of course, it doesn't exist.
converting the undefined symbol after C to ascii I get that = "";
tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
lanch.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}/main.exe",
"args": [],
"logging": {
"moduleLoad": false,
"trace": true
},
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/cygwin64/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
}
]
}
]
}
Upvotes: 2
Views: 410
Reputation: 60
I had the same issue as you, and probably have a similar setup (I also use gcc and gdb from Cygwin). After some research and trial-and-error, I was able to get debugging working by using a different configuration, as explained here: https://stackoverflow.com/a/69684819/17376152
However, I slightly modified my configuration files.
"gcc.exe build active file"
instead of "C/C++: ..."
at the beginning."environment": [],
With these changes, my debug process is now working without errors just by pressing F5.
I hope this helps you as well (I see you have the flag -gdb-set disassembly-flavor intel
set, so this might be slightly different).
Let me know if it works for you.
Upvotes: 1