This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[RFA] New Event Model Prototype
- To: Insight Maling List <insight at sources dot redhat dot com>
- Subject: [RFA] New Event Model Prototype
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Tue, 10 Apr 2001 09:46:20 -0700 (PDT)
Hi,
At long last, I have gotten around to doing a little work on this.
Here is the first part of my proposal to change from "add/remove_hook
FOO_EVENT command" to simply overloading a method inherited from GDBWin.
Comments enjoyed. More comments interspersed with patches. Look for "%%%".
Keith
I've ommitted bits and pieces of the "real" patch to help people digest
this change a little. There are also pending changes to bpwin.it[hb] and
srctextwin.it[hb].
2001-04-10 Keith Seitz <keiths@cygnus.com>
* library/interface.tcl (gdb_breakpoint_change_hook): Mark
as deprecated and comment out definition.
(gdbtk_tcl_breakpoint): Use new GDBWin event "breakpoint"
to notify rest of UI about breakpoint event.
(gdbtk_tcl_tracepoint): Ditto for "tracepoint" event.
* library/gdbwin.ith (dispatch): New public proc.
(breakpoint): New public proc.
(tracepoint): New public proc.
(update): Delete unused method. Will come
back later.
(_state): Delete unused variable.
(constructor): Delete debug statement.
(destructor): Ditto.
* library/gdbwin.itb: New file. Implements new event
model.
* tclIndex: Regenerated.
Index: library/gdbwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/gdbwin.ith,v
retrieving revision 1.2
diff -p -u -r1.2 gdbwin.ith
--- gdbwin.ith 2001/02/08 19:26:31 1.2
+++ gdbwin.ith 2001/04/10 15:54:44
@@ -13,14 +13,30 @@
class GDBWin {
- private variable _state
- public method update
- constructor {args} {
- debug "$args"
- }
+ constructor {args} {}
+ destructor {}
- destructor {
- debug
+ #
+ # Events
+ #
+ public {
+ # Dispatching proc. ALL events should be funneled through this
+ # procedure.
+ proc dispatch {event args}
+
+ # Breakpiont/tracepoint creation/deletion/modification
+ # ACTION - "create", "modify", "delete"
+ # NUM - gdb's internal token for the bp/tp
+ # ADDR - the address at which the breakpoint is set
+ # LINE - line number of this address
+ # FILE - source file name containing the address
+ # TYPE - what gdb will do with bp/tp: "delete", "delstop",
+ # "disable", "donttouch" (see breakpoint.h "enum bpdisp")
+ # ENABLED - is the bp/tp enabled?
+ # THREAD - thread number of thread-specific bp or -1 if don't care
+ # PASSCOUNT - pass count of the tracepoint
+ method breakpoint {action num addr line file type enabled thread} {}
+ method tracepoint {action num addr line file passcount} {}
}
}
%%% I've chosen to start with breakpoints/tracepoints. So the idea is
that when I (a window/widget/plugin writer) want to know about some event
FOO, is simply override a method of GDBWin which corresponds to FOO. ALL
of these events should be defined in this header file. Right now, I am
starting with breakpoint and tracepoint events.
gdbwin.itb (which is new):
# GDBwin class implementation for Insight.
# Copyright 2001 Red Hat, Inc
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
# the Free Software Foundation; either version 2 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.
body GDBWin::dispatch {event args} {
# Determine what event handler to call.
switch $event {
breakpoint { set handler breakpoint }
tracepoint { set handler tracepoint }
default { dbug E "unknown event: \"$event\""; return }
}
# invoke event handlers
foreach w [itcl_info objects -isa GDBWin] {
dbug I "posting event \"$event\" to \"$w\""
set err [catch {eval $w $handler $args} errMsg]
if {$err} {
dbug E "On $event event, $w errored:\n$errMsg"
}
}
}
%%% In gdbwin.itb, we simply have the all-important dispatch proc, which
will be replacing "run_hooks" in interface.tcl (see interface.tcl patch
below). I've included some error handling and debugging here to
facilitate flushing out any potential problems. This is pretty defensive
code (since I don't trust gdb ;-).
Index: library/interface.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
retrieving revision 1.15
diff -p -u -r1.15 interface.tcl
--- interface.tcl 2001/04/05 00:04:28 1.15
+++ interface.tcl 2001/04/10 15:55:27
@@ -16,9 +16,10 @@
global gdbtk_state
set gdbtk_state(busyCount) 0
+# *** DEPRECATED: Use GDBWin::dispatch event "breakpoint" instead.
# This is run when a breakpoint changes. The arguments are the
# action, the breakpoint number, and the breakpoint info.
-define_hook gdb_breakpoint_change_hook
+#define_hook gdb_breakpoint_change_hook
# This is run when a `set' command successfully completes in gdb. The
# first argument is the gdb variable name (as a Tcl list). The second
@@ -445,7 +446,7 @@ proc gdbtk_tcl_end_variable_annotation {
# ------------------------------------------------------------------
proc gdbtk_tcl_breakpoint {action bpnum addr line file bp_type enabled thread} {
# debug "BREAKPOINT: $action $bpnum $addr $line $file $bp_type $enabled $thread "
- run_hooks gdb_breakpoint_change_hook $action $bpnum $addr $line $file $bp_type $enabled $thread
+ GDBWin::dispatch breakpoint $action $bpnum $addr $line $file $bp_type $enabled $thread
}
# ------------------------------------------------------------------
@@ -453,7 +454,7 @@ proc gdbtk_tcl_breakpoint {action bpnum
# ------------------------------------------------------------------
proc gdbtk_tcl_tracepoint {action tpnum addr line file pass_count} {
# debug "TRACEPOINT: $action $tpnum $addr $line $file $pass_count"
- run_hooks gdb_breakpoint_change_hook $action $tpnum $addr $line $file tracepoint
+ GDBWin::dispatch tracepoint $action $tpnum $addr $line $file $pass_count
}
# ------------------------------------------------------------------