1/* DWARF2 EH unwinding support for Alpha Linux. 2 Copyright (C) 2004, 2005 Free Software Foundation, Inc. 3 4This file is part of GCC. 5 6GCC is free software; you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation; either version 2, or (at your option) 9any later version. 10 11In addition to the permissions in the GNU General Public License, the 12Free Software Foundation gives you unlimited permission to link the 13compiled version of this file with other programs, and to distribute 14those programs without any restriction coming from the use of this 15file. (The General Public License restrictions do apply in other 16respects; for example, they cover modification of the file, and 17distribution when not linked into another program.) 18 19GCC is distributed in the hope that it will be useful, 20but WITHOUT ANY WARRANTY; without even the implied warranty of 21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22GNU General Public License for more details. 23 24You should have received a copy of the GNU General Public License 25along with GCC; see the file COPYING. If not, write to 26the Free Software Foundation, 51 Franklin Street, Fifth Floor, 27Boston, MA 02110-1301, USA. */ 28 29/* Do code reading to identify a signal frame, and set the frame 30 state data appropriately. See unwind-dw2.c for the structs. */ 31 32#include <signal.h> 33#include <sys/ucontext.h> 34 35#define MD_FALLBACK_FRAME_STATE_FOR alpha_fallback_frame_state 36 37static _Unwind_Reason_Code 38alpha_fallback_frame_state (struct _Unwind_Context *context, 39 _Unwind_FrameState *fs) 40{ 41 unsigned int *pc = context->ra; 42 struct sigcontext *sc; 43 long new_cfa, i; 44 45 if (pc[0] != 0x47fe0410 /* mov $30,$16 */ 46 || pc[2] != 0x00000083 /* callsys */) 47 return _URC_END_OF_STACK; 48 if (context->cfa == 0) 49 return _URC_END_OF_STACK; 50 if (pc[1] == 0x201f0067) /* lda $0,NR_sigreturn */ 51 sc = context->cfa; 52 else if (pc[1] == 0x201f015f) /* lda $0,NR_rt_sigreturn */ 53 { 54 struct rt_sigframe { 55 struct siginfo info; 56 struct ucontext uc; 57 } *rt_ = context->cfa; 58 sc = &rt_->uc.uc_mcontext; 59 } 60 else 61 return _URC_END_OF_STACK; 62 new_cfa = sc->sc_regs[30]; 63 fs->cfa_how = CFA_REG_OFFSET; 64 fs->cfa_reg = 30; 65 fs->cfa_offset = new_cfa - (long) context->cfa; 66 for (i = 0; i < 30; ++i) 67 { 68 fs->regs.reg[i].how = REG_SAVED_OFFSET; 69 fs->regs.reg[i].loc.offset 70 = (long)&sc->sc_regs[i] - new_cfa; 71 } 72 for (i = 0; i < 31; ++i) 73 { 74 fs->regs.reg[i+32].how = REG_SAVED_OFFSET; 75 fs->regs.reg[i+32].loc.offset 76 = (long)&sc->sc_fpregs[i] - new_cfa; 77 } 78 fs->regs.reg[64].how = REG_SAVED_OFFSET; 79 fs->regs.reg[64].loc.offset = (long)&sc->sc_pc - new_cfa; 80 fs->retaddr_column = 64; 81 return _URC_NO_REASON; 82} 83