1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-27 01:27:39 +01:00

(ia64_local_resume): Begin to support unw_resume() that goes across a signal

(not complete yet).

(Logical change 1.40)
This commit is contained in:
mostang.com!davidm 2003-01-21 17:41:20 +00:00
parent a393d743f0
commit ea0a71ab32

View file

@ -1,5 +1,5 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2001-2002 Hewlett-Packard Co
Copyright (C) 2001-2003 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind.
@ -27,6 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "rse.h"
#include "unwind_i.h"
#include "offsets.h"
#ifndef UNW_REMOTE_ONLY
@ -34,6 +35,7 @@ HIDDEN inline int
ia64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
{
struct cursor *c = (struct cursor *) cursor;
long do_sigreturn = 0;
unw_fpreg_t fpval;
ucontext_t *uc = arg;
unw_word_t val, sol;
@ -97,20 +99,52 @@ ia64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
for (i = 16; i < 32; ++i)
SET_FPREG (sc_fr[i], fr_loc[i - 16]);
if (c->is_signal_frame)
abort (); /* XXX this needs to be fixed... */
/* Account for the fact that __ia64_install_context() returns via
br.ret, which will decrement bsp by size-of-locals. */
sol = (uc->uc_mcontext.sc_ar_pfs >> 7) & 0x7f;
uc->uc_mcontext.sc_ar_bsp = ia64_rse_skip_regs (c->bsp, sol);
uc->uc_mcontext.sc_flags = 0;
uc->uc_mcontext.sc_gr[1] = c->pi.gp;
uc->uc_mcontext.sc_gr[12] = c->psp;
if (unlikely (c->sigcontext_loc))
{
struct sigcontext *sc = (struct sigcontext *) c->sigcontext_loc;
/* We're returning to a frame that was (either directly or
indirectly) interrupted by a signal. We have to restore
_both_ "preserved" and "scratch" registers. That doesn't
leave us any registers to work with, and the only way we can
achieve this is by doing a sigreturn().
Note: it might be tempting to think that we don't have to
restore the scratch registers when returning to a frame that
was indirectly interrupted by a signal. However, that is not
safe because that frame and its descendants could have been
using a special convention that stores "preserved" state in
scratch registers. The fsyscall convention does this with
r11 (to save ar.pfs) and b6 (to save "rp"), for example. */
sc->sc_ip = uc->uc_mcontext.sc_br[0];
sc->sc_gr[12] = c->psp;
uc->uc_mcontext.sc_gr[12] = (c->sigcontext_loc - c->sigcontext_off);
do_sigreturn = 1;
/* Account for the fact that sigreturn will decrement bsp by
size-of-frame. */
#if 0
sof = (uc->uc_mcontext.sc_ar_pfs >> 0) & 0x7f;
uc->uc_mcontext.sc_ar_bsp = ia64_rse_skip_regs (c->bsp, sof);
#else
uc->uc_mcontext.sc_ar_bsp = sc->sc_ar_bsp;
#endif
printf("uc->bsp=%p, sc->bsp=%p\n", uc->uc_mcontext.sc_ar_bsp, sc->sc_ar_bsp);
}
else
{
/* Account for the fact that __ia64_install_context() returns
via br.ret, which will decrement bsp by size-of-locals. */
sol = (uc->uc_mcontext.sc_ar_pfs >> 7) & 0x7f;
printf("this needs fixing\n");
uc->uc_mcontext.sc_ar_bsp = ia64_rse_skip_regs (c->bsp, sol);
}
__ia64_install_context (uc, c->eh_args[0], c->eh_args[1], c->eh_args[2],
c->eh_args[3]);
c->eh_args[3], do_sigreturn);
}
#endif /* !UNW_REMOTE_ONLY */