fix softirq/irq/trap array, undefined last
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 7 Aug 2008 00:55:17 +0000 (00:55 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 7 Aug 2008 00:55:17 +0000 (00:55 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2990 04897980-b3bd-0310-b5e0-8ef037075253

trunk/lttv/lttv/lttv/state.c
trunk/lttv/lttv/lttv/state.h

index 6fb3b2afd2d6450a9b8019e65e2ea5506f1737b8..1c9ca83d96b242da452cc6ceb4131adb3f8f6195 100644 (file)
@@ -419,8 +419,12 @@ restore_init_state(LttvTraceState *self)
     self->running_process[i]->cpu = i;
 
     /* reset cpu states */
-    if(self->cpu_states[i].mode_stack->len > 0)
+    if(self->cpu_states[i].mode_stack->len > 0) {
       g_array_remove_range(self->cpu_states[i].mode_stack, 0, self->cpu_states[i].mode_stack->len);
+      self->cpu_states[i].last_irq = -1;
+      self->cpu_states[i].last_soft_irq = -1;
+      self->cpu_states[i].last_trap = -1;
+    }
   }
 
   /* reset irq states */
@@ -599,6 +603,9 @@ init(LttvTracesetState *self, LttvTraceset *ts)
     tcs->cpu_states = g_new(LttvCPUState, nb_cpu);
     for(j = 0; j<nb_cpu; j++) {
       tcs->cpu_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
+      tcs->cpu_states[j].last_irq = -1;
+      tcs->cpu_states[j].last_soft_irq = -1;
+      tcs->cpu_states[j].last_trap = -1;
       g_assert(tcs->cpu_states[j].mode_stack != NULL);
     } 
 
@@ -1277,6 +1284,8 @@ static LttvCPUState *lttv_state_copy_cpu_states(LttvCPUState *states, guint n)
   for(i=0; i<n; i++) {
     retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
     retval[i].last_irq = states[i].last_irq;
+    retval[i].last_soft_irq = states[i].last_soft_irq;
+    retval[i].last_trap = states[i].last_trap;
     g_array_set_size(retval[i].mode_stack, states[i].mode_stack->len);
     for(j=0; j<states[i].mode_stack->len; j++) {
       g_array_index(retval[i].mode_stack, GQuark, j) = g_array_index(states[i].mode_stack, GQuark, j);
@@ -2456,7 +2465,7 @@ static gboolean trap_exit(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
   LttvTraceState *ts = (LttvTraceState *)s->parent.t_context;
-  guint trap = s->cpu_state->last_trap;
+  gint trap = s->cpu_state->last_trap;
 
   pop_state(s, LTTV_STATE_TRAP);
 
@@ -2464,8 +2473,9 @@ static gboolean trap_exit(void *hook_data, void *call_data)
   cpu_pop_mode(s->cpu_state);
 
   /* update trap status */
-  if(ts->trap_states[trap].running)
-    ts->trap_states[trap].running--;
+  if (trap != -1)
+    if(ts->trap_states[trap].running)
+      ts->trap_states[trap].running--;
 
   return FALSE;
 }
@@ -2503,13 +2513,14 @@ static gboolean soft_irq_exit(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
   LttvTraceState *ts = (LttvTraceState *)s->parent.t_context;
-  guint softirq = s->cpu_state->last_soft_irq;
+  gint softirq = s->cpu_state->last_soft_irq;
 
   pop_state(s, LTTV_STATE_SOFT_IRQ);
 
   /* update softirq status */
-  if(ts->soft_irq_states[softirq].running)
-    ts->soft_irq_states[softirq].running--;
+  if (softirq != -1)
+    if(ts->soft_irq_states[softirq].running)
+      ts->soft_irq_states[softirq].running--;
 
   /* update cpu status */
   cpu_pop_mode(s->cpu_state);
@@ -2528,7 +2539,8 @@ static gboolean irq_exit(void *hook_data, void *call_data)
   cpu_pop_mode(s->cpu_state);
 
   /* update irq status */
-  irq_pop_mode(&ts->irq_states[s->cpu_state->last_irq]);
+  if (s->cpu_state->last_irq != -1)
+    irq_pop_mode(&ts->irq_states[s->cpu_state->last_irq]);
 
   return FALSE;
 }
index 523e058b2cdd107d851f219ba0850bfb08cddc76..306bef5c9fd3930267792d0e737096f5ee76ff03 100644 (file)
@@ -317,9 +317,9 @@ GType lttv_traceset_state_get_type (void);
 
 typedef struct _LttvCPUState {
   GArray *mode_stack;
-  guint last_irq;
-  guint last_soft_irq;
-  guint last_trap;
+  gint last_irq;
+  gint last_soft_irq;
+  gint last_trap;
 } LttvCPUState;
 
 typedef struct _LttvIRQState {
This page took 0.026903 seconds and 4 git commands to generate.