2

Whenever I am debugging C++ program functions, sometimes it steps into libraries/constructors. I want to debug 'just my code'. There are direct settings for this feature in Visual Studio. But I am unable to find it in Visual Studio Code settings.

{ } launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.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
              }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
          }
    ]
}
ph0en1x
  • 68
  • 1
  • 13

2 Answers2

3

I think this should be enabled by default. However, For this, you need to change the launch.json file. Inside the launch.json file you have to set "justMyCode" to true.

"justMyCode":true

put it under request or any place inside configuration.

Fadi
  • 585
  • 4
  • 22
  • Ok, But The debugger is still stepping into the library/constructor (if just my code is enabled by default). And about the solution, do I need to add a separate configuration in launch.json? [reference](https://stackoverflow.com/questions/52980448/how-to-disable-just-my-code-setting-in-vscode-debugger) – ph0en1x Jul 07 '22 at 09:20
  • 1
    Yes, give it a go. create another conf called for example (test) and set the value of justMyCode inside – Fadi Jul 07 '22 at 10:18
0

So far, there is no option for justMyCode in VS Code C++ Debugger (GDB v12.1). There is no mention of justMyCode in the C++ Debugger documentation.

When you add justMyCode (feature for python debugger) and skipFiles (feature for node.js debugger) in launch.json in VS Code, it gives an error.

Property justMyCode is not allowed.

For now, The only way to skip external codes is, just by doing 'Step into and then Step out'.

ph0en1x
  • 68
  • 1
  • 13