【问题标题】:GDB not finding header, while debuggingGDB在调试时找不到头文件
【发布时间】:2022-10-23 19:07:50
【问题描述】:

这就是我要运行的:

#include "TVk-core.h"

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

“TVk-core.h”是我正在处理的库中的头文件,我将其包含在 CMakeLists.txt 中。 “iostream”也包含在“TVk-core.h”中。 我使用 g++ 并编译并运行良好。 但是当我尝试在

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

并尝试调试,它不起作用,抱怨内部错误:

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).

并且只是中止。 我想,也许是因为标题,结果证明是正确的。如果我只包含“iostream”,则不会发生错误。 我该如何解决?

我在 AMD 处理器上运行 Linux Mint 21 x64。我使用带有 C/C++ 和 CMake 插件的 VS Code。 我设置了一个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}/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
                }
            ]
        }
    ]
}

我是一个完整的 gdb 菜鸟,以前从未使用过它,所以我真的不知道我的设置是否有意义。 有我的 C/C++ 配置,idk 如果它们有所作为,但你去:

{
    "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
}

【问题讨论】:

  • 哦,是的,这就是它在终端中打印的内容: 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"
  • 看起来您的 gdb 副本已损坏或 vscode 驱动不正确,您可能应该提交错误报告

标签: c++ linux debugging visual-studio-code gdb


【解决方案1】:

我修好了它。事实证明,正如@Alan Britles 所说,这是 gdb 或 VS Code 中的一个错误。我安装了 gdb 11.2,现在它可以工作了! Apt 只有 gdb 12.1,所以我不得不下载一个 tarball 并手动安装它。 如果其他人有这个问题,这里是 tarball 的链接:http://ftp.gwdg.de/pub/linux/sources.redhat.com/gdb/releases/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-31
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多