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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* DWARF2 EH unwinding support for S/390 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 it under
7
the terms of the GNU General Public License as published by the Free
8
Software Foundation; either version 2, or (at your option) any later
9
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, but WITHOUT ANY
20
WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
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 the Free
26
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
27
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
#define MD_FALLBACK_FRAME_STATE_FOR s390_fallback_frame_state
33
 
34
static _Unwind_Reason_Code
35
s390_fallback_frame_state (struct _Unwind_Context *context,
36
                           _Unwind_FrameState *fs)
37
{
38
  unsigned char *pc = context->ra;
39
  long new_cfa;
40
  int i;
41
 
42
  typedef struct
43
  {
44
    unsigned long psw_mask;
45
    unsigned long psw_addr;
46
    unsigned long gprs[16];
47
    unsigned int  acrs[16];
48
    unsigned int  fpc;
49
    unsigned int  __pad;
50
    double        fprs[16];
51
  } __attribute__ ((__aligned__ (8))) sigregs_;
52
 
53
  sigregs_ *regs;
54
  int *signo = NULL;
55
 
56
  /* svc $__NR_sigreturn or svc $__NR_rt_sigreturn  */
57
  if (pc[0] != 0x0a || (pc[1] != 119 && pc[1] != 173))
58
    return _URC_END_OF_STACK;
59
 
60
  /* New-style RT frame:
61
     retcode + alignment (8 bytes)
62
     siginfo (128 bytes)
63
     ucontext (contains sigregs)  */
64
  if (context->ra == context->cfa)
65
    {
66
      struct ucontext_
67
      {
68
        unsigned long     uc_flags;
69
        struct ucontext_ *uc_link;
70
        unsigned long     uc_stack[3];
71
        sigregs_          uc_mcontext;
72
      } *uc = context->cfa + 8 + 128;
73
 
74
      regs = &uc->uc_mcontext;
75
      signo = context->cfa + sizeof(long);
76
    }
77
 
78
  /* Old-style RT frame and all non-RT frames:
79
     old signal mask (8 bytes)
80
     pointer to sigregs  */
81
  else
82
    {
83
      regs = *(sigregs_ **)(context->cfa + 8);
84
 
85
      /* Recent kernels store the signal number immediately after
86
         the sigregs; old kernels have the return trampoline at
87
         this location.  */
88
      if ((void *)(regs + 1) != context->ra)
89
        signo = (int *)(regs + 1);
90
    }
91
 
92
  new_cfa = regs->gprs[15] + 16*sizeof(long) + 32;
93
  fs->cfa_how = CFA_REG_OFFSET;
94
  fs->cfa_reg = 15;
95
  fs->cfa_offset =
96
    new_cfa - (long) context->cfa + 16*sizeof(long) + 32;
97
 
98
  for (i = 0; i < 16; i++)
99
    {
100
      fs->regs.reg[i].how = REG_SAVED_OFFSET;
101
      fs->regs.reg[i].loc.offset =
102
        (long)&regs->gprs[i] - new_cfa;
103
    }
104
  for (i = 0; i < 16; i++)
105
    {
106
      fs->regs.reg[16+i].how = REG_SAVED_OFFSET;
107
      fs->regs.reg[16+i].loc.offset =
108
        (long)&regs->fprs[i] - new_cfa;
109
    }
110
 
111
  /* Load return addr from PSW into dummy register 32.  */
112
 
113
  fs->regs.reg[32].how = REG_SAVED_OFFSET;
114
  fs->regs.reg[32].loc.offset = (long)&regs->psw_addr - new_cfa;
115
  fs->retaddr_column = 32;
116
 
117
  /* If we got a SIGSEGV or a SIGBUS, the PSW address points *to*
118
     the faulting instruction, not after it.  This causes the logic
119
     in unwind-dw2.c that decrements the RA to determine the correct
120
     CFI region to get confused.  To fix that, we *increment* the RA
121
     here in that case.  Note that we cannot modify the RA in place,
122
     and the frame state wants a *pointer*, not a value; thus we put
123
     the modified RA value into the unused register 33 slot of FS and
124
     have the register 32 save address point to that slot.
125
 
126
     Unfortunately, for regular signals on old kernels, we don't know
127
     the signal number.  We default to not fiddling with the RA;
128
     that can fail in rare cases.  Upgrade your kernel.  */
129
 
130
  if (signo && (*signo == 11 || *signo == 7))
131
    {
132
      fs->regs.reg[33].loc.exp =
133
        (unsigned char *)regs->psw_addr + 1;
134
      fs->regs.reg[32].loc.offset =
135
        (long)&fs->regs.reg[33].loc.exp - new_cfa;
136
    }
137
 
138
  return _URC_NO_REASON;
139
}

powered by: WebSVN 2.1.0

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