Why does gdb stop at a different line than "i b" shows while returning from function? Why does gdb stop at a different line than "i b" shows while returning from function? unix unix

Why does gdb stop at a different line than "i b" shows while returning from function?


The breakpoint is placed at the right place, as you saw, because it did break after returning from the function. If you do a disassemble, you'll also see that the breakpoint is placed at the right instruction (in this example at 0x00401192):

b displayrf 1bdisassemble $pc...   0x0040118d <+29>:    call   0x401199 <display>=> 0x00401192 <+34>:    mov    $0x0,%eax   0x00401197 <+39>:    leavei b...2       breakpoint     keep y   0x00401192 in main at try5.c:8

But it shows the wrong line number. First I thought it might be related to function return, so I added extra instructions after the display call, but it still shows the wrong line.

This looks a bug to me.