1

I try to debug my C-code but my breakpoints are ignored. My system is Windows 10. VS-Code version is 1.38.

This is my launch.json entry:

    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "C:/Users/NCH-Lap10/Desktop/aaa.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "C:/TDM-GCC-64/bin/gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
    },

I would appreciate any hints. Could I provide more information?

2 Answers 2

0

Here I'm sharing my config files, just add them under .vscode folder, and also name the files as given below.

c_cpp_propreties.json

{
   "configurations":[
      {
         "name":"Win32",
         "includePath":[
            "${workspaceFolder}/**",
            "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/trl"
         ],
         "defines":[
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
         ],
         "compilerPath":"C:\\MinGW\\bin\\gcc.exe",
         "cStandard":"c11",
         "cppStandard":"c++17",
         "intelliSenseMode":"clang-x64"
      }
   ],
   "version":4
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/MinGW/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Compile C File"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile C File",
            "command": "gcc",
            "type": "shell",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${workspaceRoot}\\a.exe"
            ],
            "problemMatcher": [
                "$tsc"
            ],
            "presentation": {
                "reveal": "always"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

In order to work above configs, you need to have at least launch.json and tasks.json.

Sign up to request clarification or add additional context in comments.

1 Comment

@kame Also you are using gdb for c code debugging that won't work you need to have gcc for c, and gdb for cpp.
-1

try to rebuild code

  1. activate tabs with your code
  2. press Ctrl+Shift + B
  3. start debugging by pressing F5

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.