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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [gdb-events.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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