This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[RFA] New Event Model - Part A (revised)
- To: Fernando Nasser <fnasser at cygnus dot com>, James Ingham <jingham at cygnus dot com>
- Subject: [RFA] New Event Model - Part A (revised)
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Wed, 18 Apr 2001 14:17:16 -0700 (PDT)
- cc: Insight Maling List <insight at sources dot redhat dot com>
Hi,
Ok, so I think I've got it. Here's the big overview:
. There is a basic event class, GDBEvent, from which all events should
inherit.
. Anyone wanting to listen to events should inherit from GDBEventHandler.
GDBWins automatically inherit from GDBEventHandler.
. The glue in interface.tcl which is called from C-land to fire
an event should create an event, dispatch it, and then delete the event.
. I've implemented BreakpointEvent and TracepointEvent classes.
Unfortunately, I took the time to "do it right" (IMO), and it required
some rewriting of SrcTextWin. But while I was at it, I fixed a lot of
bugs regarding duplicate breakpoints (which were ONLY handled in SOURCE
mode -- they now work in all modes).
So this mega-patch comes in two parts... Part A (this part) covers the
new event model, which is in the files gdbevent.it[hb] and
ehandler.it[hb].
Part B will cover the actual usage of the new model, including the
changes needed to make BreakpointEvents and TracepointEvents work. This
will serve as an example of how we need to procede.
Please send me any final feedback. I've spent a lot of time getting this
to work with breakpoints, and I've also made MASSIVE changes compared to
my original proposal, which mearly added some of this. This represents a
completely new event model, and some of the hooks and supporting commands
have changed (or will change) to support it.
So, here we go.... All files indexed with "+++ File: <filename>".
+++ File: gdbevent.ith
# GDBEvent class definitions 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.
class GDBEvent {
protected variable _eventData
public method get {{what {*}}}
public method handler {} { return "unknown" }
}
# BREAKPOINT EVENT
#
# _eventData:
# action ....... what type of BP event ("create", "delete", "modify")
# number ....... gdb's internal token for the BP
# file ......... filename in which event occurred
# function ..... function in which event occurred
# line ......... line number in file
# address ...... address of BP
# type ......... breakpoint type ("breakpoint", "hw breakpoint", "step resume", etc)
# enabled ...... BP enabled?
# disposition .. BP's disposition ("delete", "delstop", "disable", "donttouch")
# ignore_count . BP's ignore count
# commands ..... list of commands to run when BP hit
# condition .... BP condition
# thread ....... thread in which BP is set (or -1 for all threads)
# hit_count .... number of times BP has been hit
class BreakpointEvent {
inherit GDBEvent
# Action: "create", "modify", "delete"
public variable action
# Gdb's internal token for the breakpoint
public variable number
# For reasons unknown to me, I cannot put this in the implementation
# file. The very first instance of the class will call this empty
# constructor instead of the one defined in the implementation file.
#constructor {args} {}
constructor {args} {
eval configure $args
#dbug I "action=$action, number=$number"
set _eventData(action) $action
set _eventData(number) $number
# If creating/modifying a breakpoint, then get
# all info about it and save it away.
set bpinfo [gdb_get_breakpoint_info $number]
lassign $bpinfo \
_eventData(file) \
_eventData(function) \
_eventData(line) \
_eventData(address) \
_eventData(type) \
_eventData(enabled) \
_eventData(disposition) \
_eventData(ignore_count) \
_eventData(commands) \
_eventData(condition) \
_eventData(thread) \
_eventData(hit_count)
}
#destructor { dbug I "" }
public method handler {} { return "breakpoint" }
}
# TRACEPOINT EVENT
#
# _eventData:
# action ....... what type of BP event ("create", "delete", "modify")
# number ....... gdb's internal token for the BP
# file ......... filename in which event occurred
# function ..... function in which event occurred
# line ......... line number in file
# address ...... address of BP
# enabled ...... BP enabled?
# pass_count ...
# step_count ...
# thread ....... thread in which BP is set (or -1 for all threads)
# hit_count .... number of times BP has been hit
# actions ...... a list of actions to be performed when the tracepoint is hit
class TracepointEvent {
inherit BreakpointEvent
# For reasons unknown to me, I cannot put this in the implementation
# file. The very first instance of the class will call this empty
# constructor instead of the one defined in the implementation file.
#constructor {args} {}
constructor {args} {
eval configure $args
set _eventData(action) $action
set _eventData(number) $number
# If creating/modifying a tracepoint, then get
# all info about it and save it away.
set tpinfo [gdb_get_tracepoint_info $number]
lassign $tpinfo \
_eventData(file) \
_eventData(function) \
_eventData(line) \
_eventData(address) \
_eventData(enabled) \
_eventData(pass_count) \
_eventData(step_count) \
_eventData(thread) \
_eventData(hit_count) \
_eventData(actions)
}
#destructor { dbug I "" }
public method handler {} { return "tracepoint" }
}
+++ File: gdbevent.itb
# GDB event class implementations 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 GDBEvent::get {{what {*}}} {
return [array get _eventData $what]
}
+++ File: ehandler.ith
# GDBEventHandler class definition 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.
class GDBEventHandler {
constructor {args} {}
destructor {}
# Dispatching proc. ALL events should be funneled through this
# procedure.
public proc dispatch {event}
#
# Events
#
# See gdbevent.ith for descriptions of event
public {
# Breakpiont/tracepoint events
method breakpoint {event} {}
method tracepoint {event} {}
}
}
+++ File: ehandler.itb
# GDBEventHandler 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 GDBEventHandler::dispatch {event} {
set handler [$event handler]
# invoke event handlers
foreach w [itcl_info objects -isa GDBEventHandler] {
dbug I "posting event \"$handler\" to \"$w\""
set err [catch {$w $handler $event} errMsg]
if {$err} {
dbug E "On $handler event, $w errored:\n$errMsg\n$::errorInfo"
}
}
}