GDB 找不到行号,objdump 可以

发布于 2024-12-28 17:09:43 字数 2938 浏览 2 评论 0原文

我正在使用 DDD/GDB 调试在 NintendoDS 上运行的自制游戏,该游戏使用“arm-eabi-gcc (devkitARM release 32) 4.5.1”构建。 仅供参考,我上传了未剥离的 .elf 二进制文件(文件不再托管),以防有人想要重现下面的一些步骤。

  • 我向 gdb 询问 GameScript.o (GobExpression::eval) 中的函数之一的列表,它处理得很好。

  • 我向 gdb 询问 SimpleGob::play 的列表,在同一个 GameScript.o 中,它抱怨“没有 SimpleGob::play 已知的行号”。 (arm-eabi-gdb 会话就在下面:)

arm-eabi-gdb AppleAssault.elf

GNU gdb (GDB) 7.2
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-eabi".
Reading symbols from AppleAssault.elf...done.
(gdb) list GobExpression::eval
342    bool eval(s16 data[REGISTERS], iGun **extra=0) {
343         GobCollision gc[2]={{0,0,data},{0,0,0}};
344         return eval(gc,extra);
345       }
346     
347       bool eval(GobCollision* c, iGun **extra=0) {
348         s16 *data=c[0].data;
349         s16 stack[STACKSIZE]; int sp=0;
350         u8 op;
351         if (!code) return true;
gdb) list SimpleGob::play
play    play()  
(gdb) list SimpleGob::play
No line number known for SimpleGob::play.

但是,如果我调用arm-eabi-objdump -drl AppleAssault.elf,它显然会找到一些行号,正如转储中提到的那样:

0203c7f8 <_ZN9SimpleGob4playEv>:
_ZN9SimpleGob4playEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1710
 203c7f8:       b5f0            push    {r4, r5, r6, r7, lr}
 203c7fa:       465f            mov     r7, fp
 203c7fc:       4656            mov     r6, sl
 203c7fe:       464d            mov     r5, r9
 203c800:       4644            mov     r4, r8
 203c802:       b4f0            push    {r4, r5, r6, r7}
 203c804:       b0a7            sub     sp, #156        ; 0x9c
_ZN9CommonGob11gobDoChecksEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1430
 203c806:       7c03            ldrb    r3, [r0, #16]
_ZN9SimpleGob4playEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1710
 203c808:       1c05            adds    r5, r0, #0
_ZN9CommonGob11gobDoChecksEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1430
 203c80a:       2b00            cmp     r3, #0
 203c80c:       d100            bne.n   203c810 <_ZN9SimpleGob4playEv+0x18>
 203c80e:       e099            b.n     203c944 <_ZN9SimpleGob4playEv+0x14c>

文件是用arm-eabi-g++ -MMD -MP -MF编译的/beetle/hobby/DS/dsgametools/branches/companim/libgeds/build/GameObject.d -g -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork {include路径剥离} -DARM9 -fno-rtti -Wall -O2 -c /beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp -o GameObject.o,因此启用调试符号,打包在 .a 存档中,最后与程序链接。使用 -O0 重新编译似乎没有帮助。

我在 GDB 找不到行号 看到了一种解决方法,建议使用 add-symbol-file,虽然我不太知道要添加哪个符号文件...我是否缺少 GDB 调试符号的一个微妙的关键概念,它可以解释我的程序中 GDB 缺少什么(某些部分)能够注释它带有行号吗?

I'm using DDD/GDB to debug a homebrew game running on NintendoDS, built with "arm-eabi-gcc (devkitARM release 32) 4.5.1".
FYI, I uploaded the unstripped .elf binary (file no longer hosted), in case anybody wants to reproduce some of the steps below.

  • I ask gdb for a listing of one of the functions sitting in GameScript.o (GobExpression::eval) it handles it fine.

  • I ask gdb for a listing of SimpleGob::play, in the same GameScript.o, it complains that "No line number known for SimpleGob::play".
    (arm-eabi-gdb session just below:)

arm-eabi-gdb AppleAssault.elf

GNU gdb (GDB) 7.2
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-eabi".
Reading symbols from AppleAssault.elf...done.
(gdb) list GobExpression::eval
342    bool eval(s16 data[REGISTERS], iGun **extra=0) {
343         GobCollision gc[2]={{0,0,data},{0,0,0}};
344         return eval(gc,extra);
345       }
346     
347       bool eval(GobCollision* c, iGun **extra=0) {
348         s16 *data=c[0].data;
349         s16 stack[STACKSIZE]; int sp=0;
350         u8 op;
351         if (!code) return true;
gdb) list SimpleGob::play
play    play()  
(gdb) list SimpleGob::play
No line number known for SimpleGob::play.

However, if I invoke arm-eabi-objdump -drl AppleAssault.elf, it obviously do find some line numbers, as they are mentioned in the dump:

0203c7f8 <_ZN9SimpleGob4playEv>:
_ZN9SimpleGob4playEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1710
 203c7f8:       b5f0            push    {r4, r5, r6, r7, lr}
 203c7fa:       465f            mov     r7, fp
 203c7fc:       4656            mov     r6, sl
 203c7fe:       464d            mov     r5, r9
 203c800:       4644            mov     r4, r8
 203c802:       b4f0            push    {r4, r5, r6, r7}
 203c804:       b0a7            sub     sp, #156        ; 0x9c
_ZN9CommonGob11gobDoChecksEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1430
 203c806:       7c03            ldrb    r3, [r0, #16]
_ZN9SimpleGob4playEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1710
 203c808:       1c05            adds    r5, r0, #0
_ZN9CommonGob11gobDoChecksEv():
/beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp:1430
 203c80a:       2b00            cmp     r3, #0
 203c80c:       d100            bne.n   203c810 <_ZN9SimpleGob4playEv+0x18>
 203c80e:       e099            b.n     203c944 <_ZN9SimpleGob4playEv+0x14c>

File is compiled with arm-eabi-g++ -MMD -MP -MF /beetle/hobby/DS/dsgametools/branches/companim/libgeds/build/GameObject.d -g -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork {include path stripped} -DARM9 -fno-rtti -Wall -O2 -c /beetle/hobby/DS/dsgametools/branches/companim/libgeds/source/GameObject.cpp -o GameObject.o, thus with debugging symbols enabled, packed in a .a archive, and finally linked with the program. Recompiling with -O0 doesn't seem to help.

I've seen a workaround at GDB can not find line numbers that suggests to use add-symbol-file, although I don't quite know which symbol file I'd add ... Am I missing a subtle key concept of GDB debugging symbols that would explain what (some part of) my programs are missing for GDB to be able to annotate it with line numbers ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自我难过 2025-01-04 17:09:43

使用 g++ 编译时尝试使用 -gstabs+ 来尝试使用 GNU 扩展调试信息(仅由 gdb 理解)。

Try -gstabs+ when compiling with g++ to try with GNU extensions debugging information (only understood by gdb).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文