From 60c5092c6e979b8cc1c9b762de473857d0ac7c97 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 11 Oct 2007 03:44:21 +0000 Subject: [PATCH] add facility arg to find hooks git-svn-id: http://ltt.polymtl.ca/svn@2649 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/state.c | 25 +++++++++++++++++++ ltt/branches/poly/lttv/lttv/stats.c | 28 ++++++++++++++++++++++ ltt/branches/poly/lttv/lttv/tracecontext.c | 21 +++++++++++++++- ltt/branches/poly/lttv/lttv/tracecontext.h | 2 +- 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 92c2aec5..d1120c70 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -1633,6 +1633,7 @@ create_name_tables(LttvTraceState *tcs) hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 1); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), NULL, NULL, &hooks)) { @@ -1667,6 +1668,7 @@ create_name_tables(LttvTraceState *tcs) lttv_trace_hook_remove_all(&hooks); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), NULL, NULL, &hooks)) { @@ -1695,6 +1697,7 @@ create_name_tables(LttvTraceState *tcs) lttv_trace_hook_remove_all(&hooks); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), NULL, NULL, &hooks)) { @@ -3034,84 +3037,100 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) //hn = 0; lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), syscall_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT, NULL, syscall_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), trap_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT, NULL, trap_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT, NULL, irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_SOFT_IRQ_ID), soft_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT, NULL, soft_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE, FIELD_ARRAY(LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE), schedchange, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK, FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, LTT_FIELD_CHILD_TGID), process_fork, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_KTHREAD_CREATE, FIELD_ARRAY(LTT_FIELD_PID), process_kernel_thread, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT, FIELD_ARRAY(LTT_FIELD_PID), process_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE, FIELD_ARRAY(LTT_FIELD_PID), process_free, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_EXEC, FIELD_ARRAY(LTT_FIELD_FILENAME), process_exec, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_THREAD_BRAND, FIELD_ARRAY(LTT_FIELD_NAME), thread_brand, NULL, &hooks); /* statedump-related hooks */ lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE, FIELD_ARRAY(LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME, LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, @@ -3119,31 +3138,37 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) enum_process_state, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END, NULL, statedump_end, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_LIST_INTERRUPT, FIELD_ARRAY(LTT_FIELD_ACTION, LTT_FIELD_NUM), enum_interrupt, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_ISSUE, FIELD_ARRAY(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION), bdev_request_issue, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_COMPLETE, FIELD_ARRAY(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION), bdev_request_complete, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), function_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), function_exit, NULL, &hooks); diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index 3663cbce..0bfb4546 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -1068,66 +1068,77 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 12); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), before_syscall_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT, NULL, before_syscall_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), before_trap_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT, NULL, before_trap_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), before_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT, NULL, before_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_SOFT_IRQ_ID), before_soft_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT, NULL, before_soft_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE, FIELD_ARRAY(LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE), before_schedchange, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), before_function_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), before_function_exit, NULL, @@ -1135,6 +1146,7 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) /* statedump-related hooks */ lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE, FIELD_ARRAY(LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME), before_enum_process_state, NULL, @@ -1145,84 +1157,98 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 16); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), after_syscall_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT, NULL, after_syscall_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), after_trap_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT, NULL, after_trap_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), after_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT, NULL, after_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_SOFT_IRQ_ID), after_soft_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT, NULL, after_soft_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE, FIELD_ARRAY(LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE), after_schedchange, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK, FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID), process_fork, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT, FIELD_ARRAY(LTT_FIELD_PID), process_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE, FIELD_ARRAY(LTT_FIELD_PID), process_free, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), after_function_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), after_function_exit, NULL, @@ -1230,12 +1256,14 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) /* statedump-related hooks */ lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE, FIELD_ARRAY(LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME), after_enum_process_state, NULL, &hooks); lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END, NULL, after_statedump_end, NULL, diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 3a72ef8c..71c95987 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -968,13 +968,32 @@ struct marker_info *lttv_trace_hook_get_marker(LttTrace *t, LttvTraceHook *th) return marker_get_info_from_id(t, th->id); } +static inline GQuark lttv_merge_facility_event_name(GQuark fac, GQuark ev) +{ + char *tmp; + const char *sfac, *sev; + GQuark ret; + + sfac = g_quark_to_string(fac); + sev = g_quark_to_string(ev); + tmp = g_new(char, strlen(sfac) + strlen(sev) + 3); /* 3: _ \0 \0 */ + strcpy(tmp, sfac); + strcat(tmp, "_"); + strcat(tmp, sev); + ret = g_quark_from_string(tmp); + g_free(tmp); + return ret; +} -int lttv_trace_find_hook(LttTrace *t, GQuark marker_name, +int lttv_trace_find_hook(LttTrace *t, GQuark facility_name, GQuark event_name, GQuark fields[], LttvHook h, gpointer hook_data, GArray **trace_hooks) { struct marker_info *info; guint16 marker_id; int init_array_size; + GQuark marker_name; + + marker_name = lttv_merge_facility_event_name(facility_name, event_name); info = marker_get_info_from_name(t, marker_name); if(unlikely(info == NULL)) { diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 2ec68be0..ed1d28d6 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -298,7 +298,7 @@ void lttv_trace_hook_remove_all(GArray **th); Adds the hooks to the trace_hooks array. */ -int lttv_trace_find_hook(LttTrace *t, GQuark marker_name, +int lttv_trace_find_hook(LttTrace *t, GQuark facility_name, GQuark event_name, GQuark fields[], LttvHook h, gpointer hook_data, GArray **trace_hooks); static inline struct marker_field * -- 2.34.1