When a formal parameter 1 is not stored on stack the location list mark the life of this parameter in DW_OP_reg0 however it does not consider the function calls that would be made in the function in question and the fact that eax can be destroyed down the call chain. Attached example demonstrates the problem. gcc -m32 -O -g try.c and here is .gdbinit file which would show the problem file a.out b 69 b 71 r bt c bt c q The sample looks like this Breakpoint 1 at 0x80483b7: file try.c, line 69. Breakpoint 2 at 0x80483bd: file try.c, line 71. Breakpoint 1, __sfvwrite (fp=0xffffd810, uio=0x804a018) at try.c:69 69 { #0 __sfvwrite (fp=0xffffd810, uio=0x804a018) at try.c:69 #1 0x080483e8 in __sprint (fp=0xffffd810, uio=0x804a018) at try.c:63 #2 0x0804840d in sprint (fp=0xffffd810, uio=0x804a018) at try.c:74 #3 0x08048436 in main () at try.c:81 Breakpoint 2, __sfvwrite (fp=0xffffd810, uio=0x804a018) at try.c:71 71 } #0 __sfvwrite (fp=0xffffd810, uio=0x804a018) at try.c:71 #1 0x080483e8 in __sprint (fp=0x0, uio=0x804a018) at try.c:63 ------> fp is wrong #2 0x0804840d in sprint (fp=0xffffd810, uio=0x804a018) at try.c:74 #3 0x08048436 in main () at try.c:81 Program exited normally. observe the value of frame 1 formal parameter 'fp' in backtrace.
Created attachment 19489 [details] C testcase
Created attachment 19490 [details] testcase
http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01317.html could be the fix.
Current trunk prints fp=<optimized out>, which is correct (given that the argument is passed in %eax using regparm calling conventions and the register has been/could be clobbered by the call).