1

I have found out a few different ways to debug C with the GCC compiler, however I want to have debugging on by default. Is there any way I can do this with a setting in my launch.json in VSCode?

Here is my 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}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Or Yaacov
  • 3,597
  • 5
  • 25
  • 49

1 Answers1

2

Add these to your CFLAGS: -gdwarf-4 -g3

To do that, run this command:

export CFLAGS="${CFLAGS} -gdwarf-4 -g3"

See this link for more information and this link for running commands in launch.json.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
  • 1
    thank you for your answer. Sadly it's says "Property CFLAGS is not allowed." may you please add a full example? – Or Yaacov Mar 03 '19 at 14:21
  • See updated answer. I'm not exactly sure if and how you can do this. To be honest, I don't usually use proprietary editors like VSCode. I use open-source alternatives (the non-Microsoft version, `code-oss`). – S.S. Anne Mar 03 '19 at 14:37