【问题标题】:gcc gdb no debugging infogcc gdb 没有调试信息
【发布时间】:2012-10-30 10:26:52
【问题描述】:

我试图阻止 g++ 内联模板化函数,这会导致 gdb 缺少调试信息,例如局部变量甚至当前行号。

实际上,我猜这与内联模板函数有关,因为这是我无法访问调用堆栈中任何内容的唯一情况。

我几乎尝试了所有 g++ 选项,例如:

-DDEBUG -O0 -fno-inline -fno-implicit-inline-templates

甚至考虑在我的函数前加上 __attribute__ ((noinline)) 无效。

我的调用堆栈看起来像

#0  CVector<CGatherColor>::operator[] (this=0x9324480, index=1208) at ../utils/vector.h:28
#1  0x0000000000ee1d27 in unsigned int CBrdfLoop::trace_t<CAreaLightSquare, CNoCulling, CAreaLightSquare, CBrdfLdSampler>(int, unsigned int, CPrimMBVH*, CVector<CBrdfCache::CVertexCache>*, CAreaLightSquare&, CNoCulling&, CAreaLightSquare&, CBrdfLoop::CVtxSmpInfo const&, CBrdfLdSampler&) ()
#2  0x0000000000eb52ac in void CBrdfLoop::illuminate_t<CAreaLightSquare, CAreaLightSquare, CBrdfLdSampler>(unsigned int, CBrdfLdSampler&, CVector<CBrdfCache::CVertexCache>*, CAreaLightSquare&, CAreaLightSquare&, unsigned int, CPrimMBVH*) ()

无论我做什么,都没有行号和调试信息。我正在使用 g++ 4.4.5 进行编译并使用 GNU gdb (GDB) Fedora (7.1-34.fc13) 进行调试。

我很卡住,调试也很困难,除了 printf 我别无选择... 这是我正在使用的版本的已知问题吗?我能做些什么吗?

更新:使用更新版本的 gcc/gdb,没问题。看起来像一个 gcc/gdb 错误。

【问题讨论】:

  • Captain Obvious:你使用-g吗?它未在您尝试的选项中列出
  • 是的,我正在使用 -ggdb 这显然可以确保我有 gdb 的调试信息...这是我的编译选项:g++ -c -DDEBUG -O0 -fno-inline -fno-implicit-inline-templates -Wno-deprecated -ggdb -Wall -fPIC -MD -msse2
  • note -fno-implicit-inline-templates 根据文档“不要发出代码”,所以它实际上使问题变得更糟。

标签: debugging gdb g++ symbols


【解决方案1】:

我建议使用 -g3 符号来获取详细的调试信息。这将产生可用于调试流程的完整代码级信息。

【讨论】:

    猜你喜欢
    • 2015-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    • 1970-01-01
    • 2012-05-27
    • 2012-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多