source: rtems/c/src/librdbg/src/excep.c @ 40cf43ea

4.104.114.84.95
Last change on this file since 40cf43ea 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: 2.8 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbgexcep.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
20unsigned int NbExceptCtx;
21volatile unsigned int NbSerializedCtx;
22Exception_context *FirstCtx = NULL;
23Exception_context *LastCtx = NULL;
24
25CPU_Exception_frame SavedContext;
26
27/*
28 * Save an exception context at the end of a list
29 */
30
31  int
32PushExceptCtx (Objects_Id Id, Objects_Id semId, CPU_Exception_frame * ctx)
33{
34
35  Exception_context *SaveCtx;
36
37  SaveCtx = (Exception_context *) malloc (sizeof (Exception_context));
38  if (SaveCtx == NULL)
39    rtems_panic ("Can't allocate memory to save Exception context");
40
41  SaveCtx->id = Id;
42  SaveCtx->ctx = ctx;
43  SaveCtx->semaphoreId = semId;
44  SaveCtx->previous = NULL;
45  SaveCtx->next = NULL;
46
47  if (FirstCtx == NULL) {       /* initialization */
48    FirstCtx = SaveCtx;
49    LastCtx = SaveCtx;
50    NbExceptCtx = 1;
51  } else {
52    NbExceptCtx++;
53    LastCtx->next = SaveCtx;
54    SaveCtx->previous = LastCtx;
55    LastCtx = SaveCtx;
56  }
57  return 0;
58}
59
60/*
61 * Save an temporary exception context in a global variable
62 */
63
64  int
65PushSavedExceptCtx (Objects_Id Id, CPU_Exception_frame * ctx)
66{
67  memcpy (&(SavedContext), ctx, sizeof (CPU_Exception_frame));
68  return 0;
69}
70
71/*
72 * Remove the context of the specified Id thread.
73 * If Id = -1, then return the first context
74 */
75
76  int
77PopExceptCtx (Objects_Id Id)
78{
79
80  Exception_context *ExtractCtx;
81
82  if (FirstCtx == NULL)
83    return -1;
84
85  if (Id == -1) {
86    ExtractCtx = LastCtx;
87    LastCtx = LastCtx->previous;
88    free (ExtractCtx);
89    NbExceptCtx--;
90    return 0;
91  }
92
93  ExtractCtx = LastCtx;
94
95  while (ExtractCtx->id != Id && ExtractCtx != NULL) {
96    ExtractCtx = ExtractCtx->previous;
97  }
98
99  if (ExtractCtx == NULL)
100    return -1;
101
102  if (ExtractCtx->previous != NULL)
103    (ExtractCtx->previous)->next = ExtractCtx->next;
104
105  if (ExtractCtx->next != NULL)
106    (ExtractCtx->next)->previous = ExtractCtx->previous;
107
108  if (ExtractCtx == FirstCtx)
109    FirstCtx = FirstCtx->next;
110  else if (ExtractCtx == LastCtx)
111    LastCtx = LastCtx->previous;
112
113  free (ExtractCtx);
114  NbExceptCtx--;
115  return 0;
116}
117
118/*
119 * Return the context of the specified Id thread.
120 * If Id = -1, then return the first context.
121 */
122
123  Exception_context *
124GetExceptCtx (Objects_Id Id)
125{
126
127  Exception_context *ExtractCtx;
128
129  if (FirstCtx == NULL)
130    return NULL;
131
132  if (Id == -1) {
133    return LastCtx;
134  }
135
136  ExtractCtx = LastCtx;
137
138  while (ExtractCtx->id != Id && ExtractCtx != NULL) {
139    ExtractCtx = ExtractCtx->previous;
140  }
141
142  if (ExtractCtx == NULL)
143    return NULL;
144
145  return ExtractCtx;
146}
Note: See TracBrowser for help on using the repository browser.