This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
IA64 stack unwinder, yet again
- To: "'rth at redhat dot com'" <rth at redhat dot com>, "'aph at cygnus dot com'" <aph at cygnus dot com>, "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Subject: IA64 stack unwinder, yet again
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- Date: Mon, 5 Nov 2001 11:29:09 -0800
- Cc: "MOSBERGER, DAVID (HP-PaloAlto,unix3)" <davidm at hpl dot hp dot com>
I'm still trying to fix the unwinder code in unwind-ia64.c
(http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/unwind-ia64.c?rev
=1.2&content-type=text/x-cvsweb-markup)
I currently have a patch that empirically works for my tests. But I can
neither make sense out of the original code nor convince myself that this is
really correct.
The original problem:
Empirically, uw_init_context_1 still generates a context in which sp and psp
are swapped. It's not hard to understand why this happens. It sets up a
context with the correct values of sp and psp. It then invokes
uw_update_context, after telling it that the new psp value can be computed
by subtracting the difference between psp and sp. Uw_update_context sets sp
to the old psp value, and then adjusts psp by subtracting the original
difference (since the val field in the PSP entry of the frame state is
negative), thus ending up with psp <= sp, which is guaranteed to be wrong
unless the frame has zero size. (I have no idea why this seems to pass C++
tests. It doesn't seem to work for me with Java tests. I doubt it really
works for C++.)
The stopgap:
I'm currently running with a patch that just swaps psp and sp. Empirically
this seems to work, but I have a very bad feeling about this. (It also need
another patch to deal with signal frames. But that's a separate issue.)
My questions:
I'm still having some trouble understanding the intent of the code. Here
are some specific questions:
1) Why is the funny sp and/or psp adjustment in uw_update_context necessary?
It seems to me that initially sp, psp, and rp start out in a consistent
state corresponding to the uw_init_context_1 frame?
2) How is the unwinder getting the initial state of the preserved registers
(e.g. r4-r7)? It seems to me these either should all be forced to memory,
or should be initialized from the current register contents. In the latter
case there are some issues if gcc decides to spill them in
uw_init_context_1.
3) Uw_init_context seems to go out of its way to get the bsp (register
backing store pointer) value corresponding to the frame of
uw_init_context_1's caller (which is usually _Unwind_Raise_Exception?), and
not the one for uw_init_context_1. This seems to mean that sp and bsp don't
correspond. Why?
I'd appreciate any insight.
Hans