fix array relocation in push_state
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 22 Aug 2005 22:12:58 +0000 (22:12 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 22 Aug 2005 22:12:58 +0000 (22:12 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1050 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/state.h

index 969f556a834aecf4441ad4e98ab1173dfdcbdca1..30039298e5462a7e6f9a4dccff7f39971e0abee2 100644 (file)
@@ -372,7 +372,9 @@ static void copy_process_state(gpointer key, gpointer value,gpointer user_data)
   *new_process = *process;
   new_process->execution_stack = g_array_sized_new(FALSE, FALSE, 
       sizeof(LttvExecutionState), PREALLOCATED_EXECUTION_STACK);
-  g_array_set_size(new_process->execution_stack,process->execution_stack->len);
+  new_process->execution_stack = 
+              g_array_set_size(new_process->execution_stack,
+                  process->execution_stack->len);
   for(i = 0 ; i < process->execution_stack->len; i++) {
     g_array_index(new_process->execution_stack, LttvExecutionState, i) =
         g_array_index(process->execution_stack, LttvExecutionState, i);
@@ -800,7 +802,6 @@ free_name_tables(LttvTraceState *tcs)
   g_free(name_tables);
 } 
 
-
 static void push_state(LttvTracefileState *tfs, LttvExecutionMode t, 
     guint state_id)
 {
@@ -810,7 +811,12 @@ static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
 
   guint depth = process->execution_stack->len;
 
-  g_array_set_size(process->execution_stack, depth + 1);
+  process->execution_stack = 
+    g_array_set_size(process->execution_stack, depth + 1);
+  /* Keep in sync */
+  process->state =
+    &g_array_index(process->execution_stack, LttvExecutionState, depth - 1);
+    
   es = &g_array_index(process->execution_stack, LttvExecutionState, depth);
   es->t = t;
   es->n = state_id;
@@ -846,7 +852,8 @@ static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t)
     return;
   }
 
-  g_array_set_size(process->execution_stack, depth - 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;
@@ -900,7 +907,7 @@ lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent,
   process->last_cpu_index = ((LttvTracefileContext*)tfs)->index;
   process->execution_stack = g_array_sized_new(FALSE, FALSE, 
       sizeof(LttvExecutionState), PREALLOCATED_EXECUTION_STACK);
-  g_array_set_size(process->execution_stack, 1);
+  process->execution_stack = g_array_set_size(process->execution_stack, 1);
   es = process->state = &g_array_index(process->execution_stack, 
       LttvExecutionState, 0);
   es->t = LTTV_STATE_USER_MODE;
@@ -1212,7 +1219,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
        associated by id hooks. */
 
     hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 10);
-    g_array_set_size(hooks, 10);
+    hooks = g_array_set_size(hooks, 10);
 
     ret = lttv_trace_find_hook(ts->parent.t,
         LTT_FACILITY_KERNEL, LTT_EVENT_SYSCALL_ENTRY,
index f8f7a5775e59da7d1cede732048b0abf04b2a499..720506861484f6b17de9956e21bdd7197af84f3e 100644 (file)
@@ -186,6 +186,9 @@ typedef struct _LttvProcessState {
   GQuark pid_time;
   GArray *execution_stack;         /* Array of LttvExecutionState */
   LttvExecutionState *state;       /* Top of interrupt stack */
+      /* WARNING : each time the execution_stack size is modified, the state
+       * must be reget : g_array_set_size can have to move the array.
+       * (Mathieu) */
   GQuark last_cpu;                /* Last CPU where process was scheduled */
   guint last_cpu_index;            /* index in the trace for cpu tracefile */
   /* opened file descriptors, address map?... */
This page took 0.026343 seconds and 4 git commands to generate.