aboutsummaryrefslogtreecommitdiff
path: root/handle_event.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-07-09 11:29:42 +0200
committerPetr Machata <pmachata@redhat.com>2011-10-06 14:17:57 +0200
commit4007d74c2435ce4b50305d64ffe831627f989335 (patch)
tree1a2c59ffca585ce002ef6ebd07a66292e5933cad /handle_event.c
parent69a03e6f8c15fb0272089e387a658acad887fb9c (diff)
downloadltrace-4007d74c2435ce4b50305d64ffe831627f989335.tar.gz
Facility for custom event handler
Diffstat (limited to 'handle_event.c')
-rw-r--r--handle_event.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/handle_event.c b/handle_event.c
index a2b1dc2..f115fc7 100644
--- a/handle_event.c
+++ b/handle_event.c
@@ -39,6 +39,19 @@ void
handle_event(Event *event) {
debug(DEBUG_FUNCTION, "handle_event(pid=%d, type=%d)",
event->proc ? event->proc->pid : -1, event->type);
+ /* If the thread group defines an overriding event handler,
+ give it a chance to kick in. */
+ if (event->proc != NULL
+ && event->proc->leader != NULL) {
+ Event_Handler * handler = event->proc->leader->event_handler;
+ if (handler != NULL) {
+ event = (*handler->on_event) (handler, event);
+ if (event == NULL)
+ /* It was handled. */
+ return;
+ }
+ }
+
switch (event->type) {
case EVENT_NONE:
debug(1, "event: none");
@@ -208,6 +221,8 @@ handle_clone(Event * event) {
enable_breakpoint(p, p->breakpoint_being_enabled);
p->breakpoint_being_enabled = NULL;
}
+ if (p->event_handler != NULL)
+ destroy_event_handler(p);
if (event->proc->state == STATE_ATTACHED && options.follow) {
p->state = STATE_ATTACHED;
} else {
@@ -237,6 +252,8 @@ handle_new(Event * event) {
enable_breakpoint(proc, proc->breakpoint_being_enabled);
proc->breakpoint_being_enabled = NULL;
}
+ if (proc->event_handler != NULL)
+ destroy_event_handler(proc);
if (options.follow) {
proc->state = STATE_ATTACHED;
} else {