LTTV_STATE_RESOURCE_CPUS_COUNT,
LTTV_STATE_RESOURCE_IRQS,
LTTV_STATE_RESOURCE_SOFT_IRQS,
+ LTTV_STATE_RESOURCE_TRAPS,
LTTV_STATE_RESOURCE_BLKDEVS;
static void create_max_time(LttvTraceState *tcs);
static void
restore_init_state(LttvTraceState *self)
{
- guint i, nb_cpus, nb_irqs, nb_soft_irqs;
+ guint i, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps;
//LttvTracefileState *tfcs;
nb_cpus = ltt_trace_get_num_cpu(self->parent.t);
nb_irqs = self->nb_irqs;
nb_soft_irqs = self->nb_soft_irqs;
+ nb_traps = self->nb_traps;
/* Put the per cpu running_process to beginning state : process 0. */
for(i=0; i< nb_cpus; i++) {
self->soft_irq_states[i].running = 0;
}
+ /* reset trap states */
+ for(i=0; i<nb_traps; i++) {
+ self->trap_states[i].running = 0;
+ }
+
/* reset bdev states */
g_hash_table_foreach(self->bdev_states, bdevstate_free_cb, NULL);
//g_hash_table_steal_all(self->bdev_states);
/* the kernel has a statically fixed max of 32 softirqs */
tcs->soft_irq_states = g_new(LttvSoftIRQState, tcs->nb_soft_irqs);
+ /* init trap stuff */
+ tcs->trap_states = g_new(LttvTrapState, tcs->nb_traps);
+
/* init bdev resource stuff */
tcs->bdev_states = g_hash_table_new(g_int_hash, g_int_equal);
g_free(states);
}
+static LttvTrapState *lttv_state_copy_trap_states(LttvTrapState *states, guint n)
+{
+ guint i;
+ LttvTrapState *retval;
+
+ retval = g_malloc(n*sizeof(LttvTrapState));
+
+ for(i=0; i<n; i++) {
+ retval[i].running = states[i].running;
+ }
+
+ return retval;
+}
+
+static void lttv_state_free_trap_states(LttvTrapState *states, guint n)
+{
+ g_free(states);
+}
+
/* bdevstate stuff */
static LttvBdevState *get_hashed_bdevstate(LttvTraceState *ts, guint16 devcode)
static void state_save(LttvTraceState *self, LttvAttribute *container)
{
- guint i, nb_tracefile, nb_cpus, nb_irqs;
+ guint i, nb_tracefile, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps;
LttvTracefileState *tfcs;
*(value.v_pointer) = lttv_state_copy_soft_irq_states(self->soft_irq_states, nb_soft_irqs);
}
+ /* save the trap state */
+ nb_traps = self->nb_traps;
+ {
+ value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_TRAPS,
+ LTTV_POINTER);
+ *(value.v_pointer) = lttv_state_copy_trap_states(self->trap_states, nb_traps);
+ }
+
/* save the blkdev states */
value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_BLKDEVS,
LTTV_POINTER);
static void state_restore(LttvTraceState *self, LttvAttribute *container)
{
- guint i, nb_tracefile, pid, nb_cpus, nb_irqs, nb_soft_irqs;
+ guint i, nb_tracefile, pid, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps;
LttvTracefileState *tfcs;
lttv_state_free_soft_irq_states(self->soft_irq_states, nb_soft_irqs);
self->soft_irq_states = lttv_state_copy_soft_irq_states(*(value.v_pointer), nb_soft_irqs);
+ /* restore trap resource states */
+ nb_traps = self->nb_traps;
+ type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_TRAPS, &value);
+ g_assert(type == LTTV_POINTER);
+ lttv_state_free_trap_states(self->trap_states, nb_traps);
+ self->trap_states = lttv_state_copy_trap_states(*(value.v_pointer), nb_traps);
+
/* restore the blkdev states */
type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_BLKDEVS, &value);
g_assert(type == LTTV_POINTER);
LTTV_STATE_RESOURCE_CPUS = g_quark_from_string("cpu count");
LTTV_STATE_RESOURCE_IRQS = g_quark_from_string("irq resource states");
LTTV_STATE_RESOURCE_SOFT_IRQS = g_quark_from_string("soft irq resource states");
+ LTTV_STATE_RESOURCE_TRAPS = g_quark_from_string("trap resource states");
LTTV_STATE_RESOURCE_BLKDEVS = g_quark_from_string("blkdevs resource states");
GArray *mode_stack;
guint last_irq;
guint last_soft_irq;
+ guint last_trap;
} LttvCPUState;
typedef struct _LttvIRQState {
guint running; /* number of times it is currently running (on different processors) */
} LttvSoftIRQState;
+typedef struct _LttvTrapState {
+ guint running; /* number of times it is currently running (on different processors) */
+} LttvTrapState;
+
typedef struct _LttvBdevState {
GArray *mode_stack;
} LttvBdevState;
LttvCPUState *cpu_states; /* state of each cpu */
LttvIRQState *irq_states; /* state of each irq handler */
LttvSoftIRQState *soft_irq_states; /* state of each softirq */
+ LttvTrapState *trap_states; /* state of each trap */
GHashTable *bdev_states; /* state of the block devices */
};
{ 0, 0xFFFF, 0x9400, 0x9600 }, /* COL_SOFT_IRQ_BUSY */
};
+GdkColor drawing_colors_trap[NUM_COLORS_TRAP] =
+{ /* Pixel, R, G, B */
+ { 0, 0x0000, 0x0000, 0x0000 }, /* COL_TRAP_UNKNOWN */
+ { 0, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_TRAP_IDLE */
+ { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_TRAP_BUSY */
+};
+
GdkColor drawing_colors_bdev[NUM_COLORS_BDEV] =
{ /* Pixel, R, G, B */
{ 0, 0x0000, 0x0000, 0x0000 }, /* COL_BDEV_UNKNOWN */
TRUE, success);
gdk_colormap_alloc_colors(colormap, drawing_colors_soft_irq, NUM_COLORS_SOFT_IRQ, FALSE,
TRUE, success);
+ gdk_colormap_alloc_colors(colormap, drawing_colors_trap, NUM_COLORS_TRAP, FALSE,
+ TRUE, success);
gdk_colormap_alloc_colors(colormap, drawing_colors_bdev, NUM_COLORS_BDEV, FALSE,
TRUE, success);
gdk_colormap_free_colors(colormap, drawing_colors_cpu, NUM_COLORS_CPU);
gdk_colormap_free_colors(colormap, drawing_colors_irq, NUM_COLORS_IRQ);
gdk_colormap_free_colors(colormap, drawing_colors_soft_irq, NUM_COLORS_IRQ);
+ gdk_colormap_free_colors(colormap, drawing_colors_trap, NUM_COLORS_TRAP);
gdk_colormap_free_colors(colormap, drawing_colors_bdev, NUM_COLORS_BDEV);
// Do not unref here, Drawing_t destroyed by it's widget.
NUM_COLORS_SOFT_IRQ
} draw_color_soft_irq;
+typedef enum _draw_color_trap {
+ COL_TRAP_UNKNOWN,
+ COL_TRAP_IDLE,
+ COL_TRAP_BUSY,
+ NUM_COLORS_TRAP
+} draw_color_trap;
+
typedef enum _draw_color_bdev {
COL_BDEV_UNKNOWN,
COL_BDEV_IDLE,
extern GdkColor drawing_colors_cpu[NUM_COLORS_CPU];
extern GdkColor drawing_colors_irq[NUM_COLORS_IRQ];
extern GdkColor drawing_colors_soft_irq[NUM_COLORS_SOFT_IRQ];
+extern GdkColor drawing_colors_trap[NUM_COLORS_TRAP];
extern GdkColor drawing_colors_bdev[NUM_COLORS_BDEV];
/* This part of the viewer does :
prop_line->color = drawing_colors_soft_irq[COL_SOFT_IRQ_BUSY];
}
+static void trap_set_line_color(PropertiesLine *prop_line, LttvTrapState *s)
+{
+ GQuark present_state;
+ if(s->running == 0)
+ prop_line->color = drawing_colors_trap[COL_TRAP_IDLE];
+ else
+ prop_line->color = drawing_colors_trap[COL_TRAP_BUSY];
+}
+
static void bdev_set_line_color(PropertiesLine *prop_line, LttvBdevState *s)
{
GQuark present_state;
before_execmode_hook_irq(hook_data, call_data);
before_execmode_hook_soft_irq(hook_data, call_data);
+ before_execmode_hook_trap(hook_data, call_data);
/* we are in a execmode, before the state update. We must draw the
* items corresponding to the state before it changes : now is the right
return 0;
}
+int before_execmode_hook_trap(void *hook_data, void *call_data)
+{
+ LttvTraceHook *th = (LttvTraceHook*)hook_data;
+ EventsRequest *events_request = (EventsRequest*)th->hook_data;
+ ControlFlowData *resourceview_data = events_request->viewer_data;
+
+ LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
+
+ LttvTracefileState *tfs = (LttvTracefileState *)call_data;
+ LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
+
+ LttEvent *e;
+ e = ltt_tracefile_get_event(tfc->tf);
+
+ LttTime evtime = ltt_event_time(e);
+
+ LttTrace *trace = tfc->t_context->t;
+
+ /* we are in a execmode, before the state update. We must draw the
+ * items corresponding to the state before it changes : now is the right
+ * time to do it.
+ */
+ /* For the pid */
+
+ guint64 trap;
+ guint cpu = tfs->cpu;
+
+ guint16 ev_id_entry = marker_get_id_from_info(trace, marker_get_info_from_name(trace, lttv_merge_facility_event_name(LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY)));
+ guint16 ev_id_exit = marker_get_id_from_info(trace, marker_get_info_from_name(trace, lttv_merge_facility_event_name(LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT)));
+ if(ev_id_entry == e->event_id) {
+ trap = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
+ }
+ else if(ev_id_exit == e->event_id) {
+ trap = ts->cpu_states[cpu].last_trap;
+ }
+ else {
+ return 0;
+ }
+
+ guint trace_num = ts->parent.index;
+
+ /* Well, the process_out existed : we must get it in the process hash
+ * or add it, and draw its items.
+ */
+ /* Add process to process list (if not present) */
+ guint pl_height = 0;
+ HashedResourceData *hashed_process_data = NULL;
+ ProcessList *process_list = resourceview_data->process_list;
+
+ hashed_process_data = resourcelist_obtain_trap(resourceview_data, trace_num, trap);
+
+ /* Now, the process is in the state hash and our own process hash.
+ * We definitely can draw the items related to the ending state.
+ */
+
+ if(likely(ltt_time_compare(hashed_process_data->next_good_time,
+ evtime) > 0))
+ {
+ if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
+ TimeWindow time_window =
+ lttvwindow_get_time_window(resourceview_data->tab);
+
+#ifdef EXTRA_CHECK
+ if(ltt_time_compare(evtime, time_window.start_time) == -1
+ || ltt_time_compare(evtime, time_window.end_time) == 1)
+ return;
+#endif //EXTRA_CHECK
+ Drawing_t *drawing = resourceview_data->drawing;
+ guint width = drawing->width;
+ guint x;
+ convert_time_to_pixels(
+ time_window,
+ evtime,
+ width,
+ &x);
+
+ /* Draw collision indicator */
+ gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
+ gdk_draw_point(hashed_process_data->pixmap,
+ drawing->gc,
+ x,
+ COLLISION_POSITION(hashed_process_data->height));
+ hashed_process_data->x.middle_marked = TRUE;
+ }
+ }
+ else {
+ TimeWindow time_window =
+ lttvwindow_get_time_window(resourceview_data->tab);
+
+#ifdef EXTRA_CHECK
+ if(ltt_time_compare(evtime, time_window.start_time) == -1
+ || ltt_time_compare(evtime, time_window.end_time) == 1)
+ return;
+#endif //EXTRA_CHECK
+ Drawing_t *drawing = resourceview_data->drawing;
+ guint width = drawing->width;
+ guint x;
+
+ convert_time_to_pixels(
+ time_window,
+ evtime,
+ width,
+ &x);
+
+
+ /* Jump over draw if we are at the same x position */
+ if(unlikely(x == hashed_process_data->x.middle &&
+ hashed_process_data->x.middle_used))
+ {
+ if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
+ /* Draw collision indicator */
+ gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
+ gdk_draw_point(hashed_process_data->pixmap,
+ drawing->gc,
+ x,
+ COLLISION_POSITION(hashed_process_data->height));
+ hashed_process_data->x.middle_marked = TRUE;
+ }
+ /* jump */
+ }
+ else {
+
+ DrawContext draw_context;
+ /* Now create the drawing context that will be used to draw
+ * items related to the last state. */
+ draw_context.drawable = hashed_process_data->pixmap;
+ draw_context.gc = drawing->gc;
+ draw_context.pango_layout = drawing->pango_layout;
+ draw_context.drawinfo.start.x = hashed_process_data->x.middle;
+ draw_context.drawinfo.end.x = x;
+
+ draw_context.drawinfo.y.over = 1;
+ draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
+ draw_context.drawinfo.y.under = hashed_process_data->height;
+
+ draw_context.drawinfo.start.offset.over = 0;
+ draw_context.drawinfo.start.offset.middle = 0;
+ draw_context.drawinfo.start.offset.under = 0;
+ draw_context.drawinfo.end.offset.over = 0;
+ draw_context.drawinfo.end.offset.middle = 0;
+ draw_context.drawinfo.end.offset.under = 0;
+
+ {
+ /* Draw the line */
+ PropertiesLine prop_line;
+ prop_line.line_width = STATE_LINE_WIDTH;
+ prop_line.style = GDK_LINE_SOLID;
+ prop_line.y = MIDDLE;
+ trap_set_line_color(&prop_line, &ts->trap_states[trap]);
+ draw_line((void*)&prop_line, (void*)&draw_context);
+ }
+ /* become the last x position */
+ hashed_process_data->x.middle = x;
+ hashed_process_data->x.middle_used = TRUE;
+ hashed_process_data->x.middle_marked = FALSE;
+
+ /* Calculate the next good time */
+ convert_pixels_to_time(width, x+1, time_window,
+ &hashed_process_data->next_good_time);
+ }
+ }
+
+ return 0;
+}
+
int before_bdev_event_hook(void *hook_data, void *call_data)
{
irq_set_line_color(&prop_line, &ts->irq_states[process_info->id]);
else if(hashed_process_data->type == RV_RESOURCE_SOFT_IRQ)
soft_irq_set_line_color(&prop_line, &ts->soft_irq_states[process_info->id]);
+ else if(hashed_process_data->type == RV_RESOURCE_TRAP)
+ trap_set_line_color(&prop_line, &ts->trap_states[process_info->id]);
else if(hashed_process_data->type == RV_RESOURCE_BDEV) {
gint devcode_gint = process_info->id;
LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint);
process_list->restypes[RV_RESOURCE_CPU].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
process_list->restypes[RV_RESOURCE_IRQ].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
process_list->restypes[RV_RESOURCE_SOFT_IRQ].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
+ process_list->restypes[RV_RESOURCE_TRAP].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
process_list->restypes[RV_RESOURCE_BDEV].hash_table = g_hash_table_new(ru_numeric_hash_fct, ru_numeric_equ_fct);
return process_list;
return name;
}
+GQuark make_trap_name(ControlFlowData *resourceview_data, guint trace_num, guint id)
+{
+ GQuark name;
+ gchar *str;
+
+ str = g_strdup_printf("Trap %u", id);
+ name = g_quark_from_string(str);
+ g_free(str);
+
+ return name;
+}
+
GQuark make_bdev_name(ControlFlowData *resourceview_data, guint trace_num, guint id)
{
GQuark name;
return resourcelist_obtain_generic(resourceview_data, RV_RESOURCE_SOFT_IRQ, trace_num, id, make_soft_irq_name);
}
+HashedResourceData *resourcelist_obtain_trap(ControlFlowData *resourceview_data, guint trace_num, guint id)
+{
+ return resourcelist_obtain_generic(resourceview_data, RV_RESOURCE_TRAP, trace_num, id, make_trap_name);
+}
+
HashedResourceData *resourcelist_obtain_bdev(ControlFlowData *resourceview_data, guint trace_num, guint id)
{
return resourcelist_obtain_generic(resourceview_data, RV_RESOURCE_BDEV, trace_num, id, make_bdev_name);
#define RV_RESOURCE_CPU 1
#define RV_RESOURCE_IRQ 2
#define RV_RESOURCE_SOFT_IRQ 3
-#define RV_RESOURCE_BDEV 4
-#define RV_RESOURCE_COUNT 5
+#define RV_RESOURCE_TRAP 4
+#define RV_RESOURCE_BDEV 5
+#define RV_RESOURCE_COUNT 6
/* Enumeration of the columns */
enum