trying to introduce cumulative time
[lttv.git] / ltt / branches / poly / lttv / lttv / state.c
index 07ecfc46603e30cd67d76d11d5f141fb182e945e..8e80c943f462d48a11370f36af8949ab82919aa9 100644 (file)
@@ -510,8 +510,7 @@ static void copy_process_state(gpointer key, gpointer value,gpointer user_data)
     g_array_index(new_process->user_stack, guint64, i) =
         g_array_index(process->user_stack, guint64, i);
   }
-  new_process->current_function = &g_array_index(new_process->user_stack, 
-      guint64, new_process->user_stack->len - 1);
+  new_process->current_function = process->current_function;
   g_hash_table_insert(new_processes, new_process, new_process);
 }
 
@@ -1046,10 +1045,33 @@ static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
   es->t = t;
   es->n = state_id;
   es->entry = es->change = tfs->parent.timestamp;
+       es->cum_cpu_time = ltt_time_zero;
   es->s = process->state->s;
   process->state = es;
 }
 
+/* pop state
+ * return 1 when empty, else 0 */
+int lttv_state_pop_state_cleanup(LttvProcessState *process, 
+               LttvTracefileState *tfs)
+{ 
+       guint cpu = tfs->cpu;
+  LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
+
+  guint depth = process->execution_stack->len;
+
+  if(depth == 1){
+    return 1;
+  }
+
+  process->execution_stack = 
+    g_array_set_size(process->execution_stack, depth - 1);
+  process->state = &g_array_index(process->execution_stack, LttvExecutionState,
+      depth - 2);
+  process->state->change = tfs->parent.timestamp;
+       
+       return 0;
+}
 
 static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t)
 {
@@ -1193,6 +1215,7 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent,
   es->entry = *timestamp;
   //g_assert(timestamp->tv_sec != 0);
   es->change = *timestamp;
+       es->cum_cpu_time = ltt_time_zero;
   es->s = LTTV_STATE_RUN;
 
   es = process->state = &g_array_index(process->execution_stack, 
@@ -1202,6 +1225,7 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent,
   es->entry = *timestamp;
   //g_assert(timestamp->tv_sec != 0);
   es->change = *timestamp;
+       es->cum_cpu_time = ltt_time_zero;
   es->s = LTTV_STATE_WAIT_FORK;
        
        /* Allocate an empty function call stack. If it's empty, use 0x0. */
@@ -1416,8 +1440,7 @@ static void push_function(LttvTracefileState *tfs, guint64 funcptr)
     
   new_func = &g_array_index(process->user_stack, guint64, depth);
        *new_func = funcptr;
-  process->current_function = 
-               g_array_index(process->user_stack, guint64, depth - 1);
+  process->current_function = funcptr;
 }
 
 static void pop_function(LttvTracefileState *tfs, guint64 funcptr)
@@ -1426,7 +1449,6 @@ static void pop_function(LttvTracefileState *tfs, guint64 funcptr)
   LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
   LttvProcessState *process = ts->running_process[cpu];
 
-  guint depth = process->user_stack->len;
   if(process->current_function != funcptr){
     g_info("Different functions (%lu.%09lu): ignore it\n",
         tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
@@ -1439,6 +1461,7 @@ static void pop_function(LttvTracefileState *tfs, guint64 funcptr)
                    g_quark_to_string(process->state->s));
     return;
   }
+  guint depth = process->user_stack->len;
 
   if(depth == 0){
     g_info("Trying to pop last function on stack (%lu.%09lu): ignore it\n",
This page took 0.024107 seconds and 4 git commands to generate.