From 14236daaf6bb29ea5120e5856ab75920bfb677c1 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 10 Mar 2006 17:52:23 +0000 Subject: [PATCH] basic functions stats, sums not done git-svn-id: http://ltt.polymtl.ca/svn@1676 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/state.c | 1 + ltt/branches/poly/lttv/lttv/state.h | 11 ++-- ltt/branches/poly/lttv/lttv/stats.c | 78 ++++++++++++++++++++++++++--- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 6bd0b271..b895fa9f 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -1107,6 +1107,7 @@ static gint search_usertrace(gconstpointer a, gconstpointer b) } return -1; } + return 0; } static LttvTracefileState *ltt_state_usertrace_find(LttvTraceState *tcs, diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index b4fa430f..35e17339 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -60,7 +60,8 @@ extern GQuark LTT_FACILITY_KERNEL_ARCH, LTT_FACILITY_PROCESS, LTT_FACILITY_FS, - LTT_FACILITY_STATEDUMP; + LTT_FACILITY_STATEDUMP, + LTT_FACILITY_USER_GENERIC; /* Events Quarks */ @@ -79,7 +80,9 @@ extern GQuark LTT_EVENT_EXIT, LTT_EVENT_FREE, LTT_EVENT_EXEC, - LTT_EVENT_ENUM_PROCESS_STATE; + LTT_EVENT_ENUM_PROCESS_STATE, + LTT_EVENT_FUNCTION_ENTRY, + LTT_EVENT_FUNCTION_EXIT; /* Fields Quarks */ @@ -98,7 +101,9 @@ extern GQuark LTT_FIELD_NAME, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, - LTT_FIELD_STATUS; + LTT_FIELD_STATUS, + LTT_FIELD_THIS_FN, + LTT_FIELD_CALL_SITE; typedef struct _LttvTracesetState LttvTracesetState; typedef struct _LttvTracesetStateClass LttvTracesetStateClass; diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index 06f6fa39..6117e112 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -31,6 +31,7 @@ #include #define BUF_SIZE 256 +#define MAX_64_HEX_STRING_LEN 19 GQuark LTTV_STATS_PROCESS_UNKNOWN, @@ -54,6 +55,7 @@ GQuark static void find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu, + guint64 function, GQuark mode, GQuark sub_mode, LttvAttribute **events_tree, LttvAttribute **event_types_tree); @@ -120,6 +122,7 @@ static void lttv_stats_init(LttvTracesetStats *self) ltt_tracefile_long_name(tfcs->parent.parent.tf)); find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN, ltt_tracefile_long_name(tfcs->parent.parent.tf), + 0x0ULL, LTTV_STATE_MODE_UNKNOWN, LTTV_STATE_SUBMODE_UNKNOWN, &tfcs->current_events_tree, &tfcs->current_event_types_tree); @@ -393,18 +396,26 @@ static void find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu, + guint64 function, GQuark mode, GQuark sub_mode, LttvAttribute **events_tree, LttvAttribute **event_types_tree) { LttvAttribute *a; + gchar fstring[MAX_64_HEX_STRING_LEN]; + + g_assert(snprintf(fstring, MAX_64_HEX_STRING_LEN-1, + "0x%llX", function) > 0); + fstring[MAX_64_HEX_STRING_LEN-1] = '\0'; LttvTraceStats *tcs = (LttvTraceStats*)tfcs->parent.parent.t_context; a = lttv_attribute_find_subdir(tcs->stats, LTTV_STATS_PROCESSES); a = lttv_attribute_find_subdir(a, pid_time); a = lttv_attribute_find_subdir(a, LTTV_STATS_CPU); a = lttv_attribute_find_subdir(a, cpu); + a = lttv_attribute_find_subdir(a, LTTV_STATS_FUNCTIONS); + a = lttv_attribute_find_subdir(a, g_quark_from_string(fstring)); a = lttv_attribute_find_subdir(a, LTTV_STATS_MODE_TYPES); a = lttv_attribute_find_subdir(a, mode); a = lttv_attribute_find_subdir(a, LTTV_STATS_SUBMODES); @@ -423,7 +434,8 @@ static void update_event_tree(LttvTracefileStats *tfcs) LttvExecutionState *es = process->state; find_event_tree(tfcs, process->pid_time, - ltt_tracefile_long_name(tfcs->parent.parent.tf), + ltt_tracefile_long_name(tfcs->parent.parent.tf), + process->current_function, es->t, es->n, &(tfcs->current_events_tree), &(tfcs->current_event_types_tree)); } @@ -578,6 +590,30 @@ gboolean after_soft_irq_exit(void *hook_data, void *call_data) return FALSE; } +gboolean before_function_entry(void *hook_data, void *call_data) +{ + mode_end((LttvTracefileStats *)call_data); + return FALSE; +} + +gboolean after_function_entry(void *hook_data, void *call_data) +{ + update_event_tree((LttvTracefileStats *)call_data); + return FALSE; +} + +gboolean before_function_exit(void *hook_data, void *call_data) +{ + mode_end((LttvTracefileStats *)call_data); + return FALSE; +} + +gboolean after_function_exit(void *hook_data, void *call_data) +{ + update_event_tree((LttvTracefileStats *)call_data); + return FALSE; +} + gboolean before_schedchange(void *hook_data, void *call_data) { @@ -610,6 +646,7 @@ gboolean before_schedchange(void *hook_data, void *call_data) find_event_tree(tfcs, process->pid_time, ltt_tracefile_long_name(tfcs->parent.parent.tf), + process->current_function, process->state->t, process->state->n, &(tfcs->current_events_tree), &(tfcs->current_event_types_tree)); @@ -832,8 +869,8 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) /* Find the eventtype id for the following events and register the associated by id hooks. */ - hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 9); - g_array_set_size(hooks, 9); + hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 11); + g_array_set_size(hooks, 11); hn=0; ret = lttv_trace_find_hook(ts->parent.parent.t, @@ -898,12 +935,27 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) before_schedchange, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; + + ret = lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, + LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, + before_function_entry, NULL, + &g_array_index(hooks, LttvTraceHook, hn++)); + if(ret) hn--; + + ret = lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, + LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, + before_function_exit, NULL, + &g_array_index(hooks, LttvTraceHook, hn++)); + if(ret) hn--; + g_array_set_size(hooks, hn); before_hooks = hooks; - hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 11); - g_array_set_size(hooks, 11); + hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 13); + g_array_set_size(hooks, 13); hn=0; ret = lttv_trace_find_hook(ts->parent.parent.t, @@ -983,6 +1035,20 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self) &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; + ret = lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, + LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, + after_function_entry, NULL, + &g_array_index(hooks, LttvTraceHook, hn++)); + if(ret) hn--; + + ret = lttv_trace_find_hook(ts->parent.parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, + LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, + after_function_exit, NULL, + &g_array_index(hooks, LttvTraceHook, hn++)); + if(ret) hn--; + g_array_set_size(hooks, hn); after_hooks = hooks; @@ -1115,7 +1181,7 @@ static void module_init() LTTV_STATS_MODE_TYPES = g_quark_from_string("mode_types"); LTTV_STATS_MODES = g_quark_from_string("modes"); LTTV_STATS_SUBMODES = g_quark_from_string("submodes"); - LTTV_STATS_SUBMODES = g_quark_from_string("functions"); + LTTV_STATS_FUNCTIONS = g_quark_from_string("functions"); LTTV_STATS_EVENT_TYPES = g_quark_from_string("event_types"); LTTV_STATS_CPU_TIME = g_quark_from_string("cpu time"); LTTV_STATS_ELAPSED_TIME = g_quark_from_string("elapsed time"); -- 2.34.1