source: rtems/c/src/librdbg/src/m68k/excep_f.c @ 0bc2339

4.104.114.84.95
Last change on this file since 0bc2339 was 40cf43ea, checked in by Joel Sherrill <joel.sherrill@…>, on 02/01/02 at 17:00:01
  • So many patches have been posted recently on the mailing list and because we were unable to find correct solution to compile on various linux distros (due to rpcgen incompatibilities), and because the coding style of rdbg was rather inconsistant among various pieces of code, I decided to:

1) make some cleaning regarding global coding style (using

indent + manual edits),

2) incorporate/review the paches send by various people

(S. Holford, T. Strauman),

3) Fix the bug due to varying rpcgen code generation

in remdeb_svc.c,

4) Remove some dead code,
5) Apply a patches enabling to call enterRdbg imediately

after rdbg initialization is done,

NB : the paches is huge but it is mainly due to coding styke chnages.
Only few lines of codes have been really changed and they do not impact
rdbg functionnality (AFAIKT).

  • include/rdbg/servrpc.h, include/rdbg/i386/rdbg_f.h, include/rdbg/m68k/rdbg_f.h, include/rdbg/powerpc/rdbg_f.h, src/_servtgt.c, src/awk.svc, src/excep.c, src/ptrace.c, src/rdbg.c, src/remdeb.x, src/servbkpt.c, src/servcon.c, src/servrpc.c, src/servtgt.c, src/servtsp.c, src/servutil.c, src/i386/excep_f.c, src/i386/rdbg_f.c, src/i386/any/Makefile.am, src/i386/any/remdeb.h, src/i386/any/remdeb_svc.c, src/i386/any/remdeb_xdr.c, src/m68k/excep_f.c, src/m68k/rdbg_f.c, src/m68k/any/Makefile.am, src/m68k/any/remdeb.h, src/m68k/any/remdeb_svc.c, src/m68k/any/remdeb_xdr.c, src/powerpc/excep_f.c, src/powerpc/rdbg_f.c, src/powerpc/new_exception_processing/Makefile.am, src/powerpc/new_exception_processing/remdeb.h, src/powerpc/new_exception_processing/remdeb_svc.c, src/powerpc/new_exception_processing/remdeb_xdr.c: Modified.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/m68k/excep_f.c
7 *
8 * $Id$
9 *
10 **************************************************************************
11 */
12
13#include <rtems.h>
14#include <rtems/error.h>
15#include <assert.h>
16#include <errno.h>
17#include <rdbg/rdbg.h>
18#include <rdbg/servrpc.h>
19
20  int
21ExcepToSig (Exception_context * ctx)
22{
23  int excep = getExcNum (ctx);
24
25  switch (excep) {
26  case 2:
27    return 10;
28    break;                      /* bus error           */
29  case 3:
30    return 10;
31    break;                      /* address error       */
32  case 4:
33    return 4;
34    break;                      /* illegal instruction */
35  case 5:
36    return 8;
37    break;                      /* zero divide         */
38  case 6:
39    return 8;
40    break;                      /* chk instruction     */
41  case 7:
42    return 8;
43    break;                      /* trapv instruction   */
44  case 8:
45    return 11;
46    break;                      /* privilege violation */
47  case 9:
48    return 5;
49    break;                      /* trace trap          */
50  case 10:
51    return 4;
52    break;                      /* line 1010 emulator  */
53  case 11:
54    return 4;
55    break;                      /* line 1111 emulator  */
56
57    /*
58     * Coprocessor protocol violation.  Using a standard MMU or FPU
59     * this cannot be triggered by software.  Call it a SIGBUS. 
60     */
61  case 13:
62    return 10;
63    break;
64
65  case 31:
66    return 2;
67    break;                      /* interrupt           */
68  case 33:
69    return 5;
70    break;                      /* monitor breakpoint  */
71  case 34:
72    return 2;
73    break;                      /* lets use this for SCC1 interrupt */
74  case 35:
75    return 5;
76    break;                      /* rdbg breakpoint  */
77  case 36:
78    return 2;
79    break;                      /* enter RDBG */
80    /*
81     * This is a trap #8 instruction.  Apparently it is someone's software
82     * convention for some sort of SIGFPE condition.  Whose?  How many
83     * people are being screwed by having this code the way it is?
84     * Is there a clean solution? 
85     */
86  case 40:
87    return 8;
88    break;                      /* floating point err  */
89
90  case 47:
91    return 5;
92    break;                      /* rdbg breakpoint  */
93
94  case 48:
95    return 8;
96    break;                      /* floating point err  */
97  case 49:
98    return 8;
99    break;                      /* floating point err  */
100  case 50:
101    return 8;
102    break;                      /* zero divide         */
103  case 51:
104    return 8;
105    break;                      /* underflow           */
106  case 52:
107    return 8;
108    break;                      /* operand error       */
109  case 53:
110    return 8;
111    break;                      /* overflow            */
112  case 54:
113    return 8;
114    break;                      /* NAN                 */
115  default:
116    return 7;                   /* "software generated" */
117  }
118  return SIGKILL;
119}
120
121/*----- Breakpoint Exception management -----*/
122
123    /*
124     *  Handler for Breakpoint Exceptions :
125     *  software breakpoints.
126     */
127
128  void
129BreakPointExcHdl (CPU_Exception_frame * ctx)
130{
131  rtems_status_code status;
132  rtems_id continueSemId;
133
134  connect_rdbg_exception ();    /* monitor stub changes trace vector */
135  if ((justSaveContext) && (ctx->vecnum == 47)) {   /* break */
136    PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
137    justSaveContext = 0;
138  } else {
139    if (ctx->vecnum != 9) {     /* trace */
140      NbSerializedCtx++;
141      rtems_semaphore_obtain (serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
142      NbSerializedCtx--;
143    }
144
145    currentTargetThread = _Thread_Executing->Object.id;
146
147#ifdef DDEBUG
148    printk ("----------------------------------------------------------\n");
149    printk ("Exception %d caught at PC %x by thread %d\n",
150            ctx->vecnum, ctx->pc, _Thread_Executing->Object.id);
151    printk ("----------------------------------------------------------\n");
152    printk ("Processor execution context at time of the fault was  :\n");
153    printk ("----------------------------------------------------------\n");
154    printk ("\t A0 = %x\n", ctx->a0);
155    printk ("\t A1 = %x\n", ctx->a1);
156    printk ("\t A2 = %x\n", ctx->a2);
157    printk ("\t A3 = %x\n", ctx->a3);
158    printk ("\t A4 = %x\n", ctx->a4);
159    printk ("\t A5 = %x\n", ctx->a5);
160    printk ("\t A6 = %x\n", ctx->a6);
161    printk ("\t A7 = %x\n", ctx->a7);
162    printk ("\t D0 = %x\n", ctx->d0);
163    printk ("\t D1 = %x\n", ctx->d1);
164    printk ("\t D2 = %x\n", ctx->d2);
165    printk ("\t D3 = %x\n", ctx->d3);
166    printk ("\t D4 = %x\n", ctx->d4);
167    printk ("\t D5 = %x\n", ctx->d5);
168    printk ("\t D6 = %x\n", ctx->d6);
169    printk ("\t D7 = %x\n", ctx->d7);
170    printk ("\t SR = %x\n", ctx->sr);
171#endif
172
173    status = rtems_semaphore_create (rtems_build_name ('D', 'B', 'G', 'c'),
174                                     0,
175                                     RTEMS_FIFO |
176                                     RTEMS_COUNTING_SEMAPHORE |
177                                     RTEMS_NO_INHERIT_PRIORITY |
178                                     RTEMS_NO_PRIORITY_CEILING |
179                                     RTEMS_LOCAL, 0, &continueSemId);
180    if (status != RTEMS_SUCCESSFUL)
181      rtems_panic ("Can't create continue semaphore: `%s'\n",
182                   rtems_status_text (status));
183
184    PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
185
186    switch (ctx->vecnum) {
187    case 9:                    /* trace */
188      DPRINTF ((" TRACE EXCEPTION !!!\n"));
189      ctx->sr &= ~(1 << 15);
190      ExitForSingleStep--;
191      rtems_semaphore_release (wakeupEventSemId);
192      break;
193
194    case 47:                   /* trap #15 */
195      DPRINTF ((" BREAKPOINT EXCEPTION !!!\n"));
196      rtems_semaphore_release (wakeupEventSemId);
197      break;
198
199    case 36:                   /* trap #4 */
200      DPRINTF ((" ENTER RDBG !!!\n"));
201      rtems_semaphore_release (wakeupEventSemId);
202      break;
203
204    default:
205      DPRINTF ((" OTHER EXCEPTION !!!\n"));
206      rtems_semaphore_release (wakeupEventSemId);
207      break;
208    }
209
210    rtems_semaphore_obtain (continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
211
212    PopExceptCtx (_Thread_Executing->Object.id);
213    rtems_semaphore_delete (continueSemId);
214  }
215
216  connect_rdbg_exception ();    /* monitor stub changes trace vector */
217}
Note: See TracBrowser for help on using the repository browser.