statistics working : still must add stats per time feature to graphical view
[lttv.git] / ltt / branches / poly / lttv / lttv / stats.c
index 53337786e3e84d6804957eed2f9aaa1ebb51e37f..bd9c1e6cab27d735bb8ef7e3806ec77ae21857ec 100644 (file)
@@ -58,8 +58,8 @@ find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu,
     GQuark mode, GQuark sub_mode, LttvAttribute **events_tree, 
     LttvAttribute **event_types_tree);
 
-static void
-init(LttvTracesetStats *self, LttvTraceset *ts)
+
+static void lttv_stats_init(LttvTracesetStats *self)
 {
   guint i, j, nb_trace, nb_tracefile;
 
@@ -80,8 +80,7 @@ init(LttvTracesetStats *self, LttvTraceset *ts)
     *stats_tree,
     *tracefiles_stats;
 
-  LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_STATE_TYPE))->
-      init((LttvTracesetContext *)self, ts);
+  LttvTraceset *ts = self->parent.parent.ts;
 
   self->stats = lttv_attribute_find_subdir(
                       lttv_traceset_attribute(self->parent.parent.ts),
@@ -119,17 +118,18 @@ init(LttvTracesetStats *self, LttvTraceset *ts)
                       LttvTracefileContext*, j);
       tfcs = LTTV_TRACEFILE_STATS(*tfs);
       tfcs->stats = lttv_attribute_find_subdir(tracefiles_stats, 
-          tfcs->parent.cpu_name);
+          ltt_tracefile_long_name(tfcs->parent.parent.tf));
       find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
-          tfcs->parent.cpu_name, LTTV_STATE_MODE_UNKNOWN, 
+          ltt_tracefile_long_name(tfcs->parent.parent.tf),
+          LTTV_STATE_MODE_UNKNOWN, 
           LTTV_STATE_SUBMODE_UNKNOWN, &tfcs->current_events_tree,
           &tfcs->current_event_types_tree);
     }
   }
+
 }
 
-static void
-fini(LttvTracesetStats *self)
+static void lttv_stats_fini(LttvTracesetStats *self)
 {
   guint i, j, nb_trace, nb_tracefile;
 
@@ -188,6 +188,32 @@ fini(LttvTracesetStats *self)
       tfcs->current_event_types_tree = NULL;
     }
   }
+}
+
+
+void lttv_stats_reset(LttvTracesetStats *self)
+{
+  lttv_stats_fini(self);
+  lttv_stats_init(self);
+}
+
+
+
+static void
+init(LttvTracesetStats *self, LttvTraceset *ts)
+{
+  LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_STATE_TYPE))->
+      init((LttvTracesetContext *)self, ts);
+  
+  lttv_stats_init(self);
+}
+
+
+static void
+fini(LttvTracesetStats *self)
+{
+  lttv_stats_fini(self);
+
   LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_STATE_TYPE))->
       fini((LttvTracesetContext *)self);
 }
@@ -392,10 +418,13 @@ find_event_tree(LttvTracefileStats *tfcs,
 
 static void update_event_tree(LttvTracefileStats *tfcs) 
 {
-  LttvExecutionState *es = tfcs->parent.process->state;
+  LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
+  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  LttvProcessState *process = ts->running_process[cpu];
+  LttvExecutionState *es = process->state;
 
-  find_event_tree(tfcs, tfcs->parent.process->pid_time,
-      tfcs->parent.cpu_name
+  find_event_tree(tfcs, process->pid_time,
+      ltt_tracefile_long_name(tfcs->parent.parent.tf)
       es->t, es->n, &(tfcs->current_events_tree), 
       &(tfcs->current_event_types_tree));
 }
@@ -403,6 +432,9 @@ static void update_event_tree(LttvTracefileStats *tfcs)
 
 static void mode_change(LttvTracefileStats *tfcs)
 {
+  LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
+  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  LttvProcessState *process = ts->running_process[cpu];
   LttvAttributeValue cpu_time; 
 
   LttTime delta;
@@ -410,13 +442,16 @@ static void mode_change(LttvTracefileStats *tfcs)
   lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_CPU_TIME, 
       LTTV_TIME, &cpu_time);
   delta = ltt_time_sub(tfcs->parent.parent.timestamp, 
-      tfcs->parent.process->state->change);
+      process->state->change);
   *(cpu_time.v_time) = ltt_time_add(*(cpu_time.v_time), delta);
 }
 
 
 static void mode_end(LttvTracefileStats *tfcs)
 {
+  LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
+  guint cpu = ltt_tracefile_num(tfcs->parent.parent.tf);
+  LttvProcessState *process = ts->running_process[cpu];
   LttvAttributeValue elapsed_time, cpu_time; 
 
   LttTime delta;
@@ -424,13 +459,13 @@ static void mode_end(LttvTracefileStats *tfcs)
   lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_ELAPSED_TIME, 
       LTTV_TIME, &elapsed_time);
   delta = ltt_time_sub(tfcs->parent.parent.timestamp, 
-      tfcs->parent.process->state->entry);
+      process->state->entry);
   *(elapsed_time.v_time) = ltt_time_add(*(elapsed_time.v_time), delta);
 
   lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_CPU_TIME, 
       LTTV_TIME, &cpu_time);
   delta = ltt_time_sub(tfcs->parent.parent.timestamp, 
-      tfcs->parent.process->state->change);
+      process->state->change);
   *(cpu_time.v_time) = ltt_time_add(*(cpu_time.v_time), delta);
 }
 
@@ -523,6 +558,8 @@ 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;
@@ -543,9 +580,11 @@ gboolean before_schedchange(void *hook_data, void *call_data)
 
   /* get the information for the process scheduled in */
 
-  process = lttv_state_find_process_or_create(&(tfcs->parent), pid_in);
+  process = lttv_state_find_process_or_create(ts, 
+      ANY_CPU, pid_in, &tfcs->parent.parent.timestamp);
 
-  find_event_tree(tfcs, process->pid_time, tfcs->parent.cpu_name, 
+  find_event_tree(tfcs, process->pid_time,
+      ltt_tracefile_long_name(tfcs->parent.parent.tf), 
       process->state->t, process->state->n, &(tfcs->current_events_tree), 
       &(tfcs->current_event_types_tree));
 
This page took 0.02529 seconds and 4 git commands to generate.