GDB does not find line numbers, objdump does

I use DDD / GDB to debug a NintendoDS home game built using "arm-eabi-gcc (devkitARM release 32) 4.5.1". FYI, I downloaded unstripped.elf> here if someone wants to reproduce some of the steps below.

  • I ask gdb to list one of the functions sitting in GameScript.o (GobExpression :: eval), it handles fine.

  • I ask gdb to list SimpleGob :: play, in the same GameScript.o, he complains that "There is no line number known for SimpleGob :: play". (the arm-eabi-gdb session is a little lower :)

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 call arm-eabi-objdump -drl AppleAssault.elf, it will obviously 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 bn 203c944 <_ZN9SimpleGob4playEv+0x14c> 

File 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 included, packaged in an .a archive and finally associated with the program. Recompiling with -O0 doesn't seem to help.

I saw a workaround in GDB that it couldn’t find line numbers that the add-symbol file suggests, although I don’t quite know which symbol file I would add ... I missed the subtle key concept of GDB debugging symbols that would explain that ( some part) of my programs is missing so that GDB can comment on it with line numbers?

+4
source share
1 answer

Try -gstabs+ when compiling with g++ try using the debugging information of the GNU extensions (only gdb is understood).

+3
source

Source: https://habr.com/ru/post/1392465/


All Articles