From: pmf Date: Tue, 31 Jul 2007 19:46:13 +0000 (+0000) Subject: continue implementation of cpu resource X-Git-Tag: v0.12.20~929 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d3d99fde8e46d9df5bce73544013242c9a3185fa;p=lttv.git continue implementation of cpu resource save state in stack git-svn-id: http://ltt.polymtl.ca/svn@2560 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index e12272a0..71be9d50 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -131,7 +131,8 @@ LttvCPUMode LTTV_CPU_UNKNOWN, LTTV_CPU_IDLE, LTTV_CPU_BUSY, - LTTV_CPU_IRQ; + LTTV_CPU_IRQ, + LTTV_CPU_TRAP; static GQuark LTTV_STATE_TRACEFILES, @@ -382,7 +383,7 @@ end: 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; @@ -412,12 +413,17 @@ init(LttvTracesetState *self, LttvTraceset *ts) 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; jcpu_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 = @@ -1584,6 +1590,26 @@ static void hash_table_check(GHashTable *table) #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) @@ -1943,19 +1969,25 @@ static gboolean trap_entry(void *hook_data, void *call_data) } 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; @@ -1987,8 +2019,7 @@ static gboolean irq_entry(void *hook_data, void *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; } @@ -2010,7 +2041,7 @@ static gboolean irq_exit(void *hook_data, void *call_data) 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; } @@ -2202,9 +2233,9 @@ static gboolean schedchange(void *hook_data, void *call_data) /* 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; } @@ -3542,6 +3573,7 @@ static void module_init() 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() diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index 5f22b356..c419e43f 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -203,7 +203,8 @@ extern LttvCPUMode LTTV_CPU_UNKNOWN, LTTV_CPU_IDLE, LTTV_CPU_BUSY, - LTTV_CPU_IRQ; + LTTV_CPU_IRQ, + LTTV_CPU_TRAP; typedef struct _LttvExecutionState { LttvExecutionMode t; @@ -285,8 +286,7 @@ GType lttv_traceset_state_get_type (void); #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 { diff --git a/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.c b/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.c index 30a6f8eb..251ccaca 100644 --- a/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.c @@ -86,10 +86,11 @@ GdkColor drawing_colors[NUM_COLORS] = 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 */ }; @@ -234,23 +235,23 @@ void drawing_data_request(Drawing_t *drawing, // 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, @@ -1064,8 +1065,8 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) /* 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); @@ -1123,7 +1124,7 @@ void drawing_destroy(Drawing_t *drawing) /* 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); diff --git a/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.h b/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.h index b5c6f600..1c468327 100644 --- a/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/resourceview/drawing.h @@ -55,6 +55,7 @@ typedef enum _draw_color_cpu { COL_CPU_IDLE, COL_CPU_BUSY, COL_CPU_IRQ, + COL_CPU_TRAP, NUM_COLORS_CPU } draw_color_cpu; diff --git a/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c index 03ef6f0b..d4040a5f 100644 --- a/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/resourceview/eventhooks.c @@ -317,9 +317,14 @@ static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) } -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) { @@ -328,6 +333,9 @@ static void set_line_color_cpu(PropertiesLine *prop_line, GQuark present_state) 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 @@ -382,8 +390,6 @@ int before_schedchange_hook(void *hook_data, void *call_data) // return 0; // } - exit(0); - tfc->target_pid = pid_out; // if(!filter || !filter->head || // lttv_filter_tree_parse(filter->head,e,tfc->tf, @@ -541,7 +547,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) 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); } @@ -960,7 +966,7 @@ int before_execmode_hook(void *hook_data, void *call_data) 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, @@ -1012,7 +1018,8 @@ int before_execmode_hook(void *hook_data, void *call_data) 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); @@ -1046,7 +1053,8 @@ int before_execmode_hook(void *hook_data, void *call_data) hashed_process_data->x.middle_marked = TRUE; } /* jump */ - } else { + } + else { DrawContext draw_context; /* Now create the drawing context that will be used to draw @@ -1071,8 +1079,10 @@ int before_execmode_hook(void *hook_data, void *call_data) { /* 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 */ @@ -2567,7 +2577,7 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data) 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); }