0

This is what I'm trying to run:

#include "TVk-core.h"

int main()
{
    std::cout<<"Hello World!"<<std::endl;
    ...
    return 0;
}

"TVk-core.h" is a header from a lib I'm working on, which I included in CMakeLists.txt. "iostream" is also included in "TVk-core.h". I use g++ and compiles and runs fine. But when I try to put a breakpoint at

std::cout<<"Hello World!"<<std::endl;

and try to debug, it doesn't work, complaining about an internal error:

Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
/build/gdb-wIRHdd/gdb-12.0.90/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
/build/gdb-wIRHdd/gdb-12.0.90/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
ERROR: GDB exited unexpectedly. Debugging will now abort.
The program '/media/luh0/PARA/Projects/Thesis-Vk/build/tests/test1' has exited with code -1 (0xffffffff).

and just aborts. I figured, maybe it is, because of the header, which turns out to be correct. If I just include "iostream" the error doesn't occur. How do I fix this?

I run Linux Mint 21 x64 on an AMD processor. I use VS Code, with the C/C++ and CMake addons. I set up a launch.json, with these contents:

{
    // 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}/build/tests/test1",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

I am a complete noob with gdb and never before used it, so I really don't know, if my settings even make sense. There are my C/C++ configs, idk if they make a difference, but there you go:

{
    "configurations": [
        {
            "name": "Mint64",
            "includePath": [
                "${workspaceFolder}/src/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "/usr/bin/cmake",
            "intelliSenseMode": "linux-gcc-x64",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17"
        },
        {
            "name": "Ubuntu64",
            "includePath": [
                "${workspaceFolder}/src/**",
                "${workspaceFolder}/dependencies/*/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "/bin/g++",
            "cStandard": "c17",
            "cppStandard": "c++20",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}
2
  • Oh yeah, and this is what it printed in the terminal: Aborted (core dumped) [1] + Aborted (core dumped) "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-3jn3pigo.dyp" 1>"/tmp/Microsoft-MIEngine-Out-hpziedzs.p0b" Commented Oct 22, 2022 at 16:35
  • 1
    Looks like your copy of gdb is broken or vscode is driving it incorrectly, you should probably submit a bug report Commented Oct 22, 2022 at 18:38

1 Answer 1

0

I fixed it. Turns out it is as @Alan Britles said, a bug, either in gdb or VS Code. I installed gdb 11.2, now it works! Apt only has gdb 12.1 tho, so I had to download a tarball and install it manually. If anyone else has this problem, here is a link to the tarballs: http://ftp.gwdg.de/pub/linux/sources.redhat.com/gdb/releases/

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.