This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] New Event Model Prototype


Fernando & Keith,

This seems like a good change.  The only thing I wonder about is if 
there will ever be an agent that needs to listen to notifications that 
is NOT a GUI element?  Hanging the methods off GDBWin forces this to be 
the case.  It might be cleaner to make a GDBNotification class, and have 
GDBWin inherit from that (as well as ManagedWin).  That way, if you got 
a non-window class that needed to listen to these as well, it could also 
inherit from GDBNotification.  It also means that the place to go to 
look up the hooks has ONLY the hooks for notification, and no noise from 
other stuff that might be good to put in GDBWin.

Jim

P.S. When Martin & I first talked about the whole GDBWin thing, it was 
with the notion of using it for this sort of stuff, but I didn't at the 
time think about whether ONLY windows would want this capability...  Now 
I give it another thunk, I thought maybe tying them this closely is not 
so good.

Jim

On Thursday, April 12, 2001, at 07:11 AM, Fernando Nasser wrote:

> FYI: Keith has already explained this to me personally when he visited
> Toronto some time ago.
>
> We are asking for some comments.  Keith will probably start making these
> changes sometime next week.
>
> Here is some background:
>
> The Insight events are handled in a publish-subscribe model.  Current
> you subscribe in your constructor with something like:
>
> add_hook gdb_update_hook "$this update"
>
> and have to explicitly unsubscribe in you destructor.
>
> When an event happens, the "run_hooks" code (hooks.tcl) will notify all
> that subscribed to that event.
>
> Keith's idea is to use the itcl machinery as the manager of
> subscriptions and the dispatcher.  You will now subscribe by overloading
> a method and the dispatch will figure who subscribed by introspection in
> the itcl object metadata:
>
>  foreach w [itcl_info objects -isa GDBWin] {
>
>
> As this is implemented in C, we hope that the performance will be good.
>
>
> Nothing else changes: the code in interface.c still plays the "Change
> Manager" (or "Mediator") role.  It will still convert GDB events, or
> internally generated events, into notifications to the subscribed
> observers (sent via GDBWin).
>
>
> For now, we will continue with the somewhat ad hoc set of events and
> confuse notion of observed subjects.  This is an independent work that
> has to be done eventually. It will require a very careful planning
> involving the GDB people in the discussion.
>
> Fernando
>
>
> Keith Seitz wrote:
>>
>> 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
>>  }
>>
>>  # ------------------------------------------------------------------
>
> --
> Fernando Nasser
> Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
> 2323 Yonge Street, Suite #300
> Toronto, Ontario   M4P 2C9

--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]