[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.12.1 Specific Targets

For the alpha, the __unwind_function will be something resembling:

 
void
__unwind_function(void *ptr)
{
  /* First frame */
  asm ("ldq $15, 8($30)"); /* get the saved frame ptr; 15 is fp, 30 is sp */
  asm ("bis $15, $15, $30"); /* reload sp with the fp we found */

  /* Second frame */
  asm ("ldq $15, 8($30)"); /* fp */
  asm ("bis $15, $15, $30"); /* reload sp with the fp we found */

  /* Return */
  asm ("ret $31, ($16), 1"); /* return to PTR, stored in a0 */
}

However, there are a few problems preventing it from working. First of all, the gcc-internal function __builtin_return_address needs to work given an argument of 0 for the alpha. As it stands as of August 30th, 1995, the code for BUILT_IN_RETURN_ADDRESS in `expr.c' will definitely not work on the alpha. Instead, we need to define the macros DYNAMIC_CHAIN_ADDRESS (maybe), RETURN_ADDR_IN_PREVIOUS_FRAME, and definitely need a new definition for RETURN_ADDR_RTX.

In addition (and more importantly), we need a way to reliably find the frame pointer on the alpha. The use of the value 8 above to restore the frame pointer (register 15) is incorrect. On many systems, the frame pointer is consistently offset to a specific point on the stack. On the alpha, however, the frame pointer is pushed last. First the return address is stored, then any other registers are saved (e.g., s0), and finally the frame pointer is put in place. So fp could have an offset of 8, but if the calling function saved any registers at all, they add to the offset.

The only places the frame size is noted are with the `.frame' directive, for use by the debugger and the OSF exception handling model (useless to us), and in the initial computation of the new value for sp, the stack pointer. For example, the function may start with:

 
lda $30,-32($30)
.frame $15,32,$26,0

The 32 above is exactly the value we need. With this, we can be sure that the frame pointer is stored 8 bytes less--in this case, at 24(sp)). The drawback is that there is no way that I (Brendan) have found to let us discover the size of a previous frame inside the definition of __unwind_function.

So to accomplish exception handling support on the alpha, we need two things: first, a way to figure out where the frame pointer was stored, and second, a functional __builtin_return_address implementation for except.c to be able to use it.

Or just support DWARF 2 unwind info.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by system on December, 2 2004 using texi2html