Bug 42638 - stack trace shows wrong value for a formal parameter in call-chain
Summary: stack trace shows wrong value for a formal parameter in call-chain
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-06 20:26 UTC by Khem Raj
Modified: 2010-05-24 08:58 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work:
Known to fail: 4.4.1 4.4.2 4.1.1
Last reconfirmed:


Attachments
C testcase (3.66 KB, application/octet-stream)
2010-01-06 20:27 UTC, Khem Raj
Details
testcase (928 bytes, text/plain)
2010-01-06 20:28 UTC, Khem Raj
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2010-01-06 20:26:46 UTC
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.
Comment 1 Khem Raj 2010-01-06 20:27:13 UTC
Created attachment 19489 [details]
C testcase
Comment 2 Khem Raj 2010-01-06 20:28:20 UTC
Created attachment 19490 [details]
testcase
Comment 3 Khem Raj 2010-01-06 22:34:44 UTC
http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01317.html

could be the fix.
Comment 4 Jakub Jelinek 2010-05-24 08:58:26 UTC
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).