OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [config/] [mips/] [linux-unwind.h] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* DWARF2 EH unwinding support for MIPS Linux.
2
   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
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)
9
any later version.
10
 
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.)
18
 
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.
23
 
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.  */
28
 
29
#ifndef inhibit_libc
30
/* Do code reading to identify a signal frame, and set the frame
31
   state data appropriately.  See unwind-dw2.c for the structs.  */
32
 
33
#include <signal.h>
34
 
35
/* The third parameter to the signal handler points to something with
36
 * this structure defined in asm/ucontext.h, but the name clashes with
37
 * struct ucontext from sys/ucontext.h so this private copy is used.  */
38
typedef struct _sig_ucontext {
39
    unsigned long         uc_flags;
40
    struct _sig_ucontext  *uc_link;
41
    stack_t               uc_stack;
42
    struct sigcontext uc_mcontext;
43
    sigset_t      uc_sigmask;
44
} _sig_ucontext_t;
45
 
46
#define MD_FALLBACK_FRAME_STATE_FOR mips_fallback_frame_state
47
 
48
static _Unwind_Reason_Code
49
mips_fallback_frame_state (struct _Unwind_Context *context,
50
                           _Unwind_FrameState *fs)
51
{
52
  u_int32_t *pc = (u_int32_t *) context->ra;
53
  struct sigcontext *sc;
54
  _Unwind_Ptr new_cfa;
55
  int i;
56
 
57
  /* 24021061 li v0, 0x1061 (rt_sigreturn)*/
58
  /* 0000000c syscall    */
59
  /*    or */
60
  /* 24021017 li v0, 0x1017 (sigreturn) */
61
  /* 0000000c syscall  */
62
  if (*(pc + 1) != 0x0000000c)
63
    return _URC_END_OF_STACK;
64
  if (*(pc + 0) == 0x24021017)
65
    {
66
      struct sigframe {
67
        u_int32_t  trampoline[2];
68
        struct sigcontext sigctx;
69
      } *rt_ = context->ra;
70
      sc = &rt_->sigctx;
71
    }
72
  else if (*(pc + 0) == 0x24021061)
73
    {
74
      struct rt_sigframe {
75
        u_int32_t  trampoline[2];
76
        struct siginfo info;
77
        _sig_ucontext_t uc;
78
      } *rt_ = context->ra;
79
      sc = &rt_->uc.uc_mcontext;
80
    }
81
  else
82
    return _URC_END_OF_STACK;
83
 
84
  new_cfa = (_Unwind_Ptr)sc;
85
  fs->cfa_how = CFA_REG_OFFSET;
86
  fs->cfa_reg = STACK_POINTER_REGNUM;
87
  fs->cfa_offset = new_cfa - (_Unwind_Ptr) context->cfa;
88
 
89
#if _MIPS_SIM == _ABIO32 && defined __MIPSEB__
90
  /* On o32 Linux, the register save slots in the sigcontext are
91
     eight bytes.  We need the lower half of each register slot,
92
     so slide our view of the structure back four bytes.  */
93
  new_cfa -= 4;
94
#endif
95
 
96
  for (i = 0; i < 32; i++) {
97
    fs->regs.reg[i].how = REG_SAVED_OFFSET;
98
    fs->regs.reg[i].loc.offset
99
      = (_Unwind_Ptr)&(sc->sc_regs[i]) - new_cfa;
100
  }
101
  fs->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].how = REG_SAVED_OFFSET;
102
  fs->regs.reg[SIGNAL_UNWIND_RETURN_COLUMN].loc.offset
103
    = (_Unwind_Ptr)&(sc->sc_pc) - new_cfa;
104
  fs->retaddr_column = SIGNAL_UNWIND_RETURN_COLUMN;
105
 
106
  return _URC_NO_REASON;
107
}
108
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.