From 9f93a9d0da46ee23112a7a90404d1f4e364079e0 Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Sat, 16 Nov 2002 06:50:04 +0000 Subject: [PATCH] (ia64_local_resume): Move here from unw_init_local(). (Logical change 1.27) --- src/ia64/unw_resume.c | 86 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/src/ia64/unw_resume.c b/src/ia64/unw_resume.c index 51cdab51..3b86d494 100644 --- a/src/ia64/unw_resume.c +++ b/src/ia64/unw_resume.c @@ -23,16 +23,98 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + +#include "rse.h" #include "unwind_i.h" +inline int +ia64_local_resume (unw_cursor_t *cursor, void *arg) +{ + struct ia64_cursor *c = (struct ia64_cursor *) cursor; + unw_fpreg_t fpval; + ucontext_t *uc = arg; + unw_word_t val, sol; + int i, ret; +# define SET_NAT(n) \ + do \ + { \ + ret = ia64_access_reg (c, UNW_IA64_NAT + (n), &val, 0); \ + if (ret < 0) \ + return ret; \ + if (val) \ + uc->uc_mcontext.sc_nat |= (unw_word_t) 1 << n; \ + } \ + while (0) +# define SET_REG(f, r) \ + do \ + { \ + ret = ia64_get (c, c->r, &val); \ + if (ret < 0) \ + return ret; \ + uc->uc_mcontext.f = val; \ + } \ + while (0) +# define SET_FPREG(f, r) \ + do \ + { \ + ret = ia64_getfp (c, c->r, &fpval); \ + if (ret < 0) \ + return ret; \ + uc->uc_mcontext.f.u.bits[0] = fpval.raw.bits[0]; \ + uc->uc_mcontext.f.u.bits[1] = fpval.raw.bits[1]; \ + } \ + while (0) + + SET_REG (sc_ar_pfs, pfs_loc); + SET_REG (sc_br[0], ip_loc); + SET_REG (sc_pr, pr_loc); + SET_REG (sc_ar_rnat, rnat_loc); + SET_REG (sc_ar_lc, lc_loc); + SET_REG (sc_ar_fpsr, fpsr_loc); + + SET_REG (sc_gr[4], r4_loc); SET_REG(sc_gr[5], r5_loc); + SET_REG (sc_gr[6], r6_loc); SET_REG(sc_gr[7], r7_loc); + uc->uc_mcontext.sc_nat = 0; + SET_NAT (4); SET_NAT(5); + SET_NAT (6); SET_NAT(7); + + SET_REG (sc_br[1], b1_loc); + SET_REG (sc_br[2], b2_loc); + SET_REG (sc_br[3], b3_loc); + SET_REG (sc_br[4], b4_loc); + SET_REG (sc_br[5], b5_loc); + SET_FPREG (sc_fr[2], f2_loc); + SET_FPREG (sc_fr[3], f3_loc); + SET_FPREG (sc_fr[4], f4_loc); + SET_FPREG (sc_fr[5], f5_loc); + for (i = 16; i < 32; ++i) + SET_FPREG (sc_fr[i], fr_loc[i - 16]); + + if ((c->pi.flags & IA64_FLAG_SIGTRAMP) != 0) + 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; + + __ia64_install_context (uc, c->eh_args[0], c->eh_args[1], c->eh_args[2], + c->eh_args[3]); +} + int unw_resume (unw_cursor_t *cursor) { struct ia64_cursor *c = (struct ia64_cursor *) cursor; #ifdef UNW_LOCAL_ONLY - return ia64_local_resume (cursor, c->uc); + return ia64_local_resume (cursor, c->as_arg); #else - return (*c->acc.resume) (cursor, c->acc.arg); + return (*c->as->acc.resume) (cursor, c->as_arg); #endif }