WebFreak001 / code-debug

Native debugging for VSCode
The Unlicense
409 stars 115 forks source link

My breakpoints are completely ignored #420

Open iamalsonothere opened 7 months ago

iamalsonothere commented 7 months ago

When i configure the GDB debug in launch.json and add a pre task to compile it, all it does is launch the binary. Doesnt even attempt at debugging it, does not acknowledge that any breakpoints exist.

I am using VSCodium 1.87.2

$ gdb --version
GNU gdb (GDB) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
plowsters commented 4 months ago

I had the same issue on VSCodium 1.90.2, and I got it to work. CMake successfully builds the executable, but gdb ignores all breakpoints. Fixed with this launch.json configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "GDB Debug",
      "type": "gdb",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "target": "${workspaceFolder}/build/[executable name]",
      "stopAtEntry": false,
      "arguments": "",
      "valuesFormatting": "prettyPrinters"
    }
  ]
}
plowsters commented 4 months ago

Additionally, these are the build tasks I wrote in tasks.json:

"version": "2.0.0",
  "tasks": [
    {
      "label": "CMake configure",
      "type": "process",
      "command": "cmake",
      "args": [
        "-S",
        "${workspaceFolder}",
        "-B",
        "${workspaceFolder}/build",
        "-DCMAKE_BUILD_TYPE=Debug"
      ],
      "group": {
        "kind": "build",
        "isDefault": false
      },
      "problemMatcher": [
        {
          "owner": "cpp",
          "fileLocation": ["relative", "${workspaceFolder}"],
          "pattern": {
            "regexp": "^(.*?):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
          }
        }
      ],
      "detail": "Configure the project using CMake"
    },
    {
      "label": "CMake build",
      "type": "process",
      "command": "cmake",
      "args": [
        "--build",
        "${workspaceFolder}/build"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": [
        {
          "owner": "cpp",
          "fileLocation": ["relative", "${workspaceFolder}"],
          "pattern": {
            "regexp": "^(.*?):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
          }
        }
      ],
      "detail": "Build the project using CMake"
    }
  ]
}

And here is the CMakeLists.txt used to build it:

cmake_minimum_required(VERSION 3.23)

project(BugHTTPServer)

set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)

add_executable(BugHTTPServer http_server.c)

set(CMAKE_BUILD_TYPE Debug)
GitMensch commented 4 months ago

... So what was the part in launch config that actually fixed it?

plowsters commented 4 months ago

I was originally trying to launch it in the VSCodium terminal using

"terminal": "integrated"

Removing this line fixed the issue for me, and it loads in VSCodium by default anyways.