]>
Commit | Line | Data |
---|---|---|
104c1213 JM |
1 | #!/bin/sh |
2 | ||
3 | # User Interface Events. | |
349c5d5f | 4 | # Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
104c1213 JM |
5 | # |
6 | # Contributed by Cygnus Solutions. | |
7 | # | |
8 | # This file is part of GDB. | |
9 | # | |
10 | # This program is free software; you can redistribute it and/or modify | |
11 | # it under the terms of the GNU General Public License as published by | |
12 | # the Free Software Foundation; either version 2 of the License, or | |
13 | # (at your option) any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, | |
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | # GNU General Public License for more details. | |
19 | # | |
20 | # You should have received a copy of the GNU General Public License | |
21 | # along with this program; if not, write to the Free Software | |
22 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 | ||
24 | # | |
25 | # What happens next: | |
26 | # | |
27 | ||
28 | # The gdb-events.h/gdb-events.c files this script generates are commited | |
29 | # and published. | |
30 | ||
31 | # Any UI module that is installing events is changed so that the | |
32 | # events are installed using the ``set_gdb_events()'' and | |
33 | # ``gdb_event_hooks()'' interfaces. There could prove to be an issue | |
34 | # here with respect to annotate. We might need to accomodate a hook | |
35 | # stack that allows several ui blocks to install their own events. | |
36 | ||
4b3cb714 | 37 | # Each of the variable events (as currently generated) is converted |
104c1213 JM |
38 | # to either a straight function call or a function call with a |
39 | # predicate. | |
40 | ||
41 | ||
42 | IFS=: | |
43 | ||
44 | read="class returntype function formal actual attrib" | |
45 | ||
46 | function_list () | |
47 | { | |
48 | # category: | |
49 | # # -> disable | |
50 | # * -> compatibility - pointer variable that is initialized | |
51 | # by set_gdb_events(). | |
52 | # ? -> Predicate and function proper. | |
53 | # f -> always call (must have a void returntype) | |
54 | # return-type | |
55 | # name | |
56 | # formal argument list | |
57 | # actual argument list | |
58 | # attributes | |
59 | # description | |
60 | cat <<EOF | | |
61 | f:void:breakpoint_create:int b:b | |
62 | f:void:breakpoint_delete:int b:b | |
63 | f:void:breakpoint_modify:int b:b | |
ba9fe036 KS |
64 | f:void:tracepoint_create:int number:number |
65 | f:void:tracepoint_delete:int number:number | |
66 | f:void:tracepoint_modify:int number:number | |
67c2c32c | 67 | f:void:architecture_changed:void |
104c1213 JM |
68 | #*:void:annotate_starting_hook:void |
69 | #*:void:annotate_stopped_hook:void | |
70 | #*:void:annotate_signalled_hook:void | |
71 | #*:void:annotate_signal_hook:void | |
72 | #*:void:annotate_exited_hook:void | |
73 | ##*:void:print_register_hook:int | |
74 | ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR | |
75 | ##*:void:sparc_print_register_hook:int regno:regno | |
76 | #*:void:target_resume_hook:void | |
77 | #*:void:target_wait_loop_hook:void | |
78 | #*:void:init_gdb_hook:char *argv0:argv0 | |
79 | #*:void:command_loop_hook:void | |
d9fcf2fb | 80 | #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream |
104c1213 JM |
81 | #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror |
82 | #*:int:query_hook:const char *query, va_list args:query, args | |
83 | #*:void:warning_hook:const char *string, va_list args:string, args | |
104c1213 JM |
84 | #*:void:target_output_hook:char *b:b |
85 | #*:void:interactive_hook:void | |
86 | #*:void:registers_changed_hook:void | |
87 | #*:void:readline_begin_hook:char *format, ...:format | |
88 | #*:char *:readline_hook:char *prompt:prompt | |
89 | #*:void:readline_end_hook:void | |
90 | #*:void:register_changed_hook:int regno:regno | |
91 | #*:void:memory_changed_hook:CORE_ADDR addr, int len:addr, len | |
92 | #*:void:context_hook:int num:num | |
93 | #*:int:target_wait_hook:int pid, struct target_waitstatus *status:pid, status | |
94 | #*:void:call_command_hook:struct cmd_list_element *c, char *cmd, int from_tty:c, cmd, from_tty | |
95 | #*:NORETURN void:error_hook:void:: ATTR_NORETURN | |
96 | #*:void:error_begin_hook:void | |
97 | ##*:int:target_architecture_hook:const struct bfd_arch_info * | |
98 | #*:void:exec_file_display_hook:char *filename:filename | |
99 | #*:void:file_changed_hook:char *filename:filename | |
100 | ##*:void:specify_exec_file_hook: | |
101 | #*:int:gdb_load_progress_hook:char *section, unsigned long num:section, num | |
102 | #*:void:pre_add_symbol_hook:char *name:name | |
103 | #*:void:post_add_symbol_hook:void | |
104 | #*:void:selected_frame_level_changed_hook:int level:level | |
105 | #*:int:gdb_loop_hook:int signo:signo | |
106 | ##*:void:solib_create_inferior_hook:void | |
107 | ##*:void:xcoff_relocate_symtab_hook:unsigned int | |
108 | EOF | |
109 | grep -v '^#' | |
110 | } | |
111 | ||
112 | copyright () | |
113 | { | |
114 | cat <<EOF | |
115 | /* User Interface Events. | |
349c5d5f AC |
116 | |
117 | Copyright 1999, 2001, 2002 Free Software Foundation, Inc. | |
104c1213 JM |
118 | |
119 | Contributed by Cygnus Solutions. | |
120 | ||
afbfc876 | 121 | This file is part of GDB. |
104c1213 | 122 | |
afbfc876 AC |
123 | This program is free software; you can redistribute it and/or modify |
124 | it under the terms of the GNU General Public License as published by | |
125 | the Free Software Foundation; either version 2 of the License, or | |
126 | (at your option) any later version. | |
104c1213 | 127 | |
afbfc876 AC |
128 | This program is distributed in the hope that it will be useful, |
129 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
130 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
131 | GNU General Public License for more details. | |
104c1213 | 132 | |
afbfc876 AC |
133 | You should have received a copy of the GNU General Public License |
134 | along with this program; if not, write to the Free Software | |
135 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
104c1213 JM |
136 | |
137 | /* Work in progress */ | |
138 | ||
139 | /* This file was created with the aid of \`\`gdb-events.sh''. | |
140 | ||
141 | The bourn shell script \`\`gdb-events.sh'' creates the files | |
142 | \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares | |
143 | them against the existing \`\`gdb-events.[hc]''. Any differences | |
144 | found being reported. | |
145 | ||
146 | If editing this file, please also run gdb-events.sh and merge any | |
147 | changes into that script. Conversely, when making sweeping changes | |
148 | to this file, modifying gdb-events.sh and using its output may | |
149 | prove easier. */ | |
150 | ||
151 | EOF | |
152 | } | |
153 | ||
154 | # | |
155 | # The .h file | |
156 | # | |
157 | ||
158 | exec > new-gdb-events.h | |
159 | copyright | |
160 | cat <<EOF | |
161 | ||
162 | #ifndef GDB_EVENTS_H | |
163 | #define GDB_EVENTS_H | |
164 | ||
165 | #ifndef WITH_GDB_EVENTS | |
166 | #define WITH_GDB_EVENTS 1 | |
167 | #endif | |
168 | EOF | |
169 | ||
170 | # pointer declarations | |
171 | echo "" | |
172 | echo "" | |
173 | cat <<EOF | |
174 | /* COMPAT: pointer variables for old, unconverted events. | |
175 | A call to set_gdb_events() will automatically update these. */ | |
176 | EOF | |
177 | echo "" | |
178 | function_list | while eval read $read | |
179 | do | |
180 | case "${class}" in | |
181 | "*" ) | |
182 | echo "extern ${returntype} (*${function}_event) (${formal})${attrib};" | |
183 | ;; | |
184 | esac | |
185 | done | |
186 | ||
187 | # function typedef's | |
188 | echo "" | |
189 | echo "" | |
190 | cat <<EOF | |
191 | /* Type definition of all hook functions. | |
192 | Recommended pratice is to first declare each hook function using | |
193 | the below ftype and then define it. */ | |
194 | EOF | |
195 | echo "" | |
196 | function_list | while eval read $read | |
197 | do | |
198 | echo "typedef ${returntype} (gdb_events_${function}_ftype) (${formal});" | |
199 | done | |
200 | ||
201 | # gdb_events object | |
202 | echo "" | |
203 | echo "" | |
204 | cat <<EOF | |
205 | /* gdb-events: object. */ | |
206 | EOF | |
207 | echo "" | |
208 | echo "struct gdb_events" | |
209 | echo " {" | |
210 | function_list | while eval read $read | |
211 | do | |
212 | echo " gdb_events_${function}_ftype *${function}${attrib};" | |
213 | done | |
214 | echo " };" | |
215 | ||
216 | # function declarations | |
217 | echo "" | |
218 | echo "" | |
219 | cat <<EOF | |
220 | /* Interface into events functions. | |
c4093a6a JM |
221 | Where a *_p() predicate is present, it must be called before |
222 | calling the hook proper. */ | |
104c1213 JM |
223 | EOF |
224 | function_list | while eval read $read | |
225 | do | |
226 | case "${class}" in | |
227 | "*" ) continue ;; | |
228 | "?" ) | |
229 | echo "extern int ${function}_p (void);" | |
230 | echo "extern ${returntype} ${function}_event (${formal})${attrib};" | |
231 | ;; | |
232 | "f" ) | |
233 | echo "extern ${returntype} ${function}_event (${formal})${attrib};" | |
234 | ;; | |
235 | esac | |
236 | done | |
237 | ||
238 | # function macros | |
239 | echo "" | |
240 | echo "" | |
241 | cat <<EOF | |
242 | /* When GDB_EVENTS are not being used, completly disable them. */ | |
243 | EOF | |
244 | echo "" | |
245 | echo "#if !WITH_GDB_EVENTS" | |
246 | function_list | while eval read $read | |
247 | do | |
248 | case "${class}" in | |
249 | "*" ) continue ;; | |
250 | "?" ) | |
251 | echo "#define ${function}_event_p() 0" | |
252 | echo "#define ${function}_event(${actual}) 0" | |
253 | ;; | |
254 | "f" ) | |
255 | echo "#define ${function}_event(${actual}) 0" | |
256 | ;; | |
257 | esac | |
258 | done | |
259 | echo "#endif" | |
260 | ||
261 | # our set function | |
262 | cat <<EOF | |
263 | ||
264 | /* Install custom gdb-events hooks. */ | |
ed9a39eb | 265 | extern struct gdb_events *set_gdb_event_hooks (struct gdb_events *vector); |
104c1213 JM |
266 | |
267 | /* Deliver any pending events. */ | |
268 | extern void gdb_events_deliver (struct gdb_events *vector); | |
269 | ||
270 | #if !WITH_GDB_EVENTS | |
271 | #define set_gdb_events(x) 0 | |
272 | #define set_gdb_event_hooks(x) 0 | |
273 | #define gdb_events_deliver(x) 0 | |
274 | #endif | |
275 | EOF | |
276 | ||
277 | # close it off | |
278 | echo "" | |
279 | echo "#endif" | |
280 | exec 1>&2 | |
281 | #../move-if-change new-gdb-events.h gdb-events.h | |
9e791099 | 282 | if test -r gdb-events.h |
104c1213 | 283 | then |
9e791099 KS |
284 | diff -c gdb-events.h new-gdb-events.h |
285 | if [ $? = 1 ] | |
286 | then | |
287 | echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2 | |
288 | fi | |
289 | else | |
104c1213 | 290 | echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2 |
104c1213 JM |
291 | fi |
292 | ||
293 | ||
294 | ||
295 | # | |
296 | # C file | |
297 | # | |
298 | ||
299 | exec > new-gdb-events.c | |
300 | copyright | |
301 | cat <<EOF | |
302 | ||
303 | #include "defs.h" | |
304 | #include "gdb-events.h" | |
305 | #include "gdbcmd.h" | |
306 | ||
104c1213 JM |
307 | #if WITH_GDB_EVENTS |
308 | static struct gdb_events null_event_hooks; | |
309 | static struct gdb_events queue_event_hooks; | |
310 | static struct gdb_events *current_event_hooks = &null_event_hooks; | |
311 | #endif | |
312 | ||
313 | int gdb_events_debug; | |
314 | EOF | |
315 | ||
316 | # global pointer variables - always have this | |
317 | #echo "" | |
318 | #function_list | while eval read $read | |
319 | #do | |
320 | # case "${class}" in | |
321 | # "*" ) | |
322 | # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;" | |
323 | # ;; | |
324 | # esac | |
325 | #done | |
326 | ||
327 | # function bodies | |
328 | echo "" | |
329 | echo "#if WITH_GDB_EVENTS" | |
330 | function_list | while eval read $read | |
331 | do | |
332 | case "${class}" in | |
333 | "*" ) continue ;; | |
334 | "?" ) | |
9e791099 KS |
335 | cat <<EOF |
336 | ||
337 | int | |
338 | ${function}_event_p (${formal}) | |
339 | { | |
340 | return current_event_hooks->${function}; | |
341 | } | |
342 | ||
343 | ${returntype} | |
344 | ${function}_event (${formal}) | |
345 | { | |
346 | return current_events->${function} (${actual}); | |
347 | } | |
348 | EOF | |
104c1213 JM |
349 | ;; |
350 | "f" ) | |
9e791099 KS |
351 | cat <<EOF |
352 | ||
353 | void | |
354 | ${function}_event (${formal}) | |
355 | { | |
356 | if (gdb_events_debug) | |
8c6ee715 | 357 | fprintf_unfiltered (gdb_stdlog, "${function}_event\n"); |
9e791099 KS |
358 | if (!current_event_hooks->${function}) |
359 | return; | |
360 | current_event_hooks->${function} (${actual}); | |
361 | } | |
362 | EOF | |
104c1213 JM |
363 | ;; |
364 | esac | |
365 | done | |
366 | echo "" | |
367 | echo "#endif" | |
368 | ||
369 | # Set hooks function | |
370 | echo "" | |
371 | cat <<EOF | |
372 | #if WITH_GDB_EVENTS | |
ed9a39eb | 373 | struct gdb_events * |
104c1213 JM |
374 | set_gdb_event_hooks (struct gdb_events *vector) |
375 | { | |
ed9a39eb | 376 | struct gdb_events *old_events = current_event_hooks; |
104c1213 JM |
377 | if (vector == NULL) |
378 | current_event_hooks = &queue_event_hooks; | |
379 | else | |
380 | current_event_hooks = vector; | |
ed9a39eb | 381 | return old_events; |
104c1213 JM |
382 | EOF |
383 | function_list | while eval read $read | |
384 | do | |
385 | case "${class}" in | |
386 | "*" ) | |
387 | echo " ${function}_event = hooks->${function};" | |
388 | ;; | |
389 | esac | |
390 | done | |
391 | cat <<EOF | |
392 | } | |
393 | #endif | |
394 | EOF | |
395 | ||
396 | # event type | |
397 | echo "" | |
398 | cat <<EOF | |
399 | enum gdb_event | |
afbfc876 | 400 | { |
104c1213 JM |
401 | EOF |
402 | function_list | while eval read $read | |
403 | do | |
404 | case "${class}" in | |
405 | "f" ) | |
afbfc876 | 406 | echo " ${function}," |
104c1213 JM |
407 | ;; |
408 | esac | |
409 | done | |
410 | cat <<EOF | |
afbfc876 AC |
411 | nr_gdb_events |
412 | }; | |
104c1213 JM |
413 | EOF |
414 | ||
415 | # event data | |
416 | echo "" | |
417 | function_list | while eval read $read | |
418 | do | |
419 | case "${class}" in | |
420 | "f" ) | |
fd969be2 KS |
421 | if test ${actual} |
422 | then | |
423 | echo "struct ${function}" | |
424 | echo " {" | |
425 | echo " `echo ${formal} | tr '[,]' '[;]'`;" | |
426 | echo " };" | |
427 | echo "" | |
428 | fi | |
104c1213 JM |
429 | ;; |
430 | esac | |
431 | done | |
432 | ||
433 | # event queue | |
434 | cat <<EOF | |
435 | struct event | |
436 | { | |
437 | enum gdb_event type; | |
438 | struct event *next; | |
439 | union | |
440 | { | |
441 | EOF | |
442 | function_list | while eval read $read | |
443 | do | |
444 | case "${class}" in | |
445 | "f" ) | |
fd969be2 KS |
446 | if test ${actual} |
447 | then | |
448 | echo " struct ${function} ${function};" | |
449 | fi | |
104c1213 JM |
450 | ;; |
451 | esac | |
452 | done | |
453 | cat <<EOF | |
454 | } | |
455 | data; | |
456 | }; | |
457 | struct event *pending_events; | |
458 | struct event *delivering_events; | |
459 | EOF | |
460 | ||
461 | # append | |
462 | echo "" | |
463 | cat <<EOF | |
464 | static void | |
465 | append (struct event *new_event) | |
466 | { | |
467 | struct event **event = &pending_events; | |
468 | while ((*event) != NULL) | |
469 | event = &((*event)->next); | |
470 | (*event) = new_event; | |
471 | (*event)->next = NULL; | |
472 | } | |
473 | EOF | |
474 | ||
475 | # schedule a given event | |
476 | function_list | while eval read $read | |
477 | do | |
478 | case "${class}" in | |
479 | "f" ) | |
480 | echo "" | |
481 | echo "static void" | |
482 | echo "queue_${function} (${formal})" | |
483 | echo "{" | |
484 | echo " struct event *event = XMALLOC (struct event);" | |
485 | echo " event->type = ${function};" | |
9e791099 | 486 | for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do |
104c1213 JM |
487 | echo " event->data.${function}.${arg} = ${arg};" |
488 | done | |
489 | echo " append (event);" | |
490 | echo "}" | |
491 | ;; | |
492 | esac | |
493 | done | |
494 | ||
495 | # deliver | |
496 | echo "" | |
497 | cat <<EOF | |
498 | void | |
499 | gdb_events_deliver (struct gdb_events *vector) | |
500 | { | |
501 | /* Just zap any events left around from last time. */ | |
502 | while (delivering_events != NULL) | |
503 | { | |
504 | struct event *event = delivering_events; | |
505 | delivering_events = event->next; | |
e28f816a | 506 | xfree (event); |
104c1213 JM |
507 | } |
508 | /* Process any pending events. Because one of the deliveries could | |
509 | bail out we move everything off of the pending queue onto an | |
510 | in-progress queue where it can, later, be cleaned up if | |
511 | necessary. */ | |
512 | delivering_events = pending_events; | |
513 | pending_events = NULL; | |
514 | while (delivering_events != NULL) | |
515 | { | |
516 | struct event *event = delivering_events; | |
517 | switch (event->type) | |
518 | { | |
519 | EOF | |
520 | function_list | while eval read $read | |
521 | do | |
522 | case "${class}" in | |
523 | "f" ) | |
524 | echo " case ${function}:" | |
fd969be2 KS |
525 | if test ${actual} |
526 | then | |
527 | echo " vector->${function}" | |
528 | sep=" (" | |
529 | ass="" | |
530 | for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do | |
531 | ass="${ass}${sep}event->data.${function}.${arg}" | |
532 | sep=", | |
533 | " | |
534 | done | |
535 | echo "${ass});" | |
536 | else | |
537 | echo " vector->${function} ();" | |
538 | fi | |
104c1213 JM |
539 | echo " break;" |
540 | ;; | |
541 | esac | |
542 | done | |
543 | cat <<EOF | |
544 | } | |
545 | delivering_events = event->next; | |
e28f816a | 546 | xfree (event); |
104c1213 JM |
547 | } |
548 | } | |
549 | EOF | |
550 | ||
551 | # Finally the initialization | |
552 | echo "" | |
553 | cat <<EOF | |
554 | void _initialize_gdb_events (void); | |
555 | void | |
556 | _initialize_gdb_events (void) | |
557 | { | |
afbfc876 | 558 | struct cmd_list_element *c; |
104c1213 JM |
559 | #if WITH_GDB_EVENTS |
560 | EOF | |
561 | function_list | while eval read $read | |
562 | do | |
563 | case "${class}" in | |
564 | "f" ) | |
565 | echo " queue_event_hooks.${function} = queue_${function};" | |
566 | ;; | |
567 | esac | |
568 | done | |
569 | cat <<EOF | |
570 | #endif | |
afbfc876 AC |
571 | |
572 | c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger, | |
573 | (char *) (&gdb_events_debug), "Set event debugging.\n\\ | |
574 | When non-zero, event/notify debugging is enabled.", &setlist); | |
575 | deprecate_cmd (c, "set debug event"); | |
576 | deprecate_cmd (add_show_from_set (c, &showlist), "show debug event"); | |
577 | ||
578 | add_show_from_set (add_set_cmd ("event", | |
104c1213 JM |
579 | class_maintenance, |
580 | var_zinteger, | |
afbfc876 | 581 | (char *) (&gdb_events_debug), |
104c1213 | 582 | "Set event debugging.\n\\ |
afbfc876 AC |
583 | When non-zero, event/notify debugging is enabled.", &setdebuglist), |
584 | &showdebuglist); | |
104c1213 JM |
585 | } |
586 | EOF | |
587 | ||
588 | # close things off | |
589 | exec 1>&2 | |
590 | #../move-if-change new-gdb-events.c gdb-events.c | |
afbfc876 AC |
591 | # Replace any leading spaces with tabs |
592 | sed < new-gdb-events.c > tmp-gdb-events.c \ | |
593 | -e 's/\( \)* /\1 /g' | |
594 | mv tmp-gdb-events.c new-gdb-events.c | |
595 | # Move if changed? | |
9e791099 | 596 | if test -r gdb-events.c |
104c1213 | 597 | then |
9e791099 KS |
598 | diff -c gdb-events.c new-gdb-events.c |
599 | if [ $? = 1 ] | |
600 | then | |
601 | echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2 | |
602 | fi | |
603 | else | |
104c1213 | 604 | echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2 |
104c1213 | 605 | fi |