Skip to content

Commit

Permalink
Add a "printf only on failure" event handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
trombonehero committed Jun 20, 2013
1 parent 44d872f commit 281bd0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/libtesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ int tesla_set_event_handlers(struct tesla_event_metahandler *);

#ifdef _KERNEL
#define TESLA_KERN_PRINTF_EV 0x1
#define TESLA_KERN_DTRACE_EV 0x2
#define TESLA_KERN_PANIC_EV 0x4
#define TESLA_KERN_PRINTERR_EV 0x2
#define TESLA_KERN_DTRACE_EV 0x4
#define TESLA_KERN_PANIC_EV 0x8
#endif

/** @} */
Expand Down
15 changes: 13 additions & 2 deletions libtesla/src/tesla_notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ static const struct tesla_event_handlers printf_handlers = {
.teh_ignored = print_ignored,
};

static const struct tesla_event_handlers printf_on_failure = {
.teh_init = ev_noop,
.teh_transition = ev_noop,
.teh_clone = ev_noop,
.teh_fail_no_instance = print_no_instance,
.teh_bad_transition = print_bad_transition,
.teh_err = print_error,
.teh_accept = ev_noop,
.teh_ignored = ev_noop,
};

/*
* Wrappers that panic on failure:
Expand Down Expand Up @@ -347,6 +357,7 @@ static const struct tesla_event_handlers failstop_handlers = {
*/
const static struct tesla_event_handlers* const default_handlers[] = {
&printf_handlers,
&printf_on_failure,
#if defined(_KERNEL) && defined(KDTRACE_HOOKS)
&dtrace_handlers,
#endif
Expand All @@ -356,9 +367,9 @@ const static struct tesla_event_handlers* const default_handlers[] = {
static struct tesla_event_metahandler default_event_handlers = {
.tem_length = sizeof(default_handlers) / sizeof(*default_handlers),
#if defined(_KERNEL) && defined(KDTRACE_HOOKS)
.tem_mask = 0x2,
.tem_mask = TESLA_KERN_DTRACE_EV,
#else
.tem_mask = 0x3,
.tem_mask = 0x5,
#endif
.tem_handlers = default_handlers,
};
Expand Down

0 comments on commit 281bd0e

Please sign in to comment.