do not abort when before_bdev_event_hook does not find a block device in the state
[lttv.git] / ltt / branches / poly / lttv / modules / gui / resourceview / eventhooks.c
index 1b4f7a9432a81c031ba236dc9055445a95e0ecee..05ad99c104f2607bd39e14adee65cc91b67c1701 100644 (file)
@@ -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
@@ -535,7 +548,6 @@ int before_schedchange_hook(void *hook_data, void *call_data)
                   width,
                   &x);
 
-
         /* Jump over draw if we are at the same x position */
         if(x == hashed_process_data->x.middle &&
              hashed_process_data->x.middle_used)
@@ -1383,7 +1395,9 @@ int before_bdev_event_hook(void *hook_data, void *call_data)
   guint trace_num = ts->parent.index;
 
   LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint); 
-  g_assert(bdev != NULL);
+  /* TODO: if bdev not found, draw right colour to indicate unknown state */
+  if(bdev == NULL)
+    return 0;
 
 //  guint pid = process->pid;
 
This page took 0.026609 seconds and 4 git commands to generate.