LTTV_CPU_UNKNOWN,
LTTV_CPU_IDLE,
LTTV_CPU_BUSY,
- LTTV_CPU_IRQ;
+ LTTV_CPU_IRQ,
+ LTTV_CPU_TRAP;
static GQuark
LTTV_STATE_TRACEFILES,
static void
init(LttvTracesetState *self, LttvTraceset *ts)
{
- guint i, j, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile, nb_cpu;
LttvTraceContext *tc;
get_max_time(tcs);
nb_tracefile = tc->tracefiles->len;
+ nb_cpu = ltt_trace_get_num_cpu(tc->t);
tcs->processes = NULL;
tcs->usertraces = NULL;
- tcs->running_process = g_new(LttvProcessState*,
- ltt_trace_get_num_cpu(tc->t));
- tcs->cpu_states = g_new(LttvCPUState,
- ltt_trace_get_num_cpu(tc->t));
+ tcs->running_process = g_new(LttvProcessState*, nb_cpu);
+ /* init cpu resource stuff */
+ 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));
+ g_assert(tcs->cpu_states[j].mode_stack != NULL);
+ }
+
restore_init_state(tcs);
for(j = 0 ; j < nb_tracefile ; j++) {
tfcs =
#endif
+/* clears the stack and sets the state passed as argument */
+static void cpu_set_base_mode(LttvCPUState *cpust, LttvCPUMode state)
+{
+ g_array_set_size(cpust->mode_stack, 1);
+ ((GQuark *)cpust->mode_stack->data)[0] = state;
+}
+
+static void cpu_push_mode(LttvCPUState *cpust, LttvCPUMode state)
+{
+ g_array_set_size(cpust->mode_stack, cpust->mode_stack->len + 1);
+ ((GQuark *)cpust->mode_stack->data)[cpust->mode_stack->len - 1] = state;
+}
+
+static void cpu_pop_mode(LttvCPUState *cpust)
+{
+ if(cpust->mode_stack->len == 1)
+ cpu_set_base_mode(cpust, LTTV_CPU_UNKNOWN);
+ else
+ g_array_set_size(cpust->mode_stack, cpust->mode_stack->len - 1);
+}
static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
guint state_id)
}
push_state(s, LTTV_STATE_TRAP, submode);
+
+ /* update cpu status */
+ cpu_push_mode(s->cpu_state, LTTV_CPU_TRAP);
+
return FALSE;
}
-
static gboolean trap_exit(void *hook_data, void *call_data)
{
LttvTracefileState *s = (LttvTracefileState *)call_data;
pop_state(s, LTTV_STATE_TRAP);
+
+ /* update cpu status */
+ cpu_pop_mode(s->cpu_state);
+
return FALSE;
}
-
static gboolean irq_entry(void *hook_data, void *call_data)
{
LttvTracefileState *s = (LttvTracefileState *)call_data;
push_state(s, LTTV_STATE_IRQ, submode);
/* update cpu status */
- s->cpu_state->previous_state = s->cpu_state->present_state;
- s->cpu_state->present_state = LTTV_CPU_IRQ;
+ cpu_push_mode(s->cpu_state, LTTV_CPU_IRQ);
return FALSE;
}
pop_state(s, LTTV_STATE_IRQ);
/* update cpu status */
- s->cpu_state->present_state = s->cpu_state->previous_state;
+ cpu_pop_mode(s->cpu_state);
return FALSE;
}
/* update cpu status */
if(pid_in == 0)
- s->cpu_state->present_state = LTTV_CPU_IDLE;
+ cpu_set_base_mode(s->cpu_state, LTTV_CPU_IDLE);
else
- s->cpu_state->present_state = LTTV_CPU_BUSY;
+ cpu_set_base_mode(s->cpu_state, LTTV_CPU_BUSY);
return FALSE;
}
LTTV_CPU_IDLE = g_quark_from_string("idle");
LTTV_CPU_BUSY = g_quark_from_string("busy");
LTTV_CPU_IRQ = g_quark_from_string("irq");
+ LTTV_CPU_TRAP = g_quark_from_string("trap");
}
static void module_destroy()
LTTV_CPU_UNKNOWN,
LTTV_CPU_IDLE,
LTTV_CPU_BUSY,
- LTTV_CPU_IRQ;
+ LTTV_CPU_IRQ,
+ LTTV_CPU_TRAP;
typedef struct _LttvExecutionState {
LttvExecutionMode t;
#define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass))
typedef struct _LttvCPUState {
- LttvCPUMode previous_state;
- LttvCPUMode present_state;
+ GArray *mode_stack;
} LttvCPUState;
struct _LttvTraceState {
GdkColor drawing_colors_cpu[NUM_COLORS_CPU] =
{ /* Pixel, R, G, B */
- { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_CPU_UNKNOWN */
+ { 0, 0x0000, 0x0000, 0x0000 }, /* COL_CPU_UNKNOWN */
{ 0, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_CPU_IDLE */
{ 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_CPU_BUSY */
- { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_CPU_IRQ */
+ { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_CPU_IRQ */
+ { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_CPU_TRAP */
};
// events_request,
// &g_array_index(hooks, LttvTraceHook, before_hn++));
// if(ret) before_hn--;
-//
-// ret = lttv_trace_find_hook(ts->parent.t,
-// LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY,
-// LTT_FIELD_TRAP_ID, 0, 0,
-// before_execmode_hook,
-// events_request,
-// &g_array_index(hooks, LttvTraceHook, before_hn++));
-// if(ret) before_hn--;
-//
-// ret = lttv_trace_find_hook(ts->parent.t,
-// LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT,
-// 0, 0, 0,
-// before_execmode_hook,
-// events_request,
-// &g_array_index(hooks, LttvTraceHook, before_hn++));
-// if(ret) before_hn--;
//
+ ret = lttv_trace_find_hook(ts->parent.t,
+ LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY,
+ LTT_FIELD_TRAP_ID, 0, 0,
+ before_execmode_hook,
+ events_request,
+ &g_array_index(hooks, LttvTraceHook, before_hn++));
+ if(ret) before_hn--;
+
+ ret = lttv_trace_find_hook(ts->parent.t,
+ LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT,
+ 0, 0, 0,
+ before_execmode_hook,
+ events_request,
+ &g_array_index(hooks, LttvTraceHook, before_hn++));
+ if(ret) before_hn--;
+
ret = lttv_trace_find_hook(ts->parent.t,
LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY,
LTT_FIELD_IRQ_ID, 0, 0,
/* Allocate the colors */
GdkColormap* colormap = gdk_colormap_get_system();
gboolean success[NUM_COLORS];
- //gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE,
- // TRUE, success);
+ gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE,
+ TRUE, success);
gdk_colormap_alloc_colors(colormap, drawing_colors_cpu, NUM_COLORS_CPU, FALSE,
TRUE, success);
/* Free the colors */
GdkColormap* colormap = gdk_colormap_get_system();
- //gdk_colormap_free_colors(colormap, drawing_colors, NUM_COLORS);
+ gdk_colormap_free_colors(colormap, drawing_colors, NUM_COLORS);
gdk_colormap_free_colors(colormap, drawing_colors_cpu, NUM_COLORS_CPU);
COL_CPU_IDLE,
COL_CPU_BUSY,
COL_CPU_IRQ,
+ COL_CPU_TRAP,
NUM_COLORS_CPU
} draw_color_cpu;
}
-static void set_line_color_cpu(PropertiesLine *prop_line, GQuark present_state)
+static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s)
{
- if(present_state == LTTV_CPU_IDLE) {
+ GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1];
+
+ if(present_state == LTTV_CPU_UNKNOWN) {
+ prop_line->color = drawing_colors_cpu[COL_CPU_UNKNOWN];
+ }
+ else if(present_state == LTTV_CPU_IDLE) {
prop_line->color = drawing_colors_cpu[COL_CPU_IDLE];
}
else if(present_state == LTTV_CPU_BUSY) {
else if(present_state == LTTV_CPU_IRQ) {
prop_line->color = drawing_colors_cpu[COL_CPU_IRQ];
}
+ else if(present_state == LTTV_CPU_TRAP) {
+ prop_line->color = drawing_colors_cpu[COL_CPU_TRAP];
+ }
}
/* before_schedchange_hook
// return 0;
// }
- exit(0);
-
tfc->target_pid = pid_out;
// if(!filter || !filter->head ||
// lttv_filter_tree_parse(filter->head,e,tfc->tf,
prop_line.line_width = STATE_LINE_WIDTH;
prop_line.style = GDK_LINE_SOLID;
prop_line.y = MIDDLE;
- cpu_set_line_color(&prop_line, tfs->cpu_state->present_state);
+ cpu_set_line_color(&prop_line, tfs->cpu_state);
draw_line((void*)&prop_line, (void*)&draw_context);
}
ResourceInfo *process_info;
/* Process not present */
Drawing_t *drawing = control_flow_data->drawing;
- ressourcelist_add(process_list,
+ resourcelist_add(process_list,
drawing,
trace_num,
cpuq, //process->name,
COLLISION_POSITION(hashed_process_data->height));
hashed_process_data->x.middle_marked = TRUE;
}
- } else {
+ }
+ else {
TimeWindow time_window =
lttvwindow_get_time_window(control_flow_data->tab);
hashed_process_data->x.middle_marked = TRUE;
}
/* jump */
- } else {
+ }
+ else {
DrawContext draw_context;
/* Now create the drawing context that will be used to draw
{
/* Draw the line */
PropertiesLine prop_line;
- cpu_set_line_color(&prop_line, tfs->cpu_state->present_state);
- printf("current state: %s\n", g_quark_to_string(tfs->cpu_state->present_state));
+ prop_line.line_width = STATE_LINE_WIDTH;
+ prop_line.style = GDK_LINE_SOLID;
+ prop_line.y = MIDDLE;
+ cpu_set_line_color(&prop_line, tfs->cpu_state);
draw_line((void*)&prop_line, (void*)&draw_context);
}
/* become the last x position */
prop_line.line_width = STATE_LINE_WIDTH;
prop_line.style = GDK_LINE_SOLID;
prop_line.y = MIDDLE;
- cpu_set_line_color(&prop_line, ts->cpu_states[process_info->id].present_state);
+ cpu_set_line_color(&prop_line, &ts->cpu_states[process_info->id]);
draw_line((void*)&prop_line, (void*)&draw_context);
}