From 1b17194774dd382bbf7da085ad0628968a3ebea5 Mon Sep 17 00:00:00 2001 From: pmf Date: Tue, 31 Jul 2007 19:46:15 +0000 Subject: [PATCH] don't do invalid reads when the mode stacks of resources are empty git-svn-id: http://ltt.polymtl.ca/svn@2570 04897980-b3bd-0310-b5e0-8ef037075253 --- .../modules/gui/resourceview/eventhooks.c | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c index 1b4f7a94..4d30a4bf 100644 --- a/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c @@ -319,7 +319,12 @@ static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s) { - GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; + GQuark present_state; + + if(s->mode_stack->len == 0) + present_state = LTTV_CPU_UNKNOWN; + else + present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; if(present_state == LTTV_CPU_IDLE) { prop_line->color = drawing_colors_cpu[COL_CPU_IDLE]; @@ -339,27 +344,32 @@ static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s) static void irq_set_line_color(PropertiesLine *prop_line, LttvIRQState *s) { - GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; + GQuark present_state; + if(s->mode_stack->len == 0) + present_state = LTTV_IRQ_UNKNOWN; + else + present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; - if(present_state == LTTV_IRQ_UNKNOWN) { - prop_line->color = drawing_colors_irq[COL_IRQ_UNKNOWN]; - } - else if(present_state == LTTV_IRQ_IDLE) { + if(present_state == LTTV_IRQ_IDLE) { prop_line->color = drawing_colors_irq[COL_IRQ_IDLE]; } else if(present_state == LTTV_IRQ_BUSY) { prop_line->color = drawing_colors_irq[COL_IRQ_BUSY]; } + else { + prop_line->color = drawing_colors_irq[COL_IRQ_UNKNOWN]; + } } static void bdev_set_line_color(PropertiesLine *prop_line, LttvBdevState *s) { - GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; + GQuark present_state; + if(s->mode_stack->len == 0) + present_state = LTTV_BDEV_UNKNOWN; + else + present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; - if(present_state == LTTV_BDEV_UNKNOWN) { - prop_line->color = drawing_colors_bdev[COL_BDEV_UNKNOWN]; - } - else if(present_state == LTTV_BDEV_IDLE) { + if(present_state == LTTV_BDEV_IDLE) { prop_line->color = drawing_colors_bdev[COL_BDEV_IDLE]; } else if(present_state == LTTV_BDEV_BUSY_READING) { @@ -368,6 +378,9 @@ static void bdev_set_line_color(PropertiesLine *prop_line, LttvBdevState *s) else if(present_state == LTTV_BDEV_BUSY_WRITING) { prop_line->color = drawing_colors_bdev[COL_BDEV_BUSY_WRITING]; } + else { + prop_line->color = drawing_colors_bdev[COL_BDEV_UNKNOWN]; + } } /* before_schedchange_hook -- 2.34.1