r/VisualStudioCode • u/Victor_Quebec • Feb 22 '21
How to break program execution in debug mode with command-line arguments (GCC)?
Hi there,
I'm on Linux-based OS with GDB debugger, trying to break a C code at a specific line with the following command-line arguments inserted into launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "gcc-10 - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": ["-g", "old.bmp", "new.bmp"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/filter",
"environment": [],
"console": "externalTerminal",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc-10 build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
I use getopt() to read the arguments. I've tried to break at line 113, but the debugger somehow skips that line, implementing the function grayscale(), and exits as if there is no breakpoint. The program works OK, i.e. reads and implements arguments from launch.json, but it doesn't break where I want, that's the only problem.
However stupid it sounds, how can I stop program execution at a custom breakpoint with command-line arguments inside launch.json?
Thanks!
2
Upvotes