X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fcontrolflow%2Fdrawing.c;h=9b977199fa973dc971395f2876cef4958302e82a;hb=9a1ec01b8ebf230989fc9078d35f5ac2aa7fb5b0;hp=c504cf5bc53beda7b66383807a2f44dae12cd7c1;hpb=90ef7e4a2c6a41ec36bd2530b187cc1ef2cf0025;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index c504cf5b..9b977199 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -33,7 +33,10 @@ #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) +//FIXME +#define TRACE_NUMBER 0 +#if 0 /* colors for two lines representation */ GdkColor drawing_colors[NUM_COLORS] = { /* Pixel, R, G, B */ { 0, 0, 0, 0 }, /* COL_BLACK */ @@ -51,8 +54,41 @@ GdkColor drawing_colors[NUM_COLORS] = { 0, 0xFFFF, 0xFFFF, 0xFFFF } /* COL_MODE_UNKNOWN : white */ }; +#endif //0 +GdkColor drawing_colors[NUM_COLORS] = +{ /* Pixel, R, G, B */ + { 0, 0, 0, 0 }, /* COL_BLACK */ + { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_WHITE */ + { 0, 0x0000, 0xFF00, 0x0000 }, /* COL_RUN_USER_MODE : green */ + { 0, 0x0100, 0x9E00, 0xFFFF }, /* COL_RUN_SYSCALL : pale blue */ + { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_RUN_TRAP : yellow */ + { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_RUN_IRQ : red */ + { 0, 0xA3FF, 0x0000, 0x0000 }, /* COL_WAIT : dark red */ + { 0, 0x7700, 0x7700, 0x0000 }, /* COL_WAIT_CPU : dark yellow */ + { 0, 0x6400, 0x0000, 0x5D00 }, /* COL_ZOMBIE : dark purple */ + { 0, 0x0700, 0x6400, 0x0000 }, /* COL_WAIT_FORK : dark green */ + { 0, 0x8900, 0x0000, 0x8400 }, /* COL_EXIT : "less dark" magenta */ + { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_MODE_UNKNOWN : white */ + { 0, 0xFFFF, 0xFFFF, 0xFFFF } /* COL_UNNAMED : white */ + +}; + +/* +RUN+USER MODE green +RUN+SYSCALL +RUN+TRAP +RUN+IRQ +WAIT+foncé +WAIT CPU + WAIT FORK vert foncé ou jaune +IRQ rouge +TRAP: orange +SYSCALL: bleu pâle + +ZOMBIE + WAIT EXIT +*/ + /***************************************************************************** * drawing functions * @@ -85,12 +121,11 @@ void drawing_data_request(Drawing_t *drawing, } - + Tab *tab = drawing->control_flow_data->tab; TimeWindow time_window = - lttvwindow_get_time_window(drawing->control_flow_data->tab); + lttvwindow_get_time_window(tab); ControlFlowData *control_flow_data = drawing->control_flow_data; - Tab *tab = control_flow_data->tab; // (ControlFlowData*)g_object_get_data( // G_OBJECT(drawing->drawing_area), "control_flow_data"); @@ -118,39 +153,201 @@ void drawing_data_request(Drawing_t *drawing, time_window.start_time, window_end, &time_end); - - EventsRequest *events_request = g_new(EventsRequest, 1); - // Create the hooks - LttvHooks *event = lttv_hooks_new(); - LttvHooks *before_chunk_traceset = lttv_hooks_new(); - LttvHooks *after_chunk_traceset = lttv_hooks_new(); - LttvHooks *before_request_hook = lttv_hooks_new(); - LttvHooks *after_request_hook = lttv_hooks_new(); - - lttv_hooks_add(before_chunk_traceset, - before_chunk, - events_request, - LTTV_PRIO_DEFAULT); - lttv_hooks_add(after_chunk_traceset, - after_chunk, - events_request, - LTTV_PRIO_DEFAULT); + lttvwindow_events_request_remove_all(tab, + control_flow_data); - lttv_hooks_add(before_request_hook, - before_request, - events_request, - LTTV_PRIO_DEFAULT); + { + /* find the tracehooks */ + LttvTracesetContext *tsc = lttvwindow_get_traceset_context(tab); - lttv_hooks_add(after_request_hook, - after_request, - events_request, - LTTV_PRIO_DEFAULT); + LttvTraceset *traceset = tsc->ts; - /* FIXME : hooks are registered global instead of by ID. - * This is due to the lack of granularity of main window's events requests. - * Should be fixed for gain of performance. - */ + guint i, k, nb_trace; + + LttvTraceState *ts; + + LttvTracefileState *tfs; + + GArray *hooks; + + LttvTraceHook hook; + + LttvAttributeValue val; + + nb_trace = lttv_traceset_number(traceset); + // FIXME : eventually request for more traces + // for(i = 0 ; i < nb_trace ; i++) { + for(i = 0; itraces[i]; + + /* Find the eventtype id for the following events and register the + associated by id hooks. */ + + hooks = g_array_new(FALSE, FALSE, sizeof(LttvTraceHook)); + g_array_set_size(hooks, 16); + + /* before hooks */ + + lttv_trace_find_hook(ts->parent.t, "core","syscall_entry","syscall_id", + NULL, NULL, before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 0)); + + lttv_trace_find_hook(ts->parent.t, "core", "syscall_exit", NULL, NULL, + NULL, before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 1)); + + lttv_trace_find_hook(ts->parent.t, "core", "trap_entry", "trap_id", + NULL, NULL, before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 2)); + + lttv_trace_find_hook(ts->parent.t, "core", "trap_exit", NULL, NULL, NULL, + before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 3)); + + lttv_trace_find_hook(ts->parent.t, "core", "irq_entry", "irq_id", NULL, + NULL, before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 4)); + + lttv_trace_find_hook(ts->parent.t, "core", "irq_exit", NULL, NULL, NULL, + before_execmode_hook, &g_array_index(hooks, LttvTraceHook, 5)); + + lttv_trace_find_hook(ts->parent.t, "core", "schedchange", "in", "out", + "out_state", before_schedchange_hook, + &g_array_index(hooks, LttvTraceHook, 6)); + + lttv_trace_find_hook(ts->parent.t, "core", "process", "event_sub_id", + "event_data1", "event_data2", before_process_hook, + &g_array_index(hooks, LttvTraceHook, 7)); + +#if 0 + lttv_trace_find_hook(ts->parent.t, "core", "process_fork", "child_pid", + NULL, NULL, process_fork, &g_array_index(hooks, LttvTraceHook, 7)); + + lttv_trace_find_hook(ts->parent.t, "core", "process_exit", NULL, NULL, + NULL, process_exit, &g_array_index(hooks, LttvTraceHook, 8)); +#endif //0 + + /* after hooks */ + + lttv_trace_find_hook(ts->parent.t, "core","syscall_entry","syscall_id", + NULL, NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 8)); + + lttv_trace_find_hook(ts->parent.t, "core", "syscall_exit", NULL, NULL, + NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 9)); + + lttv_trace_find_hook(ts->parent.t, "core", "trap_entry", "trap_id", + NULL, NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 10)); + + lttv_trace_find_hook(ts->parent.t, "core", "trap_exit", NULL, NULL, NULL, + after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 11)); + + lttv_trace_find_hook(ts->parent.t, "core", "irq_entry", "irq_id", NULL, + NULL, after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 12)); + + lttv_trace_find_hook(ts->parent.t, "core", "irq_exit", NULL, NULL, NULL, + after_execmode_hook, &g_array_index(hooks, LttvTraceHook, 13)); + + lttv_trace_find_hook(ts->parent.t, "core", "schedchange", "in", "out", + "out_state", after_schedchange_hook, + &g_array_index(hooks, LttvTraceHook, 14)); + + lttv_trace_find_hook(ts->parent.t, "core", "process", "event_sub_id", + "event_data1", "event_data2", after_process_hook, + &g_array_index(hooks, LttvTraceHook, 15)); + +#if 0 + lttv_trace_find_hook(ts->parent.t, "core", "process_fork", "child_pid", + NULL, NULL, process_fork, &g_array_index(hooks, LttvTraceHook, 7)); + + lttv_trace_find_hook(ts->parent.t, "core", "process_exit", NULL, NULL, + NULL, process_exit, &g_array_index(hooks, LttvTraceHook, 8)); +#endif //0 + + + + /* Add these hooks to each event_by_id hooks list */ + /* add before */ + for(k = 0 ; k < hooks->len/2 ; k++) { + hook = g_array_index(hooks, LttvTraceHook, k); + lttv_hooks_add(lttv_hooks_by_id_find(event_by_id, + hook.id), hook.h, + events_request, + LTTV_PRIO_STATE-5); + } + + /* add after */ + for(k = hooks->len/2 ; k < hooks->len ; k++) { + hook = g_array_index(hooks, LttvTraceHook, k); + lttv_hooks_add(lttv_hooks_by_id_find(event_by_id, + hook.id), hook.h, + events_request, + LTTV_PRIO_STATE+5); + } + + events_request->hooks = hooks; + + // Fill the events request + events_request->owner = control_flow_data; + events_request->viewer_data = control_flow_data; + events_request->servicing = FALSE; + events_request->start_time = start; + events_request->start_position = NULL; + events_request->stop_flag = FALSE; + events_request->end_time = time_end; + events_request->num_events = G_MAXUINT; + events_request->end_position = NULL; + events_request->trace = i; /* FIXME */ + events_request->before_chunk_traceset = before_chunk_traceset; + events_request->before_chunk_trace = NULL; + events_request->before_chunk_tracefile = NULL; + events_request->event = NULL; + events_request->event_by_id = event_by_id; + events_request->after_chunk_tracefile = NULL; + events_request->after_chunk_trace = NULL; + events_request->after_chunk_traceset = after_chunk_traceset; + events_request->before_request = before_request_hook; + events_request->after_request = after_request_hook; + + g_debug("req : start : %u, %u", start.tv_sec, + start.tv_nsec); + + g_debug("req : end : %u, %u", time_end.tv_sec, + time_end.tv_nsec); + + lttvwindow_events_request(tab, events_request); + + } + + } + +#if 0 lttv_hooks_add(event, before_schedchange_hook, events_request, @@ -175,37 +372,8 @@ void drawing_data_request(Drawing_t *drawing, after_process_hook, events_request, LTTV_PRIO_STATE+5); +#endif //0 - // Fill the events request - events_request->owner = control_flow_data; - events_request->viewer_data = control_flow_data; - events_request->servicing = FALSE; - events_request->start_time = start; - events_request->start_position = NULL; - events_request->stop_flag = FALSE; - events_request->end_time = time_end; - events_request->num_events = G_MAXUINT; - events_request->end_position = NULL; - events_request->before_chunk_traceset = before_chunk_traceset; - events_request->before_chunk_trace = NULL; - events_request->before_chunk_tracefile = NULL; - events_request->event = event; - events_request->event_by_id = NULL; - events_request->after_chunk_tracefile = NULL; - events_request->after_chunk_trace = NULL; - events_request->after_chunk_traceset = after_chunk_traceset; - events_request->before_request = before_request_hook; - events_request->after_request = after_request_hook; - - g_debug("req : start : %u, %u", start.tv_sec, - start.tv_nsec); - - g_debug("req : end : %u, %u", time_end.tv_sec, - time_end.tv_nsec); - - lttvwindow_events_request_remove_all(tab, - control_flow_data); - lttvwindow_events_request(tab, events_request); } @@ -483,7 +651,7 @@ after_expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data } - +#if 0 void tree_row_activated(GtkTreeModel *treemodel, GtkTreePath *arg1, @@ -498,12 +666,12 @@ tree_row_activated(GtkTreeModel *treemodel, path_indices = gtk_tree_path_get_indices (arg1); - height = get_cell_height( + height = get_cell_height(cfd->process_list, GTK_TREE_VIEW(treeview)); drawing->horizontal_sel = height * path_indices[0]; g_critical("new hor sel : %i", drawing->horizontal_sel); } - +#endif //0 /* mouse click */ static gboolean @@ -710,6 +878,11 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) gtk_widget_show(drawing->scrollbar); gtk_widget_show(drawing->hbox); + /* 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); return drawing; } @@ -717,6 +890,14 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) void drawing_destroy(Drawing_t *drawing) { g_info("drawing_destroy %p", drawing); + + /* Free the colors */ + GdkColormap* colormap = gdk_colormap_get_system(); + + gdk_colormap_free_colors(colormap, drawing_colors, NUM_COLORS); + + + // Do not unref here, Drawing_t destroyed by it's widget. //g_object_unref( G_OBJECT(drawing->drawing_area)); if(drawing->gc != NULL) @@ -780,8 +961,13 @@ __inline void convert_time_to_pixels( time_ll = ltt_time_to_uint64(time); interval_ll = ltt_time_to_uint64(window_time_interval); - - *x = (guint)(time_ll * width / interval_ll); + + if(interval_ll == 0) { + g_assert(time_ll == 0); + *x = 0; + } else { + *x = (guint)(time_ll * width / interval_ll); + } }