]>
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 |
e23792cc | 68 | f:void:target_changed:void |
55970da6 | 69 | f:void:selected_frame_level_changed:int level:level |
28ee05e9 | 70 | f:void:selected_thread_changed:int thread_num:thread_num |
104c1213 JM |
71 | #*:void:annotate_starting_hook:void |
72 | #*:void:annotate_stopped_hook:void | |
73 | #*:void:annotate_signalled_hook:void | |
74 | #*:void:annotate_signal_hook:void | |
75 | #*:void:annotate_exited_hook:void | |
76 | ##*:void:print_register_hook:int | |
77 | ##*:CORE_ADDR:find_toc_address_hook:CORE_ADDR | |
78 | ##*:void:sparc_print_register_hook:int regno:regno | |
79 | #*:void:target_resume_hook:void | |
80 | #*:void:target_wait_loop_hook:void | |
81 | #*:void:init_gdb_hook:char *argv0:argv0 | |
82 | #*:void:command_loop_hook:void | |
d9fcf2fb | 83 | #*:void:fputs_unfiltered_hook:const char *linebuff,struct ui_file *stream:linebuff, stream |
104c1213 JM |
84 | #*:void:print_frame_info_listing_hook:struct symtab *s, int line, int stopline, int noerror:s, line, stopline, noerror |
85 | #*:int:query_hook:const char *query, va_list args:query, args | |
86 | #*:void:warning_hook:const char *string, va_list args:string, args | |
104c1213 JM |
87 | #*:void:target_output_hook:char *b:b |
88 | #*:void:interactive_hook:void | |
89 | #*:void:registers_changed_hook:void | |
90 | #*:void:readline_begin_hook:char *format, ...:format | |
91 | #*:char *:readline_hook:char *prompt:prompt | |
92 | #*:void:readline_end_hook:void | |
104c1213 JM |
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 | ||
63d022e0 KS |
270 | /* Clear event handlers */ |
271 | extern void clear_gdb_event_hooks (void); | |
272 | ||
104c1213 JM |
273 | #if !WITH_GDB_EVENTS |
274 | #define set_gdb_events(x) 0 | |
275 | #define set_gdb_event_hooks(x) 0 | |
276 | #define gdb_events_deliver(x) 0 | |
277 | #endif | |
278 | EOF | |
279 | ||
280 | # close it off | |
281 | echo "" | |
282 | echo "#endif" | |
283 | exec 1>&2 | |
284 | #../move-if-change new-gdb-events.h gdb-events.h | |
9e791099 | 285 | if test -r gdb-events.h |
104c1213 | 286 | then |
9e791099 KS |
287 | diff -c gdb-events.h new-gdb-events.h |
288 | if [ $? = 1 ] | |
289 | then | |
290 | echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2 | |
291 | fi | |
292 | else | |
104c1213 | 293 | echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2 |
104c1213 JM |
294 | fi |
295 | ||
296 | ||
297 | ||
298 | # | |
299 | # C file | |
300 | # | |
301 | ||
302 | exec > new-gdb-events.c | |
303 | copyright | |
304 | cat <<EOF | |
305 | ||
306 | #include "defs.h" | |
307 | #include "gdb-events.h" | |
308 | #include "gdbcmd.h" | |
309 | ||
104c1213 JM |
310 | #if WITH_GDB_EVENTS |
311 | static struct gdb_events null_event_hooks; | |
312 | static struct gdb_events queue_event_hooks; | |
313 | static struct gdb_events *current_event_hooks = &null_event_hooks; | |
314 | #endif | |
315 | ||
316 | int gdb_events_debug; | |
317 | EOF | |
318 | ||
319 | # global pointer variables - always have this | |
320 | #echo "" | |
321 | #function_list | while eval read $read | |
322 | #do | |
323 | # case "${class}" in | |
324 | # "*" ) | |
325 | # echo "${returntype} (*${function}_event) (${formal})${attrib} = 0;" | |
326 | # ;; | |
327 | # esac | |
328 | #done | |
329 | ||
330 | # function bodies | |
331 | echo "" | |
332 | echo "#if WITH_GDB_EVENTS" | |
333 | function_list | while eval read $read | |
334 | do | |
335 | case "${class}" in | |
336 | "*" ) continue ;; | |
337 | "?" ) | |
9e791099 KS |
338 | cat <<EOF |
339 | ||
340 | int | |
341 | ${function}_event_p (${formal}) | |
342 | { | |
343 | return current_event_hooks->${function}; | |
344 | } | |
345 | ||
346 | ${returntype} | |
347 | ${function}_event (${formal}) | |
348 | { | |
349 | return current_events->${function} (${actual}); | |
350 | } | |
351 | EOF | |
104c1213 JM |
352 | ;; |
353 | "f" ) | |
9e791099 KS |
354 | cat <<EOF |
355 | ||
356 | void | |
357 | ${function}_event (${formal}) | |
358 | { | |
359 | if (gdb_events_debug) | |
8c6ee715 | 360 | fprintf_unfiltered (gdb_stdlog, "${function}_event\n"); |
9e791099 KS |
361 | if (!current_event_hooks->${function}) |
362 | return; | |
363 | current_event_hooks->${function} (${actual}); | |
364 | } | |
365 | EOF | |
104c1213 JM |
366 | ;; |
367 | esac | |
368 | done | |
369 | echo "" | |
370 | echo "#endif" | |
371 | ||
372 | # Set hooks function | |
373 | echo "" | |
374 | cat <<EOF | |
375 | #if WITH_GDB_EVENTS | |
ed9a39eb | 376 | struct gdb_events * |
104c1213 JM |
377 | set_gdb_event_hooks (struct gdb_events *vector) |
378 | { | |
ed9a39eb | 379 | struct gdb_events *old_events = current_event_hooks; |
104c1213 JM |
380 | if (vector == NULL) |
381 | current_event_hooks = &queue_event_hooks; | |
382 | else | |
383 | current_event_hooks = vector; | |
ed9a39eb | 384 | return old_events; |
104c1213 JM |
385 | EOF |
386 | function_list | while eval read $read | |
387 | do | |
388 | case "${class}" in | |
389 | "*" ) | |
390 | echo " ${function}_event = hooks->${function};" | |
391 | ;; | |
392 | esac | |
393 | done | |
394 | cat <<EOF | |
395 | } | |
396 | #endif | |
397 | EOF | |
398 | ||
63d022e0 KS |
399 | # Clear hooks function |
400 | echo "" | |
401 | cat <<EOF | |
402 | #if WITH_GDB_EVENTS | |
403 | void | |
404 | clear_gdb_event_hooks (void) | |
405 | { | |
406 | set_gdb_event_hooks (&null_event_hooks); | |
407 | } | |
408 | #endif | |
409 | EOF | |
410 | ||
104c1213 JM |
411 | # event type |
412 | echo "" | |
413 | cat <<EOF | |
414 | enum gdb_event | |
afbfc876 | 415 | { |
104c1213 JM |
416 | EOF |
417 | function_list | while eval read $read | |
418 | do | |
419 | case "${class}" in | |
420 | "f" ) | |
afbfc876 | 421 | echo " ${function}," |
104c1213 JM |
422 | ;; |
423 | esac | |
424 | done | |
425 | cat <<EOF | |
afbfc876 AC |
426 | nr_gdb_events |
427 | }; | |
104c1213 JM |
428 | EOF |
429 | ||
430 | # event data | |
431 | echo "" | |
432 | function_list | while eval read $read | |
433 | do | |
434 | case "${class}" in | |
435 | "f" ) | |
fd969be2 KS |
436 | if test ${actual} |
437 | then | |
438 | echo "struct ${function}" | |
439 | echo " {" | |
440 | echo " `echo ${formal} | tr '[,]' '[;]'`;" | |
441 | echo " };" | |
442 | echo "" | |
443 | fi | |
104c1213 JM |
444 | ;; |
445 | esac | |
446 | done | |
447 | ||
448 | # event queue | |
449 | cat <<EOF | |
450 | struct event | |
451 | { | |
452 | enum gdb_event type; | |
453 | struct event *next; | |
454 | union | |
455 | { | |
456 | EOF | |
457 | function_list | while eval read $read | |
458 | do | |
459 | case "${class}" in | |
460 | "f" ) | |
fd969be2 KS |
461 | if test ${actual} |
462 | then | |
463 | echo " struct ${function} ${function};" | |
464 | fi | |
104c1213 JM |
465 | ;; |
466 | esac | |
467 | done | |
468 | cat <<EOF | |
469 | } | |
470 | data; | |
471 | }; | |
472 | struct event *pending_events; | |
473 | struct event *delivering_events; | |
474 | EOF | |
475 | ||
476 | # append | |
477 | echo "" | |
478 | cat <<EOF | |
479 | static void | |
480 | append (struct event *new_event) | |
481 | { | |
482 | struct event **event = &pending_events; | |
483 | while ((*event) != NULL) | |
484 | event = &((*event)->next); | |
485 | (*event) = new_event; | |
486 | (*event)->next = NULL; | |
487 | } | |
488 | EOF | |
489 | ||
490 | # schedule a given event | |
491 | function_list | while eval read $read | |
492 | do | |
493 | case "${class}" in | |
494 | "f" ) | |
495 | echo "" | |
496 | echo "static void" | |
497 | echo "queue_${function} (${formal})" | |
498 | echo "{" | |
499 | echo " struct event *event = XMALLOC (struct event);" | |
500 | echo " event->type = ${function};" | |
9e791099 | 501 | for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do |
104c1213 JM |
502 | echo " event->data.${function}.${arg} = ${arg};" |
503 | done | |
504 | echo " append (event);" | |
505 | echo "}" | |
506 | ;; | |
507 | esac | |
508 | done | |
509 | ||
510 | # deliver | |
511 | echo "" | |
512 | cat <<EOF | |
513 | void | |
514 | gdb_events_deliver (struct gdb_events *vector) | |
515 | { | |
516 | /* Just zap any events left around from last time. */ | |
517 | while (delivering_events != NULL) | |
518 | { | |
519 | struct event *event = delivering_events; | |
520 | delivering_events = event->next; | |
e28f816a | 521 | xfree (event); |
104c1213 JM |
522 | } |
523 | /* Process any pending events. Because one of the deliveries could | |
524 | bail out we move everything off of the pending queue onto an | |
525 | in-progress queue where it can, later, be cleaned up if | |
526 | necessary. */ | |
527 | delivering_events = pending_events; | |
528 | pending_events = NULL; | |
529 | while (delivering_events != NULL) | |
530 | { | |
531 | struct event *event = delivering_events; | |
532 | switch (event->type) | |
533 | { | |
534 | EOF | |
535 | function_list | while eval read $read | |
536 | do | |
537 | case "${class}" in | |
538 | "f" ) | |
539 | echo " case ${function}:" | |
fd969be2 KS |
540 | if test ${actual} |
541 | then | |
542 | echo " vector->${function}" | |
543 | sep=" (" | |
544 | ass="" | |
545 | for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do | |
546 | ass="${ass}${sep}event->data.${function}.${arg}" | |
547 | sep=", | |
548 | " | |
549 | done | |
550 | echo "${ass});" | |
551 | else | |
552 | echo " vector->${function} ();" | |
553 | fi | |
104c1213 JM |
554 | echo " break;" |
555 | ;; | |
556 | esac | |
557 | done | |
558 | cat <<EOF | |
559 | } | |
560 | delivering_events = event->next; | |
e28f816a | 561 | xfree (event); |
104c1213 JM |
562 | } |
563 | } | |
564 | EOF | |
565 | ||
566 | # Finally the initialization | |
567 | echo "" | |
568 | cat <<EOF | |
569 | void _initialize_gdb_events (void); | |
570 | void | |
571 | _initialize_gdb_events (void) | |
572 | { | |
afbfc876 | 573 | struct cmd_list_element *c; |
104c1213 JM |
574 | #if WITH_GDB_EVENTS |
575 | EOF | |
576 | function_list | while eval read $read | |
577 | do | |
578 | case "${class}" in | |
579 | "f" ) | |
580 | echo " queue_event_hooks.${function} = queue_${function};" | |
581 | ;; | |
582 | esac | |
583 | done | |
584 | cat <<EOF | |
585 | #endif | |
afbfc876 AC |
586 | |
587 | c = add_set_cmd ("eventdebug", class_maintenance, var_zinteger, | |
588 | (char *) (&gdb_events_debug), "Set event debugging.\n\\ | |
589 | When non-zero, event/notify debugging is enabled.", &setlist); | |
590 | deprecate_cmd (c, "set debug event"); | |
591 | deprecate_cmd (add_show_from_set (c, &showlist), "show debug event"); | |
592 | ||
593 | add_show_from_set (add_set_cmd ("event", | |
104c1213 JM |
594 | class_maintenance, |
595 | var_zinteger, | |
afbfc876 | 596 | (char *) (&gdb_events_debug), |
104c1213 | 597 | "Set event debugging.\n\\ |
afbfc876 AC |
598 | When non-zero, event/notify debugging is enabled.", &setdebuglist), |
599 | &showdebuglist); | |
104c1213 JM |
600 | } |
601 | EOF | |
602 | ||
603 | # close things off | |
604 | exec 1>&2 | |
605 | #../move-if-change new-gdb-events.c gdb-events.c | |
afbfc876 AC |
606 | # Replace any leading spaces with tabs |
607 | sed < new-gdb-events.c > tmp-gdb-events.c \ | |
608 | -e 's/\( \)* /\1 /g' | |
609 | mv tmp-gdb-events.c new-gdb-events.c | |
610 | # Move if changed? | |
9e791099 | 611 | if test -r gdb-events.c |
104c1213 | 612 | then |
9e791099 KS |
613 | diff -c gdb-events.c new-gdb-events.c |
614 | if [ $? = 1 ] | |
615 | then | |
616 | echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2 | |
617 | fi | |
618 | else | |
104c1213 | 619 | echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2 |
104c1213 | 620 | fi |