How to improve debuggability of inlined function?

Terry Guo flameroc@gmail.com
Thu Oct 30 09:29:00 GMT 2014


Hi there,

When setting breakpoint under gdb for source line that contains an
inlined function call, I often run into below error:

(gdb) b g.c:18
No line 18 in file "g.c".
Make breakpoint pending on future shared library load? (y or [n])

Can such issue be fixed by generating more suitable dwarf information?
If so, could somebody please shed some light on this? I know something
about gcc/dwarf/gdb and I am willing to improve this debug experience.
Thanks in advance for any help.

BR,
Terry

PS:

My test case is:

terguo01@terry-pc01:case$ cat -n g.c
     1 volatile int x;
     2
     3 static inline void NVIC_EnableIRQ(int IRQn)
     4 {
     5  volatile int y;
     6  y = IRQn;
     7 }
     8
     9 __attribute__( ( always_inline ) ) static inline void __WFI(void)
    10 {
    11    __asm volatile ("nop");
    12 }
    13
    14 int main(void) {
    15
    16    x= 42;
    17
    18    NVIC_EnableIRQ(16); //the call will be inlined
    19    NVIC_EnableIRQ(18); //the call will be inlined
    20
    21    while (1)
    22      {
    23 __WFI();
    24      }
    25
    26    return 0 ;
    27 }
    28

The case is compiled with command "../x86/install/bin/gcc -g -O2 -c g.c".

I am using pretty recent gcc and gdb trunk.



More information about the Gcc-help mailing list