1 /* DWARF2 EH unwinding support for Linux/m68k.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file with other programs, and to distribute
14 those programs without any restriction coming from the use of this
15 file. (The General Public License restrictions do apply in other
16 respects; for example, they cover modification of the file, and
17 distribution when not linked into another program.)
19 GCC is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with GCC; see the file COPYING. If not, write to
26 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA. */
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 Don't use this at all if inhibit_libc is used. */
37 /* <sys/ucontext.h> is unfortunately broken right now. */
39 unsigned long uc_flags;
40 struct ucontext *uc_link;
42 mcontext_t uc_mcontext;
43 unsigned long uc_filler[80];
44 __sigset_t uc_sigmask;
47 #define MD_FALLBACK_FRAME_STATE_FOR m68k_fallback_frame_state
50 #define M68K_FP_SIZE 8
52 #define M68K_FP_SIZE 12
55 static _Unwind_Reason_Code
56 m68k_fallback_frame_state (struct _Unwind_Context *context,
57 _Unwind_FrameState *fs)
59 unsigned short *pc = context->ra;
62 /* moveq #__NR_sigreturn,%d0; trap #0 */
63 if (pc[0] == 0x7077 && pc[1] == 0x4e40)
65 struct sigcontext *sc;
67 /* Context is passed as the 3rd argument. */
68 sc = *(struct sigcontext **) (context->cfa + 8);
71 fs->regs.cfa_how = CFA_REG_OFFSET;
72 fs->regs.cfa_reg = 15;
73 fs->regs.cfa_offset = cfa - (long) context->cfa;
75 fs->regs.reg[0].how = REG_SAVED_OFFSET;
76 fs->regs.reg[0].loc.offset = (long) &sc->sc_d0 - cfa;
77 fs->regs.reg[1].how = REG_SAVED_OFFSET;
78 fs->regs.reg[1].loc.offset = (long) &sc->sc_d1 - cfa;
79 fs->regs.reg[8].how = REG_SAVED_OFFSET;
80 fs->regs.reg[8].loc.offset = (long) &sc->sc_a0 - cfa;
81 fs->regs.reg[9].how = REG_SAVED_OFFSET;
82 fs->regs.reg[9].loc.offset = (long) &sc->sc_a1 - cfa;
84 fs->regs.reg[24].how = REG_SAVED_OFFSET;
85 fs->regs.reg[24].loc.offset = (long) &sc->sc_pc - cfa;
87 if (*(int *) sc->sc_fpstate)
89 int *fpregs = (int *) sc->sc_fpregs;
91 fs->regs.reg[16].how = REG_SAVED_OFFSET;
92 fs->regs.reg[16].loc.offset = (long) &fpregs[0] - cfa;
93 fs->regs.reg[17].how = REG_SAVED_OFFSET;
94 fs->regs.reg[17].loc.offset = (long) &fpregs[M68K_FP_SIZE/4] - cfa;
98 /* move.l #__NR_rt_sigreturn,%d0; trap #0 */
99 else if (pc[0] == 0x203c && pc[1] == 0x0000 &&
100 pc[2] == 0x00ad && pc[3] == 0x4e40)
102 /* moveq #~__NR_rt_sigreturn,%d0; not.b %d0; trap #0 */
103 else if (pc[0] == 0x7052 && pc[1] == 0x4600 && pc[2] == 0x4e40)
106 struct uw_ucontext *uc;
110 /* Context is passed as the 3rd argument. */
111 uc = *(struct uw_ucontext **) (context->cfa + 8);
113 gregs = uc->uc_mcontext.gregs;
115 fs->regs.cfa_how = CFA_REG_OFFSET;
116 fs->regs.cfa_reg = 15;
117 fs->regs.cfa_offset = cfa - (long) context->cfa;
119 /* register %d0-%d7/%a0-%a6 */
120 for (i = 0; i <= 14; i++)
122 fs->regs.reg[i].how = REG_SAVED_OFFSET;
123 fs->regs.reg[i].loc.offset = (long) &gregs[i] - cfa;
127 fs->regs.reg[24].how = REG_SAVED_OFFSET;
128 fs->regs.reg[24].loc.offset = (long) &gregs[16] - cfa;
130 #define uc_fpstate uc_filler[0]
134 long fpregs = (long) uc->uc_mcontext.fpregs.f_fpregs;
136 /* register %fp0-%fp7 */
137 for (i = 16; i <= 23; i++)
139 fs->regs.reg[i].how = REG_SAVED_OFFSET;
140 fs->regs.reg[i].loc.offset = fpregs - cfa;
141 fpregs += M68K_FP_SIZE;
146 return _URC_END_OF_STACK;
148 fs->retaddr_column = 24;
149 fs->signal_frame = 1;
151 return _URC_NO_REASON;
153 #endif /* ifdef inhibit_libc */