source: rtems/c/src/librdbg/src/i386/rdbg_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 Feb 1, 2002 at 5:00:01 PM
  • 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: 3.9 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/i386/rdbg_f.c
7 *
8 * $Id$
9 *
10 **************************************************************************
11 */
12
13#include <assert.h>
14#include <errno.h>
15#include <rdbg/reg.h>
16#include <rdbg/remdeb.h>
17#include <rdbg/rdbg.h>
18#include <rtems/score/cpu.h>
19#include <rtems/score/thread.h>
20
21  void
22CtxToRegs (const CPU_Exception_frame * ctx, xdr_regs * regs)
23{
24  regs->tabreg[GS] = 0;
25  regs->tabreg[FS] = 0;
26  regs->tabreg[ES] = 0;
27  regs->tabreg[DS] = 0;
28  regs->tabreg[EDI] = ctx->edi;
29  regs->tabreg[ESI] = ctx->esi;
30  regs->tabreg[EBP] = ctx->ebp;
31  regs->tabreg[ESP] = ctx->esp0;
32  regs->tabreg[EBX] = ctx->ebx;
33  regs->tabreg[EDX] = ctx->edx;
34  regs->tabreg[ECX] = ctx->ecx;
35  regs->tabreg[EAX] = ctx->eax;
36  regs->tabreg[TRAPNO] = ctx->idtIndex;
37  regs->tabreg[ERR] = ctx->faultCode;
38  regs->tabreg[EIP] = ctx->eip;
39  regs->tabreg[CS] = ctx->cs & 0xFFFF;
40  regs->tabreg[EFL] = ctx->eflags;
41}
42
43  void
44RegsToCtx (const xdr_regs * regs, CPU_Exception_frame * ctx)
45{
46  ctx->edi = regs->tabreg[EDI];
47  ctx->esi = regs->tabreg[ESI];
48  ctx->ebp = regs->tabreg[EBP];
49  ctx->esp0 = regs->tabreg[ESP];
50  ctx->ebx = regs->tabreg[EBX];
51  ctx->edx = regs->tabreg[EDX];
52  ctx->ecx = regs->tabreg[ECX];
53  ctx->eax = regs->tabreg[EAX];
54  ctx->idtIndex = regs->tabreg[TRAPNO];
55  ctx->faultCode = regs->tabreg[ERR];
56  ctx->eip = regs->tabreg[EIP];
57  ctx->cs = regs->tabreg[CS];
58  ctx->eflags = regs->tabreg[EFL];
59}
60
61  void
62get_ctx_thread (Thread_Control * thread, CPU_Exception_frame * ctx)
63{
64  ctx->edi = thread->Registers.edi;
65  ctx->esi = thread->Registers.esi;
66  ctx->ebp = (unsigned32) (thread->Registers.ebp);
67  ctx->esp0 = (unsigned32) (thread->Registers.esp);
68  ctx->ebx = thread->Registers.ebx;
69  ctx->edx = 0;
70  ctx->ecx = 0;
71  ctx->eax = 0;
72  ctx->idtIndex = 0;
73  ctx->faultCode = 0;
74  ctx->eip = *(unsigned int *) (thread->Registers.esp);
75  ctx->cs = 0;
76  ctx->eflags = thread->Registers.eflags;
77}
78
79  void
80set_ctx_thread (Thread_Control * thread, CPU_Exception_frame * ctx)
81{
82  thread->Registers.edi = ctx->edi;
83  thread->Registers.esi = ctx->esi;
84  thread->Registers.ebp = (void *) (ctx->ebp);
85  thread->Registers.esp = (void *) (ctx->esp0);
86  thread->Registers.ebx = ctx->ebx;
87  thread->Registers.eflags = ctx->eflags;
88}
89
90  int
91Single_Step (CPU_Exception_frame * ctx)
92{
93  /*
94   * Check if not already set
95   */
96  if ((ctx->eflags & EFLAGS_TF) != 0 || ExitForSingleStep != 0) {
97    /*
98     * Check coherency
99     */
100    assert ((ctx->eflags & EFLAGS_TF) != 0);
101    assert (ExitForSingleStep != 0);
102    return 0;
103  }
104  ctx->eflags |= EFLAGS_TF;     /* eflags */
105  ++ExitForSingleStep;
106
107  return 0;
108}
109
110  int
111CheckForSingleStep (CPU_Exception_frame * ctx)
112{
113  if (ExitForSingleStep) {
114    /*
115     *  This functions can be called both from
116     *  INT1 and INT3 handlers. In case it is
117     *  called from INT3, need to clear TF.
118     */
119    ctx->eflags &= ~EFLAGS_TF;
120    ExitForSingleStep = 0;
121    return 1;
122  }
123  return 0;
124}
125
126  void
127CancelSingleStep (CPU_Exception_frame * ctx)
128{
129  /*
130   * Cancel scheduled SS
131   */
132  ctx->eflags &= ~EFLAGS_TF;
133  ExitForSingleStep--;
134}
135
136static cpuExcHandlerType old_currentExcHandler;
137extern void rtems_exception_prologue_50 ();
138
139  void
140connect_rdbg_exception ()
141{
142  interrupt_gate_descriptor *currentIdtEntry;
143  unsigned limit;
144  unsigned level;
145
146  /*
147   *  Connect the Exception used to debug
148   */
149  i386_get_info_from_IDTR (&currentIdtEntry, &limit);
150
151  _CPU_ISR_Disable (level);
152  create_interrupt_gate_descriptor (&currentIdtEntry[50],
153                                    rtems_exception_prologue_50);
154  _CPU_ISR_Enable (level);
155
156  if (_currentExcHandler != BreakPointExcHdl) {
157    old_currentExcHandler = _currentExcHandler;
158    _currentExcHandler = BreakPointExcHdl;
159  }
160}
161
162  void
163disconnect_rdbg_exception ()
164{
165  if (_currentExcHandler == BreakPointExcHdl) {
166    _currentExcHandler = old_currentExcHandler;
167  }
168}
Note: See TracBrowser for help on using the repository browser.