This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Debug symbol information in elf file


Hi All,
I'm having a problem with debugging (with gdb) an application that was built using gcc. Gcc has been patched to target a non-standard architecture, but I'm not sure the port is complete.
When debugging with gdb, function parameters are not displayed properly. I think this is because gdb is looking for the parameter on the stack, where in fact it is in a register.
For example, when debugging  this code:

PRIVATE uint8 u8UpdateTimeBlock(uint8 u8TimeBlock)
{
    /* Update block state for next time, if in a state where regular
       updates should be performed */
    if ((sDemoData.sSystem.eState != E_STATE_SET_CHANNEL)
        && (sDemoData.sSystem.eState != E_STATE_SETUP_SCREEN)
        && (sDemoData.sSystem.eState != E_STATE_SCANNING))
    {
        u8TimeBlock++;
        if (u8TimeBlock >= MAX_BLOCKS)
        {
            u8TimeBlock = 0;
        }
    }

    return u8TimeBlock;
}

With gdb, it thinks that the parameter u8TimeBlock is on the stack at offset 7:

(gdb) info address u8TimeBlock
Symbol "u8TimeBlock" is an argument at offset 7.

In fact, from the disassembly listing we can see that the parameter is actually in r3, then gets moved to r7.

04001604 <_u8UpdateTimeBlock>:
 4001604:       30 21 1f                        b.addi     r1,r1,0xfffffff8
 4001607:       04 e3                           b.mov      r7,r3
 4001609:       20 e1 e0                        b.sb       0x7(r1),r7
 400160c:       8c e0 75 52 00 20               b.lwz      r7,0x4004aac(r0)
 4001612:       40 c7 94                        b.beqi     r7,0x3,400163b <_u8Up
dateTimeBlock+0x37>
 4001615:       8c e0 75 52 00 20               b.lwz      r7,0x4004aac(r0)
 400161b:       40 27 04                        b.beqi     r7,0x4,400163b <_u8Up
dateTimeBlock+0x37>
 400161e:       8c e0 75 52 00 20               b.lwz      r7,0x4004aac(r0)
 4001624:       40 a7 e8                        b.beqi     r7,0x5,400163b <_u8Up
dateTimeBlock+0x37>
 4001627:       24 e1 e0                        b.lbz      r7,0x7(r1)
 400162a:       00 f8                           b.addi     r7,r7,0x1
 400162c:       20 e1 e0                        b.sb       0x7(r1),r7
 400162f:       24 e1 e0                        b.lbz      r7,0x7(r1)
 4001632:       3c e7 c8                        b.sfleui   r7,0x13
 4001635:       47 26 00                        b.bf       400163b <_u8UpdateTim
eBlock+0x37>
 4001638:       20 01 e0                        b.sb       0x7(r1),r0
 400163b:       24 e1 e0                        b.lbz      r7,0x7(r1)
 400163e:       04 67                           b.mov      r3,r7
 4001640:       30 21 10                        b.addi     r1,r1,0x8
 4001643:       47 d2 48                        b.jr       r9

I am wondering if the gcc port is somehow not putting the right debug symbol information into the elf file.
Output of objdump -stabs:

459    FUN    0      681    04001604 25677  u8UpdateTimeBlock:f(1,8)
460    PSYM   0      680    00000007 25530  u8TimeBlock:p(1,8)
461    46     0      0      04001604 0
462    SLINE  0      681    00000000 0
463    SLINE  0      684    00000008 0
464    SLINE  0      688    00000023 0
465    SLINE  0      689    0000002b 0
466    SLINE  0      691    00000034 0
467    SLINE  0      695    00000037 0
468    SLINE  0      696    0000003a 0
469    FUN    0      0      00000042 0
470    78     0      0      04001646 0

According to http://sourceware.org/gdb/onlinedocs/stabs.html#Parameters, I believe there should be 2 entries in the stabs for the register parameter, a PSYM  and RSYM. 

Please could you tell me if this assumption is correct and if so, any ideas why gcc would not be putting  this information in the elf file? Is there any architectural dependant code that needs to be implemented that might be missing from the port to add this debugging information?

Thanks very much,
Matt



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]