OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdb-events.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* User Interface Events.
2
   Copyright 1999, 2001 Free Software Foundation, Inc.
3
 
4
   Contributed by Cygnus Solutions.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
 
22
/* Work in progress */
23
 
24
/* This file was created with the aid of ``gdb-events.sh''.
25
 
26
   The bourn shell script ``gdb-events.sh'' creates the files
27
   ``new-gdb-events.c'' and ``new-gdb-events.h and then compares
28
   them against the existing ``gdb-events.[hc]''.  Any differences
29
   found being reported.
30
 
31
   If editing this file, please also run gdb-events.sh and merge any
32
   changes into that script. Conversely, when making sweeping changes
33
   to this file, modifying gdb-events.sh and using its output may
34
   prove easier. */
35
 
36
 
37
#include "defs.h"
38
#include "gdb-events.h"
39
#include "gdbcmd.h"
40
 
41
#undef XMALLOC
42
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
43
 
44
#if WITH_GDB_EVENTS
45
static struct gdb_events null_event_hooks;
46
static struct gdb_events queue_event_hooks;
47
static struct gdb_events *current_event_hooks = &null_event_hooks;
48
#endif
49
 
50
int gdb_events_debug;
51
 
52
#if WITH_GDB_EVENTS
53
 
54
void
55
breakpoint_create_event (int b)
56
{
57
  if (gdb_events_debug)
58
    fprintf_unfiltered (gdb_stdlog, "breakpoint_create_event\n");
59
  if (!current_event_hooks->breakpoint_create)
60
    return;
61
  current_event_hooks->breakpoint_create (b);
62
}
63
 
64
void
65
breakpoint_delete_event (int b)
66
{
67
  if (gdb_events_debug)
68
    fprintf_unfiltered (gdb_stdlog, "breakpoint_delete_event\n");
69
  if (!current_event_hooks->breakpoint_delete)
70
    return;
71
  current_event_hooks->breakpoint_delete (b);
72
}
73
 
74
void
75
breakpoint_modify_event (int b)
76
{
77
  if (gdb_events_debug)
78
    fprintf_unfiltered (gdb_stdlog, "breakpoint_modify_event\n");
79
  if (!current_event_hooks->breakpoint_modify)
80
    return;
81
  current_event_hooks->breakpoint_modify (b);
82
}
83
 
84
void
85
tracepoint_create_event (int number)
86
{
87
  if (gdb_events_debug)
88
    fprintf_unfiltered (gdb_stdlog, "tracepoint_create_event\n");
89
  if (!current_event_hooks->tracepoint_create)
90
    return;
91
  current_event_hooks->tracepoint_create (number);
92
}
93
 
94
void
95
tracepoint_delete_event (int number)
96
{
97
  if (gdb_events_debug)
98
    fprintf_unfiltered (gdb_stdlog, "tracepoint_delete_event\n");
99
  if (!current_event_hooks->tracepoint_delete)
100
    return;
101
  current_event_hooks->tracepoint_delete (number);
102
}
103
 
104
void
105
tracepoint_modify_event (int number)
106
{
107
  if (gdb_events_debug)
108
    fprintf_unfiltered (gdb_stdlog, "tracepoint_modify_event\n");
109
  if (!current_event_hooks->tracepoint_modify)
110
    return;
111
  current_event_hooks->tracepoint_modify (number);
112
}
113
 
114
#endif
115
 
116
#if WITH_GDB_EVENTS
117
struct gdb_events *
118
set_gdb_event_hooks (struct gdb_events *vector)
119
{
120
  struct gdb_events *old_events = current_event_hooks;
121
  if (vector == NULL)
122
    current_event_hooks = &queue_event_hooks;
123
  else
124
    current_event_hooks = vector;
125
  return old_events;
126
}
127
#endif
128
 
129
enum gdb_event
130
{
131
  breakpoint_create,
132
  breakpoint_delete,
133
  breakpoint_modify,
134
  tracepoint_create,
135
  tracepoint_delete,
136
  tracepoint_modify,
137
  nr_gdb_events
138
};
139
 
140
struct breakpoint_create
141
  {
142
    int b;
143
  };
144
 
145
struct breakpoint_delete
146
  {
147
    int b;
148
  };
149
 
150
struct breakpoint_modify
151
  {
152
    int b;
153
  };
154
 
155
struct tracepoint_create
156
  {
157
    int number;
158
  };
159
 
160
struct tracepoint_delete
161
  {
162
    int number;
163
  };
164
 
165
struct tracepoint_modify
166
  {
167
    int number;
168
  };
169
 
170
struct event
171
  {
172
    enum gdb_event type;
173
    struct event *next;
174
    union
175
      {
176
        struct breakpoint_create breakpoint_create;
177
        struct breakpoint_delete breakpoint_delete;
178
        struct breakpoint_modify breakpoint_modify;
179
        struct tracepoint_create tracepoint_create;
180
        struct tracepoint_delete tracepoint_delete;
181
        struct tracepoint_modify tracepoint_modify;
182
      }
183
    data;
184
  };
185
struct event *pending_events;
186
struct event *delivering_events;
187
 
188
static void
189
append (struct event *new_event)
190
{
191
  struct event **event = &pending_events;
192
  while ((*event) != NULL)
193
    event = &((*event)->next);
194
  (*event) = new_event;
195
  (*event)->next = NULL;
196
}
197
 
198
static void
199
queue_breakpoint_create (int b)
200
{
201
  struct event *event = XMALLOC (struct event);
202
  event->type = breakpoint_create;
203
  event->data.breakpoint_create.b = b;
204
  append (event);
205
}
206
 
207
static void
208
queue_breakpoint_delete (int b)
209
{
210
  struct event *event = XMALLOC (struct event);
211
  event->type = breakpoint_delete;
212
  event->data.breakpoint_delete.b = b;
213
  append (event);
214
}
215
 
216
static void
217
queue_breakpoint_modify (int b)
218
{
219
  struct event *event = XMALLOC (struct event);
220
  event->type = breakpoint_modify;
221
  event->data.breakpoint_modify.b = b;
222
  append (event);
223
}
224
 
225
static void
226
queue_tracepoint_create (int number)
227
{
228
  struct event *event = XMALLOC (struct event);
229
  event->type = tracepoint_create;
230
  event->data.tracepoint_create.number = number;
231
  append (event);
232
}
233
 
234
static void
235
queue_tracepoint_delete (int number)
236
{
237
  struct event *event = XMALLOC (struct event);
238
  event->type = tracepoint_delete;
239
  event->data.tracepoint_delete.number = number;
240
  append (event);
241
}
242
 
243
static void
244
queue_tracepoint_modify (int number)
245
{
246
  struct event *event = XMALLOC (struct event);
247
  event->type = tracepoint_modify;
248
  event->data.tracepoint_modify.number = number;
249
  append (event);
250
}
251
 
252
void
253
gdb_events_deliver (struct gdb_events *vector)
254
{
255
  /* Just zap any events left around from last time. */
256
  while (delivering_events != NULL)
257
    {
258
      struct event *event = delivering_events;
259
      delivering_events = event->next;
260
      xfree (event);
261
    }
262
  /* Process any pending events.  Because one of the deliveries could
263
     bail out we move everything off of the pending queue onto an
264
     in-progress queue where it can, later, be cleaned up if
265
     necessary. */
266
  delivering_events = pending_events;
267
  pending_events = NULL;
268
  while (delivering_events != NULL)
269
    {
270
      struct event *event = delivering_events;
271
      switch (event->type)
272
        {
273
        case breakpoint_create:
274
          vector->breakpoint_create
275
            (event->data.breakpoint_create.b);
276
          break;
277
        case breakpoint_delete:
278
          vector->breakpoint_delete
279
            (event->data.breakpoint_delete.b);
280
          break;
281
        case breakpoint_modify:
282
          vector->breakpoint_modify
283
            (event->data.breakpoint_modify.b);
284
          break;
285
        case tracepoint_create:
286
          vector->tracepoint_create
287
            (event->data.tracepoint_create.number);
288
          break;
289
        case tracepoint_delete:
290
          vector->tracepoint_delete
291
            (event->data.tracepoint_delete.number);
292
          break;
293
        case tracepoint_modify:
294
          vector->tracepoint_modify
295
            (event->data.tracepoint_modify.number);
296
          break;
297
        }
298
      delivering_events = event->next;
299
      xfree (event);
300
    }
301
}
302
 
303
void _initialize_gdb_events (void);
304
void
305
_initialize_gdb_events (void)
306
{
307
  struct cmd_list_element *c;
308
#if WITH_GDB_EVENTS
309
  queue_event_hooks.breakpoint_create = queue_breakpoint_create;
310
  queue_event_hooks.breakpoint_delete = queue_breakpoint_delete;
311
  queue_event_hooks.breakpoint_modify = queue_breakpoint_modify;
312
  queue_event_hooks.tracepoint_create = queue_tracepoint_create;
313
  queue_event_hooks.tracepoint_delete = queue_tracepoint_delete;
314
  queue_event_hooks.tracepoint_modify = queue_tracepoint_modify;
315
#endif
316
 
317
  c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger,
318
                   (char *) (&gdb_events_debug), "Set event debugging.\n\
319
When non-zero, event/notify debugging is enabled.", &setlist);
320
  deprecate_cmd (c, "set debug event");
321
  deprecate_cmd (add_show_from_set (c, &showlist), "show debug event");
322
 
323
  add_show_from_set (add_set_cmd ("event",
324
                                  class_maintenance,
325
                                  var_zinteger,
326
                                  (char *) (&gdb_events_debug),
327
                                  "Set event debugging.\n\
328
When non-zero, event/notify debugging is enabled.", &setdebuglist),
329
                     &showdebuglist);
330
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.