From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26286 invoked by alias); 22 Jul 2008 00:56:57 -0000 Received: (qmail 26267 invoked by uid 22791); 22 Jul 2008 00:56:50 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 22 Jul 2008 00:56:19 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6M0uHxO004421 for ; Mon, 21 Jul 2008 20:56:17 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6M0uGeE002283; Mon, 21 Jul 2008 20:56:16 -0400 Received: from opsy.redhat.com (vpn-10-106.bos.redhat.com [10.16.10.106]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6M0uFAt032551; Mon, 21 Jul 2008 20:56:16 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 4D85C378245; Mon, 21 Jul 2008 18:56:15 -0600 (MDT) To: Joel Brobecker Cc: vladimir@codesourcery.com, gdb-patches@sources.redhat.com Subject: Re: RFA: Remove gdb-events References: <20080714171004.GC3998@adacore.com> From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Tue, 22 Jul 2008 00:56:00 -0000 In-Reply-To: (Tom Tromey's message of "Thu\, 17 Jul 2008 17\:40\:46 -0600") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00400.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Joel> First nit: gdbarch.c is a generated file. You'll need to modify Joel> gdbarch.sh instead, and regenerate gdbarch.c. You'll see that Joel> the changes should be identical to the ones you made, but in a Joel> different file. Tom> Thanks, I fixed this. Here is the follow-up patch. I assume I need a final "OK" for this. I fixed Eli's comment about the text in observer.texi, and I made the change to gdbarch.sh. Built and tested on x86 F8. Ok? Tom ChangeLog: 2008-07-21 Tom Tromey * tui/tui-hooks.c: Include observer.h. (tui_event_default, tui_old_event_hooks, tui_event_hooks): Remove. (tui_bp_created_observer, tui_bp_deleted_observer, tui_bp_modified_observer): New globals. (tui_install_hooks): Use observers, not events. (tui_remove_hooks): Likewise. * mi/mi-cmd-break.c: Include observer.h, not gdb-events.h. (mi_breakpoint_observers_installed, mi_can_breakpoint_notify): New globals. (breakpoint_notify): Check mi_can_breakpoint_notify. (breakpoint_hooks): Remove. (mi_cmd_break_insert): Attach observers. Don't use events. * tracepoint.c: Include observer.h, not gdb-events.h. (tracepoint_operation, trace_pass_command): Notify observer. * interps.c: Don't include gdb-events.h. (clear_interpreter_hooks): Don't call clear_gdb_event_hooks. * gdbarch.c: Rebuild. * gdbarch.sh: Emit include for observer.h, not gdb-events.h. (deprecated_current_gdbarch_select_hack): Notify observer. * breakpoint.h: Don't include gdb-events.h. * breakpoint.c: Don't include gdb-events.h. (condition_command): Notify observer. (commands_command): Likewise. (commands_from_control_command): Likewise. (mention, delete_breakpoint, set_ignore_count): Likewise. (disable_breakpoint, do_enable_breakpoint): Likewise. * Makefile.in (gdb_events_h): Remove. (breakpoint_h): Update. (COMMON_OBS): Remove gdb-events.o. (gdb-events.o): Remove. (breakpoint.o, gdbarch.o, interps.o, tracepoint.o, gdbtk-bp.o, gdbtk-hooks.o, mi-cmd-break.o, tui-hooks.o): Update. * gdb-events.c: Remove. * gdb-events.h: Remove. * gdb-events.sh: Remove. doc/ChangeLog: 2008-07-21 Tom Tromey * observer.texi (GDB Observers): Document new observers: breakpoint_created, breakpoint_deleted, breakpoint_modified, tracepoint_created, tracepoint_deleted, tracepoint_modified, architecture_changed. gdbtk/ChangeLog: 2008-07-21 Tom Tromey * generic/gdbtk-hooks.c: Include observer.h, not gdb-events.h. (gdbtk_add_hooks): Use observers, not events. (gdbtk_architecture_changed): Add argument, for observer. * generic/gdbtk-bp.c: Include observer.h. (gdb_set_bp): Notify observer. (gdb_set_bp_addr): Likewise. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.1039 diff -u -r1.1039 Makefile.in --- Makefile.in 18 Jul 2008 20:55:32 -0000 1.1039 +++ Makefile.in 22 Jul 2008 00:34:54 -0000 @@ -742,7 +742,7 @@ bcache_h = bcache.h bfd_target_h = bfd-target.h block_h = block.h -breakpoint_h = breakpoint.h $(frame_h) $(value_h) $(gdb_events_h) $(vec_h) +breakpoint_h = breakpoint.h $(frame_h) $(value_h) $(vec_h) bsd_kvm_h = bsd-kvm.h bsd_uthread_h = bsd-uthread.h buildsym_h = buildsym.h @@ -787,7 +787,6 @@ gdbcore_h = gdbcore.h $(bfd_h) gdb_curses_h = gdb_curses.h gdb_dirent_h = gdb_dirent.h -gdb_events_h = gdb-events.h gdb_h = gdb.h gdb_expat_h = gdb_expat.h gdb_locale_h = gdb_locale.h @@ -1062,7 +1061,6 @@ findcmd.o \ std-regs.o \ signals.o \ - gdb-events.o \ exec.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \ dbxread.o coffread.o coff-pe-read.o \ dwarf2read.o mipsread.o stabsread.o corefile.o \ @@ -1972,7 +1970,7 @@ $(gdb_string_h) $(demangle_h) $(annotate_h) $(symfile_h) \ $(objfiles_h) $(source_h) $(linespec_h) $(completer_h) $(gdb_h) \ $(ui_out_h) $(cli_script_h) $(gdb_assert_h) $(block_h) $(solib_h) \ - $(solist_h) $(observer_h) $(exceptions_h) $(gdb_events_h) \ + $(solist_h) $(observer_h) $(exceptions_h) \ $(mi_common_h) $(memattr_h) $(ada_lang_h) $(top_h) $(hashtab_h) bsd-kvm.o: bsd-kvm.c $(defs_h) $(cli_cmds_h) $(command_h) $(frame_h) \ $(regcache_h) $(target_h) $(value_h) $(gdbcore_h) $(gdb_assert_h) \ @@ -2167,9 +2165,8 @@ $(gdb_assert_h) gdbarch.o: gdbarch.c $(defs_h) $(arch_utils_h) $(gdbcmd_h) $(inferior_h) \ $(symcat_h) $(floatformat_h) $(gdb_assert_h) $(gdb_string_h) \ - $(gdb_events_h) $(reggroups_h) $(osabi_h) $(gdb_obstack_h) + $(reggroups_h) $(osabi_h) $(gdb_obstack_h) $(observer_h) gdb.o: gdb.c $(defs_h) $(main_h) $(gdb_string_h) $(interps_h) -gdb-events.o: gdb-events.c $(defs_h) $(gdb_events_h) $(gdbcmd_h) gdbtypes.o: gdbtypes.c $(defs_h) $(gdb_string_h) $(bfd_h) $(symtab_h) \ $(symfile_h) $(objfiles_h) $(gdbtypes_h) $(expression_h) \ $(language_h) $(target_h) $(value_h) $(demangle_h) $(complaints_h) \ @@ -2341,7 +2338,7 @@ $(gdb_assert_h) $(gdb_string_h) $(inf_child_h) $(inf_ttrace_h) interps.o: interps.c $(defs_h) $(gdbcmd_h) $(ui_out_h) $(event_loop_h) \ $(event_top_h) $(interps_h) $(completer_h) $(gdb_string_h) \ - $(gdb_events_h) $(gdb_assert_h) $(top_h) $(exceptions_h) + $(gdb_assert_h) $(top_h) $(exceptions_h) iq2000-tdep.o: iq2000-tdep.c $(defs_h) $(frame_h) $(frame_base_h) \ $(frame_unwind_h) $(dwarf2_frame_h) $(gdbtypes_h) $(value_h) \ $(dis_asm_h) $(gdb_string_h) $(arch_utils_h) $(regcache_h) \ @@ -2933,9 +2930,9 @@ tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_h) \ $(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \ $(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \ - $(linespec_h) $(regcache_h) $(completer_h) $(gdb_events_h) \ + $(linespec_h) $(regcache_h) $(completer_h) \ $(block_h) $(dictionary_h) $(ax_h) $(ax_gdb_h) $(readline_h) \ - $(readline_history_h) + $(readline_history_h) $(observer_h) trad-frame.o: trad-frame.c $(defs_h) $(frame_h) $(trad_frame_h) \ $(regcache_h) $(frame_unwind_h) $(value_h) tramp-frame.o: tramp-frame.c $(defs_h) $(tramp_frame_h) $(frame_unwind_h) \ @@ -3151,7 +3148,7 @@ $(srcdir)/gdbtk/generic/gdbtk.h \ $(srcdir)/gdbtk/generic/gdbtk-cmds.h \ $(defs_h) $(breakpoint_h) $(tracepoint_h) \ - $(symfile_h) $(symtab_h) $(gdb_string_h) + $(symfile_h) $(symtab_h) $(gdb_string_h) $(observer_h) $(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \ $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \ $(GDBTK_CFLAGS) $(srcdir)/gdbtk/generic/gdbtk-bp.c \ @@ -3172,7 +3169,7 @@ $(srcdir)/gdbtk/generic/gdbtk.h $(defs_h) \ $(symtab_h) $(inferior_h) $(command_h) \ $(bfd_h) $(symfile_h) $(objfiles_h) $(target_h) $(gdb_string_h) \ - $(tracepoint_h) + $(tracepoint_h) $(observer_h) $(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \ $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) $(GDBTK_CFLAGS)\ $(srcdir)/gdbtk/generic/gdbtk-hooks.c -DGDBTK_LIBRARY=\"$(GDBTK_LIBRARY)\" @@ -3232,7 +3229,7 @@ mi-cmd-break.o: $(srcdir)/mi/mi-cmd-break.c $(defs_h) $(mi_cmds_h) \ $(ui_out_h) $(mi_out_h) $(breakpoint_h) $(gdb_string_h) \ - $(mi_getopt_h) $(gdb_events_h) $(gdb_h) + $(mi_getopt_h) $(gdb_h) $(observer_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-break.c mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \ $(mi_cmds_h) $(mi_getopt_h) $(gdb_string_h) $(ui_out_h) $(disasm_h) @@ -3326,7 +3323,7 @@ tui-hooks.o: $(srcdir)/tui/tui-hooks.c $(defs_h) $(symtab_h) $(inferior_h) \ $(command_h) $(bfd_h) $(symfile_h) $(objfiles_h) $(target_h) \ $(gdbcore_h) $(event_loop_h) $(event_top_h) $(frame_h) \ - $(breakpoint_h) $(gdb_events_h) $(ui_out_h) $(top_h) $(observer_h) \ + $(breakpoint_h) $(ui_out_h) $(top_h) $(observer_h) \ $(tui_h) $(tui_hooks_h) $(tui_data_h) $(tui_layout_h) $(tui_io_h) \ $(tui_regs_h) $(tui_win_h) $(tui_stack_h) $(tui_windata_h) \ $(tui_winsource_h) $(gdb_curses_h) $(readline_h) Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.336 diff -u -r1.336 breakpoint.c --- breakpoint.c 15 Jul 2008 19:11:34 -0000 1.336 +++ breakpoint.c 22 Jul 2008 00:34:55 -0000 @@ -57,7 +57,6 @@ #include "top.h" #include "wrapper.h" -#include "gdb-events.h" #include "mi/mi-common.h" /* Prototypes for local functions. */ @@ -619,7 +618,7 @@ } } breakpoints_changed (); - breakpoint_modify_event (b->number); + observer_notify_breakpoint_modified (b->number); return; } @@ -658,7 +657,7 @@ free_command_lines (&b->commands); b->commands = l; breakpoints_changed (); - breakpoint_modify_event (b->number); + observer_notify_breakpoint_modified (b->number); return; } error (_("No breakpoint number %d."), bnum); @@ -704,7 +703,7 @@ list after it finishes execution. */ b->commands = copy_command_lines (cmd->body_list[0]); breakpoints_changed (); - breakpoint_modify_event (b->number); + observer_notify_breakpoint_modified (b->number); return simple_control; } error (_("No breakpoint number %d."), bnum); @@ -4895,7 +4894,7 @@ been done for deprecated_delete_breakpoint_hook and so on. */ if (deprecated_create_breakpoint_hook) deprecated_create_breakpoint_hook (b); - breakpoint_create_event (b->number); + observer_notify_breakpoint_created (b->number); if (b->ops != NULL && b->ops->print_mention != NULL) b->ops->print_mention (b); @@ -7216,7 +7215,7 @@ if (deprecated_delete_breakpoint_hook) deprecated_delete_breakpoint_hook (bpt); - breakpoint_delete_event (bpt->number); + observer_notify_breakpoint_deleted (bpt->number); if (breakpoint_chain == bpt) breakpoint_chain = bpt->next; @@ -7721,7 +7720,7 @@ count, bptnum); } breakpoints_changed (); - breakpoint_modify_event (b->number); + observer_notify_breakpoint_modified (b->number); return; } @@ -7871,7 +7870,7 @@ if (deprecated_modify_breakpoint_hook) deprecated_modify_breakpoint_hook (bpt); - breakpoint_modify_event (bpt->number); + observer_notify_breakpoint_modified (bpt->number); } static void @@ -7996,7 +7995,7 @@ if (deprecated_modify_breakpoint_hook) deprecated_modify_breakpoint_hook (bpt); - breakpoint_modify_event (bpt->number); + observer_notify_breakpoint_modified (bpt->number); } Index: breakpoint.h =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.h,v retrieving revision 1.75 diff -u -r1.75 breakpoint.h --- breakpoint.h 9 Jul 2008 22:23:05 -0000 1.75 +++ breakpoint.h 22 Jul 2008 00:34:55 -0000 @@ -24,8 +24,6 @@ #include "value.h" #include "vec.h" -#include "gdb-events.h" - struct value; struct block; Index: gdb-events.c =================================================================== RCS file: gdb-events.c diff -N gdb-events.c --- gdb-events.c 1 Jan 2008 22:53:09 -0000 1.25 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,349 +0,0 @@ -/* User Interface Events. - - Copyright (C) 1999, 2001, 2002, 2004, 2005, 2007, 2008 - Free Software Foundation, Inc. - - Contributed by Cygnus Solutions. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Work in progress */ - -/* This file was created with the aid of ``gdb-events.sh''. - - The bourn shell script ``gdb-events.sh'' creates the files - ``new-gdb-events.c'' and ``new-gdb-events.h and then compares - them against the existing ``gdb-events.[hc]''. Any differences - found being reported. - - If editing this file, please also run gdb-events.sh and merge any - changes into that script. Conversely, when making sweeping changes - to this file, modifying gdb-events.sh and using its output may - prove easier. */ - - -#include "defs.h" -#include "gdb-events.h" -#include "gdbcmd.h" - -static struct gdb_events null_event_hooks; -static struct gdb_events queue_event_hooks; -static struct gdb_events *current_event_hooks = &null_event_hooks; - -int gdb_events_debug; -static void -show_gdb_events_debug (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) -{ - fprintf_filtered (file, _("Event debugging is %s.\n"), value); -} - - -void -breakpoint_create_event (int b) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "breakpoint_create_event\n"); - if (!current_event_hooks->breakpoint_create) - return; - current_event_hooks->breakpoint_create (b); -} - -void -breakpoint_delete_event (int b) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "breakpoint_delete_event\n"); - if (!current_event_hooks->breakpoint_delete) - return; - current_event_hooks->breakpoint_delete (b); -} - -void -breakpoint_modify_event (int b) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "breakpoint_modify_event\n"); - if (!current_event_hooks->breakpoint_modify) - return; - current_event_hooks->breakpoint_modify (b); -} - -void -tracepoint_create_event (int number) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "tracepoint_create_event\n"); - if (!current_event_hooks->tracepoint_create) - return; - current_event_hooks->tracepoint_create (number); -} - -void -tracepoint_delete_event (int number) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "tracepoint_delete_event\n"); - if (!current_event_hooks->tracepoint_delete) - return; - current_event_hooks->tracepoint_delete (number); -} - -void -tracepoint_modify_event (int number) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "tracepoint_modify_event\n"); - if (!current_event_hooks->tracepoint_modify) - return; - current_event_hooks->tracepoint_modify (number); -} - -void -architecture_changed_event (void) -{ - if (gdb_events_debug) - fprintf_unfiltered (gdb_stdlog, "architecture_changed_event\n"); - if (!current_event_hooks->architecture_changed) - return; - current_event_hooks->architecture_changed (); -} - -struct gdb_events * -deprecated_set_gdb_event_hooks (struct gdb_events *vector) -{ - struct gdb_events *old_events = current_event_hooks; - if (vector == NULL) - current_event_hooks = &queue_event_hooks; - else - current_event_hooks = vector; - return old_events; -} - -void -clear_gdb_event_hooks (void) -{ - deprecated_set_gdb_event_hooks (&null_event_hooks); -} - -enum gdb_event -{ - breakpoint_create, - breakpoint_delete, - breakpoint_modify, - tracepoint_create, - tracepoint_delete, - tracepoint_modify, - architecture_changed, - nr_gdb_events -}; - -struct breakpoint_create - { - int b; - }; - -struct breakpoint_delete - { - int b; - }; - -struct breakpoint_modify - { - int b; - }; - -struct tracepoint_create - { - int number; - }; - -struct tracepoint_delete - { - int number; - }; - -struct tracepoint_modify - { - int number; - }; - -struct event - { - enum gdb_event type; - struct event *next; - union - { - struct breakpoint_create breakpoint_create; - struct breakpoint_delete breakpoint_delete; - struct breakpoint_modify breakpoint_modify; - struct tracepoint_create tracepoint_create; - struct tracepoint_delete tracepoint_delete; - struct tracepoint_modify tracepoint_modify; - } - data; - }; -struct event *pending_events; -struct event *delivering_events; - -static void -append (struct event *new_event) -{ - struct event **event = &pending_events; - while ((*event) != NULL) - event = &((*event)->next); - (*event) = new_event; - (*event)->next = NULL; -} - -static void -queue_breakpoint_create (int b) -{ - struct event *event = XMALLOC (struct event); - event->type = breakpoint_create; - event->data.breakpoint_create.b = b; - append (event); -} - -static void -queue_breakpoint_delete (int b) -{ - struct event *event = XMALLOC (struct event); - event->type = breakpoint_delete; - event->data.breakpoint_delete.b = b; - append (event); -} - -static void -queue_breakpoint_modify (int b) -{ - struct event *event = XMALLOC (struct event); - event->type = breakpoint_modify; - event->data.breakpoint_modify.b = b; - append (event); -} - -static void -queue_tracepoint_create (int number) -{ - struct event *event = XMALLOC (struct event); - event->type = tracepoint_create; - event->data.tracepoint_create.number = number; - append (event); -} - -static void -queue_tracepoint_delete (int number) -{ - struct event *event = XMALLOC (struct event); - event->type = tracepoint_delete; - event->data.tracepoint_delete.number = number; - append (event); -} - -static void -queue_tracepoint_modify (int number) -{ - struct event *event = XMALLOC (struct event); - event->type = tracepoint_modify; - event->data.tracepoint_modify.number = number; - append (event); -} - -static void -queue_architecture_changed (void) -{ - struct event *event = XMALLOC (struct event); - event->type = architecture_changed; - append (event); -} - -void -gdb_events_deliver (struct gdb_events *vector) -{ - /* Just zap any events left around from last time. */ - while (delivering_events != NULL) - { - struct event *event = delivering_events; - delivering_events = event->next; - xfree (event); - } - /* Process any pending events. Because one of the deliveries could - bail out we move everything off of the pending queue onto an - in-progress queue where it can, later, be cleaned up if - necessary. */ - delivering_events = pending_events; - pending_events = NULL; - while (delivering_events != NULL) - { - struct event *event = delivering_events; - switch (event->type) - { - case breakpoint_create: - vector->breakpoint_create - (event->data.breakpoint_create.b); - break; - case breakpoint_delete: - vector->breakpoint_delete - (event->data.breakpoint_delete.b); - break; - case breakpoint_modify: - vector->breakpoint_modify - (event->data.breakpoint_modify.b); - break; - case tracepoint_create: - vector->tracepoint_create - (event->data.tracepoint_create.number); - break; - case tracepoint_delete: - vector->tracepoint_delete - (event->data.tracepoint_delete.number); - break; - case tracepoint_modify: - vector->tracepoint_modify - (event->data.tracepoint_modify.number); - break; - case architecture_changed: - vector->architecture_changed (); - break; - } - delivering_events = event->next; - xfree (event); - } -} - -void _initialize_gdb_events (void); -void -_initialize_gdb_events (void) -{ - struct cmd_list_element *c; - queue_event_hooks.breakpoint_create = queue_breakpoint_create; - queue_event_hooks.breakpoint_delete = queue_breakpoint_delete; - queue_event_hooks.breakpoint_modify = queue_breakpoint_modify; - queue_event_hooks.tracepoint_create = queue_tracepoint_create; - queue_event_hooks.tracepoint_delete = queue_tracepoint_delete; - queue_event_hooks.tracepoint_modify = queue_tracepoint_modify; - queue_event_hooks.architecture_changed = queue_architecture_changed; - - add_setshow_zinteger_cmd ("event", class_maintenance, - &gdb_events_debug, _("\ -Set event debugging."), _("\ -Show event debugging."), _("\ -When non-zero, event/notify debugging is enabled."), - NULL, - show_gdb_events_debug, - &setdebuglist, &showdebuglist); -} Index: gdb-events.h =================================================================== RCS file: gdb-events.h diff -N gdb-events.h --- gdb-events.h 1 Jan 2008 22:53:09 -0000 1.20 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,94 +0,0 @@ -/* User Interface Events. - - Copyright (C) 1999, 2001, 2002, 2004, 2007, 2008 - Free Software Foundation, Inc. - - Contributed by Cygnus Solutions. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Work in progress */ - -/* This file was created with the aid of ``gdb-events.sh''. - - The bourn shell script ``gdb-events.sh'' creates the files - ``new-gdb-events.c'' and ``new-gdb-events.h and then compares - them against the existing ``gdb-events.[hc]''. Any differences - found being reported. - - If editing this file, please also run gdb-events.sh and merge any - changes into that script. Conversely, when making sweeping changes - to this file, modifying gdb-events.sh and using its output may - prove easier. */ - - -#ifndef GDB_EVENTS_H -#define GDB_EVENTS_H - - -/* COMPAT: pointer variables for old, unconverted events. - A call to set_gdb_events() will automatically update these. */ - - - -/* Type definition of all hook functions. Recommended pratice is to - first declare each hook function using the below ftype and then - define it. */ - -typedef void (gdb_events_breakpoint_create_ftype) (int b); -typedef void (gdb_events_breakpoint_delete_ftype) (int b); -typedef void (gdb_events_breakpoint_modify_ftype) (int b); -typedef void (gdb_events_tracepoint_create_ftype) (int number); -typedef void (gdb_events_tracepoint_delete_ftype) (int number); -typedef void (gdb_events_tracepoint_modify_ftype) (int number); -typedef void (gdb_events_architecture_changed_ftype) (void); - - -/* gdb-events: object. */ - -struct gdb_events - { - gdb_events_breakpoint_create_ftype *breakpoint_create; - gdb_events_breakpoint_delete_ftype *breakpoint_delete; - gdb_events_breakpoint_modify_ftype *breakpoint_modify; - gdb_events_tracepoint_create_ftype *tracepoint_create; - gdb_events_tracepoint_delete_ftype *tracepoint_delete; - gdb_events_tracepoint_modify_ftype *tracepoint_modify; - gdb_events_architecture_changed_ftype *architecture_changed; - }; - - -/* Interface into events functions. - Where a *_p() predicate is present, it must be called before - calling the hook proper. */ -extern void breakpoint_create_event (int b); -extern void breakpoint_delete_event (int b); -extern void breakpoint_modify_event (int b); -extern void tracepoint_create_event (int number); -extern void tracepoint_delete_event (int number); -extern void tracepoint_modify_event (int number); -extern void architecture_changed_event (void); - -/* Install custom gdb-events hooks. */ -extern struct gdb_events *deprecated_set_gdb_event_hooks (struct gdb_events *vector); - -/* Deliver any pending events. */ -extern void gdb_events_deliver (struct gdb_events *vector); - -/* Clear event handlers. */ -extern void clear_gdb_event_hooks (void); - -#endif Index: gdb-events.sh =================================================================== RCS file: gdb-events.sh diff -N gdb-events.sh --- gdb-events.sh 1 Jan 2008 22:53:09 -0000 1.29 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,509 +0,0 @@ -#!/bin/sh - -# User Interface Events. -# -# Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 -# Free Software Foundation, Inc. -# -# Contributed by Cygnus Solutions. -# -# This file is part of GDB. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -IFS=: - -read="class returntype function formal actual attrib" - -function_list () -{ - # category: - # # -> disable - # * -> compatibility - pointer variable that is initialized - # by set_gdb_events(). - # ? -> Predicate and function proper. - # f -> always call (must have a void returntype) - # return-type - # name - # formal argument list - # actual argument list - # attributes - # description - cat <. */ - -/* Work in progress */ - -/* This file was created with the aid of \`\`gdb-events.sh''. - - The bourn shell script \`\`gdb-events.sh'' creates the files - \`\`new-gdb-events.c'' and \`\`new-gdb-events.h and then compares - them against the existing \`\`gdb-events.[hc]''. Any differences - found being reported. - - If editing this file, please also run gdb-events.sh and merge any - changes into that script. Conversely, when making sweeping changes - to this file, modifying gdb-events.sh and using its output may - prove easier. */ - -EOF -} - -# -# The .h file -# - -exec > new-gdb-events.h -copyright -cat <&2 -#../move-if-change new-gdb-events.h gdb-events.h -if test -r gdb-events.h -then - diff -c gdb-events.h new-gdb-events.h - if [ $? = 1 ] - then - echo "gdb-events.h changed? cp new-gdb-events.h gdb-events.h" 1>&2 - fi -else - echo "File missing? mv new-gdb-events.h gdb-events.h" 1>&2 -fi - - - -# -# C file -# - -exec > new-gdb-events.c -copyright -cat <${function}; -} - -${returntype} -${function}_event (${formal}) -{ - return current_events->${function} (${actual}); -} -EOF - ;; - "f" ) -cat <${function}) - return; - current_event_hooks->${function} (${actual}); -} -EOF - ;; - esac -done - -# Set hooks function -echo "" -cat <${function};" - ;; - esac -done -cat <next); - (*event) = new_event; - (*event)->next = NULL; -} -EOF - -# schedule a given event -function_list | while eval read $read -do - case "${class}" in - "f" ) - echo "" - echo "static void" - echo "queue_${function} (${formal})" - echo "{" - echo " struct event *event = XMALLOC (struct event);" - echo " event->type = ${function};" - for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do - echo " event->data.${function}.${arg} = ${arg};" - done - echo " append (event);" - echo "}" - ;; - esac -done - -# deliver -echo "" -cat <next; - xfree (event); - } - /* Process any pending events. Because one of the deliveries could - bail out we move everything off of the pending queue onto an - in-progress queue where it can, later, be cleaned up if - necessary. */ - delivering_events = pending_events; - pending_events = NULL; - while (delivering_events != NULL) - { - struct event *event = delivering_events; - switch (event->type) - { -EOF -function_list | while eval read $read -do - case "${class}" in - "f" ) - echo " case ${function}:" - if test ${actual} - then - echo " vector->${function}" - sep=" (" - ass="" - for arg in `echo ${actual} | tr '[,]' '[:]' | tr -d '[ ]'`; do - ass="${ass}${sep}event->data.${function}.${arg}" - sep=", - " - done - echo "${ass});" - else - echo " vector->${function} ();" - fi - echo " break;" - ;; - esac -done -cat <next; - xfree (event); - } -} -EOF - -# Finally the initialization -echo "" -cat <&2 -#../move-if-change new-gdb-events.c gdb-events.c -# Replace any leading spaces with tabs -sed < new-gdb-events.c > tmp-gdb-events.c \ - -e 's/\( \)* /\1 /g' -mv tmp-gdb-events.c new-gdb-events.c -# Move if changed? -if test -r gdb-events.c -then - diff -c gdb-events.c new-gdb-events.c - if [ $? = 1 ] - then - echo "gdb-events.c changed? cp new-gdb-events.c gdb-events.c" 1>&2 - fi -else - echo "File missing? mv new-gdb-events.c gdb-events.c" 1>&2 -fi Index: gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.470 diff -u -r1.470 gdbarch.sh --- gdbarch.sh 11 Jun 2008 22:03:49 -0000 1.470 +++ gdbarch.sh 22 Jul 2008 00:34:55 -0000 @@ -1130,10 +1130,10 @@ #include "gdb_assert.h" #include "gdb_string.h" -#include "gdb-events.h" #include "reggroups.h" #include "osabi.h" #include "gdb_obstack.h" +#include "observer.h" /* Static function declarations */ @@ -2018,7 +2018,7 @@ gdb_assert (current_gdbarch != NULL); gdb_assert (new_gdbarch->initialized_p); current_gdbarch = new_gdbarch; - architecture_changed_event (); + observer_notify_architecture_changed (new_gdbarch); reinit_frame_cache (); } Index: interps.c =================================================================== RCS file: /cvs/src/src/gdb/interps.c,v retrieving revision 1.26 diff -u -r1.26 interps.c --- interps.c 12 Jul 2008 19:25:42 -0000 1.26 +++ interps.c 22 Jul 2008 00:34:55 -0000 @@ -37,7 +37,6 @@ #include "interps.h" #include "completer.h" #include "gdb_string.h" -#include "gdb-events.h" #include "gdb_assert.h" #include "top.h" /* For command_loop. */ #include "exceptions.h" @@ -352,7 +351,6 @@ deprecated_error_hook = 0; deprecated_error_begin_hook = 0; deprecated_command_loop_hook = 0; - clear_gdb_event_hooks (); } /* This is a lazy init routine, called the first time the interpreter Index: tracepoint.c =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.c,v retrieving revision 1.106 diff -u -r1.106 tracepoint.c --- tracepoint.c 27 May 2008 19:29:51 -0000 1.106 +++ tracepoint.c 22 Jul 2008 00:34:56 -0000 @@ -34,9 +34,9 @@ #include "linespec.h" #include "regcache.h" #include "completer.h" -#include "gdb-events.h" #include "block.h" #include "dictionary.h" +#include "observer.h" #include "ax.h" #include "ax-gdb.h" @@ -570,11 +570,11 @@ { case enable_op: t->enabled_p = 1; - tracepoint_modify_event (t->number); + observer_notify_tracepoint_modified (t->number); break; case disable_op: t->enabled_p = 0; - tracepoint_modify_event (t->number); + observer_notify_tracepoint_modified (t->number); break; case delete_op: if (tracepoint_chain == t) @@ -587,7 +587,7 @@ break; } - tracepoint_delete_event (t->number); + observer_notify_tracepoint_deleted (t->number); if (t->addr_string) xfree (t->addr_string); @@ -739,7 +739,7 @@ if (t1 == (struct tracepoint *) -1 || t1 == t2) { t2->pass_count = count; - tracepoint_modify_event (t2->number); + observer_notify_tracepoint_modified (t2->number); if (from_tty) printf_filtered ("Setting tracepoint %d's passcount to %d\n", t2->number, count); Index: doc/observer.texi =================================================================== RCS file: /cvs/src/src/gdb/doc/observer.texi,v retrieving revision 1.17 diff -u -r1.17 observer.texi --- doc/observer.texi 21 Jul 2008 16:47:11 -0000 1.17 +++ doc/observer.texi 22 Jul 2008 00:34:56 -0000 @@ -2,7 +2,7 @@ @c This file is part of the GDB manual. @c -@c Copyright (C) 2003, 2004, 2005, 2006 +@c Copyright (C) 2003, 2004, 2005, 2006, 2008 @c Free Software Foundation, Inc. @c @c See the file gdbint.texinfo for copying conditions. @@ -139,3 +139,39 @@ The target was resumed. The @var{ptid} parameter specifies which thread was resume, and may be RESUME_ALL if all threads are resumed. @end deftypefun + +@deftypefun void breakpoint_created (int @var{bpnum}) +A new breakpoint has been created. The argument @var{bpnum} is the +number of the newly-created breakpoint. +@end deftypefun + +@deftypefun void breakpoint_deleted (int @var{bpnum}) +A breakpoint has been destroyed. The argument @var{bpnum} is the +number of the newly-destroyed breakpoint. +@end deftypefun + +@deftypefun void breakpoint_modified (int @var{bpnum}) +A breakpoint has been modified in some way. The argument @var{bpnum} +is the number of the modified breakpoint. +@end deftypefun + +@deftypefun void tracepoint_created (int @var{tpnum}) +A new tracepoint has been created. The argument @var{tpnum} is the +number of the newly-created tracepoint. +@end deftypefun + +@deftypefun void tracepoint_deleted (int @var{tpnum}) +A tracepoint has been destroyed. The argument @var{tpnum} is the +number of the newly-destroyed tracepoint. +@end deftypefun + +@deftypefun void tracepoint_modified (int @var{tpnum}) +A tracepoint has been modified in some way. The argument @var{tpnum} +is the number of the modified tracepoint. +@end deftypefun + +@deftypefun void architecture_changed (struct gdbarch *@var{newarch}) +The current architecture has changed. The argument @var{newarch} is +a pointer to the new architecture. +@end deftypefun + Index: gdbtk/generic/gdbtk-bp.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-bp.c,v retrieving revision 1.26 diff -u -r1.26 gdbtk-bp.c --- gdbtk/generic/gdbtk-bp.c 23 Dec 2005 18:23:15 -0000 1.26 +++ gdbtk/generic/gdbtk-bp.c 22 Jul 2008 00:34:56 -0000 @@ -1,5 +1,5 @@ /* Tcl/Tk command definitions for Insight - Breakpoints. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2008 Free Software Foundation, Inc. This file is part of GDB. @@ -29,6 +29,7 @@ #include #include "gdbtk.h" #include "gdbtk-cmds.h" +#include "observer.h" /* From breakpoint.c */ extern struct breakpoint *breakpoint_chain; @@ -541,7 +542,7 @@ free(buf); /* now send notification command back to GUI */ - breakpoint_create_event (b->number); + observer_notify_breakpoint_created (b->number); return TCL_OK; } @@ -609,7 +610,7 @@ b->addr_string = xstrdup (saddr); /* now send notification command back to GUI */ - breakpoint_create_event (b->number); + observer_notify_breakpoint_created (b->number); return TCL_OK; } Index: gdbtk/generic/gdbtk-hooks.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v retrieving revision 1.43 diff -u -r1.43 gdbtk-hooks.c --- gdbtk/generic/gdbtk-hooks.c 14 Jul 2008 23:43:36 -0000 1.43 +++ gdbtk/generic/gdbtk-hooks.c 22 Jul 2008 00:34:56 -0000 @@ -29,10 +29,10 @@ #include "gdbcore.h" #include "tracepoint.h" #include "demangle.h" -#include "gdb-events.h" #include "top.h" #include "annotate.h" #include "cli/cli-decode.h" +#include "observer.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN @@ -75,7 +75,7 @@ extern void gdbtk_delete_tracepoint (int); extern void gdbtk_modify_tracepoint (int); -static void gdbtk_architecture_changed (void); +static void gdbtk_architecture_changed (struct gdbarch *); static void gdbtk_trace_find (char *arg, int from_tty); static void gdbtk_trace_start_stop (int, int); static void gdbtk_attach (void); @@ -121,17 +121,14 @@ void gdbtk_add_hooks (void) { - static struct gdb_events handlers; - - /* Gdb event handlers */ - handlers.breakpoint_create = gdbtk_create_breakpoint; - handlers.breakpoint_modify = gdbtk_modify_breakpoint; - handlers.breakpoint_delete = gdbtk_delete_breakpoint; - handlers.tracepoint_create = gdbtk_create_tracepoint; - handlers.tracepoint_modify = gdbtk_modify_tracepoint; - handlers.tracepoint_delete = gdbtk_delete_tracepoint; - handlers.architecture_changed = gdbtk_architecture_changed; - deprecated_set_gdb_event_hooks (&handlers); + /* Gdb observers */ + observer_attach_breakpoint_created (gdbtk_create_breakpoint); + observer_attach_breakpoint_modified (gdbtk_modify_breakpoint); + observer_attach_breakpoint_deleted (gdbtk_delete_breakpoint); + observer_attach_tracepoint_created (gdbtk_create_tracepoint); + observer_attach_tracepoint_modified (gdbtk_modify_tracepoint); + observer_attach_tracepoint_deleted (gdbtk_delete_tracepoint); + observer_attach_architecture_changed (gdbtk_architecture_changed); /* Hooks */ deprecated_call_command_hook = gdbtk_call_command; @@ -835,7 +832,7 @@ /* Called from gdbarch_update_p whenever the architecture changes. */ static void -gdbtk_architecture_changed (void) +gdbtk_architecture_changed (struct gdbarch *ignore) { Tcl_Eval (gdbtk_interp, "gdbtk_tcl_architecture_changed"); } Index: mi/mi-cmd-break.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmd-break.c,v retrieving revision 1.20 diff -u -r1.20 mi-cmd-break.c --- mi/mi-cmd-break.c 25 Jun 2008 15:15:41 -0000 1.20 +++ mi/mi-cmd-break.c 22 Jul 2008 00:34:56 -0000 @@ -24,32 +24,32 @@ #include "breakpoint.h" #include "gdb_string.h" #include "mi-getopt.h" -#include "gdb-events.h" #include "gdb.h" #include "exceptions.h" +#include "observer.h" enum { FROM_TTY = 0 }; -/* Output a single breakpoint. */ +/* True if MI breakpoint observers have been registered. */ + +static int mi_breakpoint_observers_installed; + +/* Control whether breakpoint_notify may act. */ + +static int mi_can_breakpoint_notify; + +/* Output a single breakpoint, when allowed. */ static void breakpoint_notify (int b) { - gdb_breakpoint_query (uiout, b, NULL); + if (mi_can_breakpoint_notify) + gdb_breakpoint_query (uiout, b, NULL); } - -struct gdb_events breakpoint_hooks = -{ - breakpoint_notify, - breakpoint_notify, - breakpoint_notify, -}; - - enum bp_type { REG_BP, @@ -132,7 +132,15 @@ address = argv[optind]; /* Now we have what we need, let's insert the breakpoint! */ - old_hooks = deprecated_set_gdb_event_hooks (&breakpoint_hooks); + if (! mi_breakpoint_observers_installed) + { + observer_attach_breakpoint_created (breakpoint_notify); + observer_attach_breakpoint_modified (breakpoint_notify); + observer_attach_breakpoint_deleted (breakpoint_notify); + mi_breakpoint_observers_installed = 1; + } + + mi_can_breakpoint_notify = 1; /* Make sure we restore hooks even if exception is thrown. */ TRY_CATCH (e, RETURN_MASK_ALL) { @@ -163,7 +171,7 @@ _("mi_cmd_break_insert: Bad switch.")); } } - deprecated_set_gdb_event_hooks (old_hooks); + mi_can_breakpoint_notify = 0; if (e.reason < 0) throw_exception (e); } Index: tui/tui-hooks.c =================================================================== RCS file: /cvs/src/src/gdb/tui/tui-hooks.c,v retrieving revision 1.37 diff -u -r1.37 tui-hooks.c --- tui/tui-hooks.c 1 Jan 2008 22:53:22 -0000 1.37 +++ tui/tui-hooks.c 22 Jul 2008 00:34:56 -0000 @@ -31,7 +31,6 @@ #include "event-top.h" #include "frame.h" #include "breakpoint.h" -#include "gdb-events.h" #include "ui-out.h" #include "top.h" #include "observer.h" @@ -157,23 +156,6 @@ tui_update_all_breakpoint_info (); } -static void -tui_event_default (int number) -{ - ; -} - -static struct gdb_events *tui_old_event_hooks; - -static struct gdb_events tui_event_hooks = { - tui_event_create_breakpoint, - tui_event_delete_breakpoint, - tui_event_modify_breakpoint, - tui_event_default, - tui_event_default, - tui_event_default -}; - /* Called when going to wait for the target. Leave curses mode and setup program mode. */ static ptid_t @@ -262,6 +244,11 @@ tui_display_main (); } +/* Observers created when installing TUI hooks. */ +static struct observer *tui_bp_created_observer; +static struct observer *tui_bp_deleted_observer; +static struct observer *tui_bp_modified_observer; + /* Install the TUI specific hooks. */ void tui_install_hooks (void) @@ -273,7 +260,12 @@ deprecated_query_hook = tui_query_hook; /* Install the event hooks. */ - tui_old_event_hooks = deprecated_set_gdb_event_hooks (&tui_event_hooks); + tui_bp_created_observer + = observer_attach_breakpoint_created (tui_event_create_breakpoint); + tui_bp_deleted_observer + = observer_attach_breakpoint_deleted (tui_event_delete_breakpoint); + tui_bp_modified_observer + = observer_attach_breakpoint_modified (tui_event_modify_breakpoint); deprecated_register_changed_hook = tui_register_changed_hook; deprecated_detach_hook = tui_detach_hook; @@ -290,8 +282,13 @@ deprecated_register_changed_hook = 0; deprecated_detach_hook = 0; - /* Restore the previous event hooks. */ - deprecated_set_gdb_event_hooks (tui_old_event_hooks); + /* Remove our observers. */ + observer_detach_breakpoint_created (tui_bp_created_observer); + tui_bp_created_observer = NULL; + observer_detach_breakpoint_deleted (tui_bp_deleted_observer); + tui_bp_deleted_observer = NULL; + observer_detach_breakpoint_modified (tui_bp_modified_observer); + tui_bp_modified_observer = NULL; } void _initialize_tui_hooks (void);