调试符号(g ++ / clang ++)中缺少QObject类信息

I'm building a Qt project using g++ and debugging with gdb. Recently, I noticed that class info about QObject and all Qt types that derive from it, seem to be absent from my debug symbols. For example, the gdb command ptype QObject results in No symbol "QObject" in current context. Similarly I can't call methods, examine the d_ptr of an instance, or downcast a derived pointer to QObject* inside the debugger. info types does not list any contents from qobject.h.

For derived classes of QObject defined in my own code, I can see my own members just fine but where the base class is listed, it just says <QObject> = {<No data fields>}

Other Qt classes that are declared in public headers, for example QString, are present in the debug symbols. I can't see anything about the declaration of QObject that would make it different.

我有一个用于研究此问题的简约项目:

//main.cpp
#include <iostream>
#include <QObject>

int main()
{
    QObject* spiff = new QObject();

    spiff->setObjectName("Foo");
    std::cout << qPrintable(spiff->objectName()) << std::endl;

    return 0;
}
#project.pro
QT -= gui
CONFIG += debug
SOURCES += main.cpp 

对我而言,这里似乎没有任何东西。没有构建错误,并且代码按预期执行。

这似乎不受调试级别或优化标志,任何调试符号格式的影响,无论我使用g ++ vs. clang ++还是gdb vs lldb,发行版(在Arch,Ubuntu和minGW-w64上尝试),无论我是否链接到Qt库,是使用调试符号构建的,还是是否启用了漂亮打印功能。

我很难找到有关gdb用于检查类的功能的任何信息(这很有意义:为什么要使用调试器检查静态代码),但是由于这使我无法调用方法,因此这是一个很大的不便。我发现的任何东西似乎都没有表明一个原因,即调试符号中仅会省略某些类,或者Qt对此可能特有的原因。