fix marker id off by one
[lttv.git] / ltt / branches / poly / lttv / lttv / stats.c
index 179fde3f0de21ac9e01e4cb8a048a4ce835662cb..0bfb45462d9d6eee7fa5207b795afb36a3f2acb5 100644 (file)
 #include <lttv/stats.h>
 #include <lttv/lttv.h>
 #include <lttv/attribute.h>
-#include <ltt/facility.h>
 #include <ltt/trace.h>
 #include <ltt/event.h>
-#include <ltt/type.h>
 
 #define BUF_SIZE 256
 #define MAX_64_HEX_STRING_LEN 19
@@ -69,18 +67,12 @@ static void lttv_stats_init(LttvTracesetStats *self)
 
   LttvTraceStats *tcs;
 
-  LttvTracefileContext *tfc;
-
   LttvTracefileContext **tfs;
   LttvTracefileStats *tfcs;
   
-  LttTime timestamp = {0,0};
-
   LttvAttributeValue v;
 
-  LttvAttribute
-    *stats_tree,
-    *tracefiles_stats;
+  LttvAttribute *tracefiles_stats;
 
   LttvTraceset *ts = self->parent.parent.ts;
 
@@ -147,8 +139,6 @@ static void lttv_stats_fini(LttvTracesetStats *self)
 
   LttvTracefileStats *tfcs;
   
-  LttTime timestamp = {0,0};
-
   LttvAttributeValue v;
 
   LttvAttribute *tracefiles_stats;
@@ -403,7 +393,7 @@ find_event_tree(LttvTracefileStats *tfcs,
                 LttvAttribute **events_tree, 
                 LttvAttribute **event_types_tree)
 {
-  LttvAttribute *a, *prev_a;
+  LttvAttribute *a;
   gchar fstring[MAX_64_HEX_STRING_LEN];
   gint ret;
 
@@ -464,7 +454,7 @@ static void mode_change(LttvTracefileStats *tfcs)
   LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
   guint cpu = tfcs->parent.cpu;
   LttvProcessState *process = ts->running_process[cpu];
-  LttvAttributeValue cpu_time, cum_cpu_time;
+  LttvAttributeValue cpu_time;
 
   LttTime delta;
 
@@ -536,7 +526,6 @@ static void after_mode_end(LttvTracefileStats *tfcs)
   LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
   guint cpu = tfcs->parent.cpu;
   LttvProcessState *process = ts->running_process[cpu];
-  LttvAttributeValue cum_cpu_time;
 
   LttTime nested_delta;
 
@@ -686,19 +675,17 @@ static gboolean before_schedchange(void *hook_data, void *call_data)
 {
   LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data;
 
-  LttvTraceState *ts = (LttvTraceState*)tfcs->parent.parent.t_context;
-
   LttEvent *e = ltt_tracefile_get_event(tfcs->parent.parent.tf);
 
-  LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
+  LttvTraceHook *th = (LttvTraceHook *)hook_data;
 
   guint pid_in, pid_out;
     
-  gint state_out;
+  gint64 state_out;
 
-  pid_out = ltt_event_get_unsigned(e, thf->f1);
-  pid_in = ltt_event_get_unsigned(e, thf->f2);
-  state_out = ltt_event_get_int(e, thf->f3);
+  pid_out = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
+  pid_in = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
+  state_out = ltt_event_get_long_int(e, lttv_trace_get_hook_field(th, 2));
 
   /* compute the time for the process to schedule out */
   mode_change(tfcs);
@@ -714,17 +701,17 @@ static gboolean after_schedchange(void *hook_data, void *call_data)
 
   LttEvent *e = ltt_tracefile_get_event(tfcs->parent.parent.tf);
 
-  LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
+  LttvTraceHook *th = (LttvTraceHook *)hook_data;
 
   guint pid_in, pid_out;
     
-  gint state_out;
+  gint64 state_out;
 
   LttvProcessState *process;
 
-  pid_out = ltt_event_get_unsigned(e, thf->f1);
-  pid_in = ltt_event_get_unsigned(e, thf->f2);
-  state_out = ltt_event_get_int(e, thf->f3);
+  pid_out = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
+  pid_in = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
+  state_out = ltt_event_get_long_int(e, lttv_trace_get_hook_field(th, 2));
 
   /* get the information for the process scheduled in */
   guint cpu = tfcs->parent.cpu;
@@ -794,14 +781,19 @@ static gboolean every_event(void *hook_data, void *call_data)
 
   LttvAttributeValue v;
 
+  LttTrace *trace = ((LttvTracefileContext *)tfcs)->t_context->t;
+
+  struct marker_info *info;
+
   /* The current branch corresponds to the tracefile/process/interrupt state.
      Statistics are added within it, to count the number of events of this
      type occuring in this context. A quark has been pre-allocated for each
      event type and is used as name. */
 
+  info = marker_get_info_from_id(trace, e->event_id);
+
   lttv_attribute_find(tfcs->current_event_types_tree, 
-      ltt_eventtype_name(ltt_event_eventtype(e)), 
-      LTTV_UINT, &v);
+      info->name, LTTV_UINT, &v);
   (*(v.v_uint))++;
   return FALSE;
 }
@@ -819,11 +811,8 @@ static void lttv_stats_cleanup_process_state(gpointer key, gpointer value,
   struct cleanup_state_struct *cleanup_closure =
     (struct cleanup_state_struct *)user_data;
   LttvTraceState *ts = cleanup_closure->ts;
-  LttvTraceStats *tcs = (LttvTraceStats *)ts;
   LttvProcessState *process = (LttvProcessState *)value;
-  LttvTracesetContext *tsc = ts->parent.ts_context;
   LttTime current_time = cleanup_closure->current_time;
-  int i;
   LttvTracefileStats **tfs = (LttvTracefileStats **)
       &g_array_index(ts->parent.tracefiles, LttvTracefileContext*,
           process->cpu);
@@ -873,7 +862,7 @@ static void lttv_stats_cleanup_state(LttvTraceStats *tcs, LttTime current_time)
     lttv_stats_cleanup_process_state(ts, ts->running_process[i], current_time);
   }
 #endif //0
-  cleanup_closure.ts = tcs;
+  cleanup_closure.ts = ts;
   cleanup_closure.current_time = current_time;
   g_hash_table_foreach(ts->processes, lttv_stats_cleanup_process_state,
     &cleanup_closure);
@@ -1026,8 +1015,6 @@ lttv_stats_sum_traceset(LttvTracesetStats *self, LttTime current_time)
 
   int i, nb_trace;
 
-  LttvAttribute *main_tree;
-
   LttvAttributeValue value;
 
   lttv_attribute_find(sum_container, LTTV_STATS_SUMMED, 
@@ -1059,7 +1046,7 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self)
 {
   LttvTraceset *traceset = self->parent.parent.ts;
 
-  guint i, j, k, l, nb_trace, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceStats *ts;
 
@@ -1067,15 +1054,10 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self)
 
   GArray *hooks, *before_hooks, *after_hooks;
 
-  LttvTraceHook *hook;
-
-  LttvTraceHookByFacility *thf;
+  LttvTraceHook *th;
 
   LttvAttributeValue val;
 
-  gint ret;
-  gint hn;
-
   nb_trace = lttv_traceset_number(traceset);
   for(i = 0 ; i < nb_trace ; i++) {
     ts = (LttvTraceStats *)self->parent.parent.traces[i];
@@ -1084,216 +1066,208 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self)
        associated by id hooks. */
 
     hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 12);
-    g_array_set_size(hooks, 12);
-    hn=0;
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
-        LTT_FIELD_SYSCALL_ID, 0, 0,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL_ARCH,
+        LTT_EVENT_SYSCALL_EXIT,
+        NULL,
         before_syscall_exit, NULL, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY,
-        LTT_FIELD_TRAP_ID, 0, 0,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL_ARCH,
+        LTT_EVENT_TRAP_EXIT,
+        NULL,
         before_trap_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY,
-        LTT_FIELD_IRQ_ID, 0, 0,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL,
+        LTT_EVENT_IRQ_EXIT,
+        NULL,
         before_irq_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY,
-        LTT_FIELD_SOFT_IRQ_ID, 0, 0,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL,
+        LTT_EVENT_SOFT_IRQ_EXIT,
+        NULL,
         before_soft_irq_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE,
-        LTT_FIELD_OUT, LTT_FIELD_IN, LTT_FIELD_OUT_STATE,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    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,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    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,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
     /* statedump-related hooks */
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE,
-        LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
-
-    g_array_set_size(hooks, hn);
+        &hooks);
 
     before_hooks = hooks;
 
     hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 16);
-    g_array_set_size(hooks, 16);
-    hn=0;
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
-        LTT_FIELD_SYSCALL_ID, 0, 0,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL_ARCH,
+        LTT_EVENT_SYSCALL_EXIT,
+        NULL,
         after_syscall_exit, NULL, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, 
-        LTT_FIELD_TRAP_ID, 0, 0,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL_ARCH,
+        LTT_EVENT_TRAP_EXIT,
+        NULL,
         after_trap_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, 
-        LTT_FIELD_IRQ_ID, 0, 0,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL,
+        LTT_EVENT_IRQ_EXIT,
+        NULL,
         after_irq_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
-
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, 
-        LTT_FIELD_SOFT_IRQ_ID, 0, 0,
-        after_irq_entry, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
-
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT,
-        0, 0, 0,
+        &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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE,
-        LTT_FIELD_OUT, LTT_FIELD_IN, LTT_FIELD_OUT_STATE,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK, 
-        LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, 0,
+    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, 
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
-        LTT_FIELD_PID, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL,
+        LTT_EVENT_PROCESS_EXIT,
+        FIELD_ARRAY(LTT_FIELD_PID),
         process_exit, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
     
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE,
-        LTT_FIELD_PID, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_KERNEL,
+        LTT_EVENT_PROCESS_FREE,
+        FIELD_ARRAY(LTT_FIELD_PID),
         process_free, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    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,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    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,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
     /* statedump-related hooks */
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE,
-        LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+    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,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
+        &hooks);
 
-    ret = lttv_trace_find_hook(ts->parent.parent.t,
-        LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END,
-        0, 0, 0,
+    lttv_trace_find_hook(ts->parent.parent.t,
+        LTT_FACILITY_LIST,
+        LTT_EVENT_STATEDUMP_END,
+        NULL,
         after_statedump_end, NULL,
-        &g_array_index(hooks, LttvTraceHook, hn++));
-    if(ret) hn--;
-
-    g_array_set_size(hooks, hn);
+        &hooks);
 
     after_hooks = hooks;
 
@@ -1308,26 +1282,20 @@ void lttv_stats_add_event_hooks(LttvTracesetStats *self)
                      LTTV_PRIO_DEFAULT);
 
       for(k = 0 ; k < before_hooks->len ; k++) {
-        hook = &g_array_index(before_hooks, LttvTraceHook, k);
-        for(l = 0; l<hook->fac_list->len;l++) {
-          thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l);
-          lttv_hooks_add(
-              lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, thf->id),
-              thf->h,
-              thf,
-              LTTV_PRIO_STATS_BEFORE_STATE);
-        }
+        th = &g_array_index(before_hooks, LttvTraceHook, k);
+        lttv_hooks_add(
+            lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, th->id),
+            th->h,
+            th,
+            LTTV_PRIO_STATS_BEFORE_STATE);
       }
       for(k = 0 ; k < after_hooks->len ; k++) {
-        hook = &g_array_index(after_hooks, LttvTraceHook, k);
-        for(l = 0; l<hook->fac_list->len;l++) {
-          thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l);
-          lttv_hooks_add(
-              lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, thf->id),
-              thf->h,
-              thf,
-              LTTV_PRIO_STATS_AFTER_STATE);
-        }
+        th = &g_array_index(after_hooks, LttvTraceHook, k);
+        lttv_hooks_add(
+            lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, th->id),
+            th->h,
+            th,
+            LTTV_PRIO_STATS_AFTER_STATE);
       }
     }
     lttv_attribute_find(self->parent.parent.a, LTTV_STATS_BEFORE_HOOKS, 
@@ -1353,19 +1321,15 @@ void lttv_stats_remove_event_hooks(LttvTracesetStats *self)
 {
   LttvTraceset *traceset = self->parent.parent.ts;
 
-  guint i, j, k, l, nb_trace, nb_tracefile;
+  guint i, j, k, nb_trace, nb_tracefile;
 
   LttvTraceStats *ts;
 
   LttvTracefileStats *tfs;
 
-  void *hook_data;
-
   GArray *before_hooks, *after_hooks;
 
-  LttvTraceHook *hook;
-  
-  LttvTraceHookByFacility *thf;
+  LttvTraceHook *th;
 
   LttvAttributeValue val;
 
@@ -1390,27 +1354,24 @@ void lttv_stats_remove_event_hooks(LttvTracesetStats *self)
           NULL);
 
       for(k = 0 ; k < before_hooks->len ; k++) {
-        hook = &g_array_index(before_hooks, LttvTraceHook, k);
-        for(l = 0 ; l < hook->fac_list->len ; l++) {
-          thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l);
-          lttv_hooks_remove_data(
-              lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, thf->id),
-              thf->h,
-              thf);
-        }
+        th = &g_array_index(before_hooks, LttvTraceHook, k);
+        lttv_hooks_remove_data(
+            lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, th->id),
+            th->h,
+            th);
       }
       for(k = 0 ; k < after_hooks->len ; k++) {
-        hook = &g_array_index(after_hooks, LttvTraceHook, k);
-        for(l = 0 ; l < hook->fac_list->len ; l++) {
-          thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l);
-          lttv_hooks_remove_data(
-              lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, thf->id),
-              thf->h,
-              thf);
-        }
+        th = &g_array_index(after_hooks, LttvTraceHook, k);
+        lttv_hooks_remove_data(
+            lttv_hooks_by_id_find(tfs->parent.parent.event_by_id, th->id),
+            th->h,
+            th);
+        
       }
     }
     g_debug("lttv_stats_remove_event_hooks()");
+    lttv_trace_hook_remove_all(&before_hooks);
+    lttv_trace_hook_remove_all(&after_hooks);
     g_array_free(before_hooks, TRUE);
     g_array_free(after_hooks, TRUE);
   }
This page took 0.03594 seconds and 4 git commands to generate.