From: compudj Date: Thu, 7 Aug 2008 00:55:17 +0000 (+0000) Subject: fix softirq/irq/trap array, undefined last X-Git-Tag: v0.12.20~499 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=aaa41e47b880d6a761d7b285cedf9c410186d682;p=lttv.git fix softirq/irq/trap array, undefined last git-svn-id: http://ltt.polymtl.ca/svn@2990 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/lttv/lttv/lttv/state.c b/trunk/lttv/lttv/lttv/state.c index 6fb3b2af..1c9ca83d 100644 --- a/trunk/lttv/lttv/lttv/state.c +++ b/trunk/lttv/lttv/lttv/state.c @@ -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; jcpu_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; ilen); for(j=0; jlen; 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; } diff --git a/trunk/lttv/lttv/lttv/state.h b/trunk/lttv/lttv/lttv/state.h index 523e058b..306bef5c 100644 --- a/trunk/lttv/lttv/lttv/state.h +++ b/trunk/lttv/lttv/lttv/state.h @@ -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 {