|
From: Julian S. <js...@ac...> - 2006-09-21 21:34:35
|
Thanks Jeff for finding a small test case, and Josef for chasing it. I have not much constructive to add except ... > x86 with its explicit call/ret instructions is way easier to get right; > on x86, the stack pointer always changes on call/ret. On PPC, this does > not need to happen as the return address is stored in the link register. > So: ideas for good heuristics welcome. One difficulty on ppc is that the RA is not always in the link register, not even for the innermost frame. Suppose f is a leaf function. Normally RA would remain in lr and that would be OK; however suppose the compiler wants to use lr for some other purpose - not calling a function, maybe for an indirect jump. Then it will have to store LR somewhere else inside f. I am not claiming to understand this fully. I think studying the ppc32-ELF ABI would help. What I do know is that there is a nasty hack in m_stacktrace.c, the part for unwinding the stack -- see VG_(get_StackTrace2) and specifically the stuff for setting/using lr_is_first_RA. This was from one of the IBM linux guys, unfortunately moved on elsewhere now. If you do come up with a good story on unwinding the ppc-linux stack I would like to see it. It may be that the logic for ppc in VG_(get_StackTrace2) is too complex or wrong or something, or maybe it's exactly correct, I don't know. J |