source: rtems/c/src/librdbg/src/i386/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: 4.3 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/i386/excep.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/* -----------------------------------------------------------------
21   Maping of hardware exceptions into Unix-like signal numbers.
22   It is identical to the one used by the PM and the AM.
23   ----------------------------------------------------------------- */
24
25  int
26ExcepToSig (Exception_context * ctx)
27{
28  int excep = getExcNum (ctx);
29
30  switch (excep) {
31
32  case I386_EXCEPTION_MATH_COPROC_UNAVAIL:
33  case I386_EXCEPTION_I386_COPROC_SEG_ERR:
34  case I386_EXCEPTION_FLOAT_ERROR:
35  case I386_EXCEPTION_BOUND:
36    return SIGFPE;
37
38  case I386_EXCEPTION_DEBUG:
39  case I386_EXCEPTION_BREAKPOINT:
40  case I386_EXCEPTION_ENTER_RDBG:
41    return SIGTRAP;
42
43  case I386_EXCEPTION_OVERFLOW:
44  case I386_EXCEPTION_DIVIDE_BY_ZERO:
45  case I386_EXCEPTION_ILLEGAL_INSTR:
46    return SIGILL;
47
48  case I386_EXCEPTION_SEGMENT_NOT_PRESENT:
49  case I386_EXCEPTION_STACK_SEGMENT_FAULT:
50  case I386_EXCEPTION_GENERAL_PROT_ERR:
51  case I386_EXCEPTION_PAGE_FAULT:
52    return SIGSEGV;
53
54  default:
55    break;
56  }
57  return SIGKILL;
58}
59
60/*----- Breakpoint Exception management -----*/
61
62    /*
63     *  Handler for Breakpoint Exceptions :
64     *  software breakpoints.
65     */
66
67  void
68BreakPointExcHdl (CPU_Exception_frame * ctx)
69{
70  rtems_status_code status;
71  rtems_id continueSemId;
72
73  if ((justSaveContext) && (ctx->idtIndex == I386_EXCEPTION_ENTER_RDBG)) {
74    PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
75    justSaveContext = 0;
76  } else {
77    if (ctx->idtIndex != I386_EXCEPTION_DEBUG) {
78      NbSerializedCtx++;
79      rtems_semaphore_obtain (serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
80      NbSerializedCtx--;
81    }
82
83    currentTargetThread = _Thread_Executing->Object.id;
84
85#ifdef DDEBUG
86    printk ("----------------------------------------------------------\n");
87    printk ("Exception %d caught at PC %x by thread %d\n",
88            ctx->idtIndex, ctx->eip, _Thread_Executing->Object.id);
89    printk ("----------------------------------------------------------\n");
90    printk ("Processor execution context at time of the fault was  :\n");
91    printk ("----------------------------------------------------------\n");
92    printk (" EAX = %x  EBX = %x        ECX = %x        EDX = %x\n",
93            ctx->eax, ctx->ebx, ctx->ecx, ctx->edx);
94    printk (" ESI = %x  EDI = %x        EBP = %x        ESP = %x\n",
95            ctx->esi, ctx->edi, ctx->ebp, ctx->esp0);
96    printk ("----------------------------------------------------------\n");
97    printk ("Error code pushed by processor itself (if not 0) = %x\n",
98            ctx->faultCode);
99    printk ("----------------------------------------------------------\n\n");
100#endif
101
102    status = rtems_semaphore_create (rtems_build_name ('D', 'B', 'G', 'c'),
103                                     0,
104                                     RTEMS_FIFO |
105                                     RTEMS_COUNTING_SEMAPHORE |
106                                     RTEMS_NO_INHERIT_PRIORITY |
107                                     RTEMS_NO_PRIORITY_CEILING |
108                                     RTEMS_LOCAL, 0, &continueSemId);
109    if (status != RTEMS_SUCCESSFUL)
110      rtems_panic ("Can't create continue semaphore: `%s'\n",
111                   rtems_status_text (status));
112
113    PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
114
115    switch (ctx->idtIndex) {
116    case I386_EXCEPTION_DEBUG:
117      DPRINTF ((" DEBUG EXCEPTION !!!\n"));
118      ctx->eflags &= ~EFLAGS_TF;
119      ExitForSingleStep--;
120      rtems_semaphore_release (wakeupEventSemId);
121      break;
122
123    case I386_EXCEPTION_BREAKPOINT:
124      DPRINTF ((" BREAKPOINT EXCEPTION !!!\n"));
125      rtems_semaphore_release (wakeupEventSemId);
126      break;
127
128    case I386_EXCEPTION_ENTER_RDBG:
129      DPRINTF ((" ENTER RDBG !!!\n"));
130      rtems_semaphore_release (wakeupEventSemId);
131      break;
132
133    default:
134      DPRINTF ((" OTHER EXCEPTION !!!\n"));
135      rtems_semaphore_release (wakeupEventSemId);
136      break;
137    }
138
139    rtems_semaphore_obtain (continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
140
141    PopExceptCtx (_Thread_Executing->Object.id);
142    rtems_semaphore_delete (continueSemId);
143  }
144}
Note: See TracBrowser for help on using the repository browser.