source: rtems/c/src/lib/librdbg/powerpc/excep_f.c @ 981b99f

4.104.114.84.95
Last change on this file since 981b99f was 981b99f, checked in by Joel Sherrill <joel.sherrill@…>, on 08/10/99 at 16:41:44

Patch from Eric Valette <valette@…> and Emmanuel Raguet
<raguet@…>:

  • the dec21140 driver code has been hardened (various bug fixed) Emmanuel,
  • bug in the mcp750 init code have been fixed (interrupt stack/initial stack initialization), BSS correctly cleared (Eric V)
  • remote debugging over TCP/IP is nearly complete (berakpoints, backtrace, variables,...) (Eric V),
  • exception handling code has also been improved in order to fully support RDBG requirements (Eric V),
  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/powerpc/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 ASM_FLOAT_VECTOR   : return SIGFPE;
27       
28        case ASM_TRACE_VECTOR   :
29        case ASM_SYS_VECTOR     : return SIGTRAP;
30       
31        case ASM_ISI_VECTOR     : return SIGSEGV;
32       
33        case ASM_PROG_VECTOR    :
34        case ASM_RESET_VECTOR   :
35        case ASM_MACH_VECTOR    :
36        case ASM_EXT_VECTOR     :
37        case ASM_ALIGN_VECTOR   : return SIGILL;
38       
39    default:
40        break;
41    }
42    return SIGKILL;
43}
44
45 
46/*----- Breakpoint Exception management -----*/
47
48    /*
49     *  Handler for Breakpoint Exceptions :
50     *  software breakpoints.
51     */
52
53void
54BreakPointExcHdl(CPU_Exception_frame *ctx)
55{
56  rtems_status_code status;
57  rtems_id continueSemId;
58
59  if ( (justSaveContext) && (ctx->_EXC_number == ASM_SYS_VECTOR) ) {
60    PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
61    justSaveContext = 0;
62  }
63  else {
64    if (ctx->_EXC_number != ASM_TRACE_VECTOR){
65      NbSerializedCtx++;
66      rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
67      NbSerializedCtx--;
68    }
69     
70    currentTargetThread = _Thread_Executing->Object.id;
71
72#ifdef DDEBUG
73    printk("----------------------------------------------------------\n");
74    printk("Exception %d caught at PC %x by thread %d\n",
75           ctx->_EXC_number,
76           ctx->EXC_SRR0,
77           _Thread_Executing->Object.id);
78    printk("----------------------------------------------------------\n");
79    printk("Processor execution context at time of the fault was  :\n");
80    printk("----------------------------------------------------------\n");
81    printk("\t R0 = %x\n", ctx->GPR0);
82    printk("\t R1 = %x\n", ctx->GPR1);
83    printk("\t R2 = %x\n", ctx->GPR2);
84    printk("\t R3 = %x\n", ctx->GPR3);
85    printk("\t R4 = %x\n", ctx->GPR4);
86    printk("\t R5 = %x\n", ctx->GPR5);
87    printk("\t R6 = %x\n", ctx->GPR6);
88    printk("\t R7 = %x\n", ctx->GPR7);
89    printk("\t R8 = %x\n", ctx->GPR8);
90    printk("\t R9 = %x\n", ctx->GPR9);
91    printk("\t R10 = %x\n", ctx->GPR10);
92    printk("\t R11 = %x\n", ctx->GPR11);
93    printk("\t R12 = %x\n", ctx->GPR12);
94    printk("\t R13 = %x\n", ctx->GPR13);
95    printk("\t R14 = %x\n", ctx->GPR14);
96    printk("\t R15 = %x\n", ctx->GPR15);
97    printk("\t R16 = %x\n", ctx->GPR16);
98    printk("\t R17 = %x\n", ctx->GPR17);
99    printk("\t R18 = %x\n", ctx->GPR18);
100    printk("\t R19 = %x\n", ctx->GPR19);
101    printk("\t R20 = %x\n", ctx->GPR20);
102    printk("\t R21 = %x\n", ctx->GPR21);
103    printk("\t R22 = %x\n", ctx->GPR22);
104    printk("\t R23 = %x\n", ctx->GPR23);
105    printk("\t R24 = %x\n", ctx->GPR24);
106    printk("\t R25 = %x\n", ctx->GPR25);
107    printk("\t R26 = %x\n", ctx->GPR26);
108    printk("\t R27 = %x\n", ctx->GPR27);
109    printk("\t R28 = %x\n", ctx->GPR28);
110    printk("\t R29 = %x\n", ctx->GPR29);
111    printk("\t R30 = %x\n", ctx->GPR30);
112    printk("\t R31 = %x\n", ctx->GPR31);
113    printk("\t CR = %x\n", ctx->EXC_CR);
114    printk("\t CTR = %x\n", ctx->EXC_CTR);
115    printk("\t XER = %x\n", ctx->EXC_XER);
116    printk("\t LR = %x\n", ctx->EXC_LR);
117    printk("\t MSR = %x\n", ctx->EXC_MSR);
118#endif
119
120    status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
121                                     0,
122                                     RTEMS_FIFO |
123                                     RTEMS_COUNTING_SEMAPHORE |
124                                     RTEMS_NO_INHERIT_PRIORITY |
125                                     RTEMS_NO_PRIORITY_CEILING |
126                                     RTEMS_LOCAL,
127                                     0,
128                                     &continueSemId);
129    if (status != RTEMS_SUCCESSFUL)
130      rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
131
132    PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
133 
134    switch (ctx->_EXC_number){
135    case ASM_TRACE_VECTOR :
136      DPRINTF((" TRACE EXCEPTION !!!\n"));
137      ctx->EXC_SRR1 &= ~MSR_SE;
138      ExitForSingleStep-- ;
139      rtems_semaphore_release( wakeupEventSemId );
140    break;
141
142    case ASM_PROG_VECTOR :
143      DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
144      rtems_semaphore_release( wakeupEventSemId );
145    break;
146
147    case ASM_SYS_VECTOR :
148      DPRINTF((" ENTER RDBG !!!\n"));
149      rtems_semaphore_release( wakeupEventSemId );
150      break;
151
152    default:
153      DPRINTF((" OTHER EXCEPTION !!!\n"));
154      rtems_semaphore_release( wakeupEventSemId );
155      break;
156    }
157
158    rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
159   
160    PopExceptCtx (_Thread_Executing->Object.id);
161    rtems_semaphore_delete(continueSemId);
162  }
163
164}
165
166
167
Note: See TracBrowser for help on using the repository browser.