From e025a729300a06b0de77a8c63d7256fed2658ccb Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 10 Aug 2004 13:23:28 +0000 Subject: [PATCH] now default viewers on main tab git-svn-id: http://ltt.polymtl.ca/svn@696 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/gui/controlflow/eventhooks.c | 51 +++++++------------ .../lttv/modules/gui/controlflow/module.c | 3 +- .../lttv/modules/gui/detailedevents/events.c | 3 +- .../gui/lttvwindow/lttvwindow/callbacks.c | 46 ++++++++++++++++- .../gui/lttvwindow/lttvwindow/init_module.c | 2 + .../gui/lttvwindow/lttvwindow/lttvwindow.c | 42 ++++++++++++++- .../gui/lttvwindow/lttvwindow/lttvwindow.h | 8 ++- .../lttv/modules/gui/statistics/statistics.c | 23 ++++----- 8 files changed, 128 insertions(+), 50 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 66209010..d458fe04 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -397,6 +397,12 @@ int draw_before_hook(void *hook_data, void *call_data) &height, &hashed_process_data) == 1) { + g_assert(!(process->pid == 432 && + ltt_time_compare(process->creation_time, + ltt_time_zero)==0)); + + g_assert(!(process->pid == 432 && + process->creation_time.tv_nsec == 47797905)); /* Process not present */ processlist_add(process_list, pid_out, @@ -1270,6 +1276,13 @@ int draw_after_hook(void *hook_data, void *call_data) &height, &hashed_process_data_in) == 1) { + g_assert(!(process_in->pid == 432 && + ltt_time_compare(process_in->creation_time, + ltt_time_zero)==0)); + + g_assert(!(process_in->pid == 432 && + process_in->creation_time.tv_nsec == 47797905)); + /* Process not present */ processlist_add(process_list, pid_in, @@ -2158,35 +2171,6 @@ typedef struct _ClosureData { } ClosureData; -/* find_process - * Input : A trace and a PID. - * - * - For each CPU of the trace - * - Search in trace states by PID and CPU key - * - If no ProcessState found, return NULL. - */ -static LttvProcessState *find_process(LttvTraceState *tstate, guint pid) -{ - guint cpu_num = ltt_trace_per_cpu_tracefile_number(tstate->parent.t); - GQuark cpu_name; - guint i; - - LttvProcessState *real_state = NULL; - - for(i=0;iparent.tracefiles[i])->cpu_name; - LttvProcessState *state = lttv_state_find_process_from_trace(tstate, - cpu_name, - pid); - if(state != NULL) { - real_state = state; - break; - } - } - return real_state; -} - - void draw_closure(gpointer key, gpointer value, gpointer user_data) { ProcessInfo *process_info = (ProcessInfo*)key; @@ -2222,11 +2206,14 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data) * be added after the state update. */ g_assert(lttv_traceset_number(tsc->ts) > 0); - LttvTraceState *trace_state = - (LttvTraceState*)tsc->traces[process_info->trace_num]; + /* tracefiles[0] is ok here, because we draw for every PID, and + * assume CPU 0 for PID 0 //FIXME */ + LttvTracefileState *tfs = + (LttvTracefileState*)tsc->traces[process_info->trace_num]->tracefiles[0]; LttvProcessState *process; - process = find_process(trace_state, process_info->pid); + process = lttv_state_find_process(tfs, + process_info->pid); if(process != NULL) { diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/module.c b/ltt/branches/poly/lttv/modules/gui/controlflow/module.c index db6d256f..d2099fc4 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/module.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/module.c @@ -70,7 +70,8 @@ static void init() { g_info("GUI ControlFlow Viewer init()"); /* Register the toolbar insert button and menu entry*/ - lttvwindow_register_constructor("/", + lttvwindow_register_constructor("guicontrolflow", + "/", "Insert Control Flow Viewer", hGuiControlFlowInsert_xpm, "Insert Control Flow Viewer", diff --git a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c index f16e7436..414a311b 100644 --- a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c +++ b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c @@ -1867,7 +1867,8 @@ void remove_all_items_from_queue(GQueue *q) */ static void init() { - lttvwindow_register_constructor("/", + lttvwindow_register_constructor("guievents", + "/", "Insert Event Viewer", hGuiEventsInsert_xpm, "Insert Event Viewer", diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 5630febb..273207da 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -4308,6 +4308,50 @@ void construct_main_window(MainWindow * parent) } LttvTraceset *traceset = new_tab->traceset_info->traceset; SetTraceset(new_tab, traceset); + + /* Insert default viewers */ + { + LttvAttributeType type; + LttvAttributeName name; + LttvAttributeValue value; + LttvAttribute *attribute; + + LttvIAttribute *attributes_global = + LTTV_IATTRIBUTE(lttv_global_attributes()); + + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(attributes_global), + LTTV_VIEWER_CONSTRUCTORS))); + + name = g_quark_from_string("guievents"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); + } + + name = g_quark_from_string("guicontrolflow"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); + } + + name = g_quark_from_string("guistatistics"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); + } + + } } g_printf("There are now : %d windows\n",g_slist_length(g_main_window_list)); @@ -4323,7 +4367,7 @@ void tab_destructor(Tab * tab) int i, nb, ref_count; LttvTrace * trace; - g_object_free(tab->tooltips); + g_object_unref(tab->tooltips); if(tab->attributes) g_object_unref(tab->attributes); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c index a4e7d427..67c6a54e 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c @@ -50,6 +50,7 @@ LttvTraceInfo LTTV_TRACES, LTTV_COMPUTATION, + LTTV_VIEWER_CONSTRUCTORS, LTTV_REQUESTS_QUEUE, LTTV_REQUESTS_CURRENT, LTTV_NOTIFY_QUEUE, @@ -144,6 +145,7 @@ static void init() { LTTV_TRACES = g_quark_from_string("traces"); LTTV_COMPUTATION = g_quark_from_string("computation"); + LTTV_VIEWER_CONSTRUCTORS = g_quark_from_string("viewer_constructors"); LTTV_REQUESTS_QUEUE = g_quark_from_string("requests_queue"); LTTV_REQUESTS_CURRENT = g_quark_from_string("requests_current"); LTTV_NOTIFY_QUEUE = g_quark_from_string("notify_queue"); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c index 9f153a75..ea848ada 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -228,6 +228,7 @@ void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewe * * It should be called by init function of the module. * + * @param name name of the viewer * @param menu_path path of the menu item. * @param menu_text text of the menu item. * @param pixmap Image shown on the toolbar item. @@ -236,7 +237,8 @@ void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewe */ void lttvwindow_register_constructor - (char * menu_path, + (char * name, + char * menu_path, char * menu_text, char ** pixmap, char * tooltip, @@ -249,6 +251,8 @@ void lttvwindow_register_constructor LttvMenuClosure menu_c; LttvAttributeValue value; + if(view_constructor == NULL) return; + if(pixmap != NULL) { g_assert(lttv_iattribute_find_by_path(attributes_global, "viewers/toolbar", LTTV_POINTER, &value)); @@ -281,6 +285,19 @@ void lttvwindow_register_constructor (gpointer)add_menu_constructor, &menu_c); } + { + LttvAttribute *attribute; + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(attributes_global), + LTTV_VIEWER_CONSTRUCTORS))); + + g_assert(lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute), + name, LTTV_POINTER, &value)); + + *(value.v_pointer) = view_constructor; + + } } @@ -324,6 +341,29 @@ void lttvwindow_unregister_constructor view_constructor); lttv_menus_remove(menu, view_constructor); } + + { + LttvAttribute *attribute; + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(attributes_global), + LTTV_VIEWER_CONSTRUCTORS))); + + guint num = lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute)); + guint i; + LttvAttributeName name; + LttvAttributeValue value; + LttvAttributeType type; + + for(i=0;i +#include #include #include @@ -281,7 +282,7 @@ gui_statistic(Tab *tab) statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash, g_str_equal, statistic_destroy_hash_key, - statistic_destroy_hash_data); + NULL); statistic_viewer_data->hpaned_v = gtk_hpaned_new(); statistic_viewer_data->store_m = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING); @@ -388,15 +389,12 @@ void statistic_destroy_hash_key(gpointer key) g_free(key); } -void statistic_destroy_hash_data(gpointer data) -{ - // g_free(data); -} - +#ifdef DEBUG #include extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; +#endif //DEBUG void show_traceset_stats(StatisticViewerData * statistic_viewer_data) { @@ -434,9 +432,11 @@ void show_traceset_stats(StatisticViewerData * statistic_viewer_data) for(i = 0 ; i < nb ; i++) { tcs = (LttvTraceStats *)(LTTV_TRACESET_CONTEXT(tscs)->traces[i]); desc = ltt_trace_system_description(tcs->parent.parent.t); - sprintf(trace_str, "Trace on system %s at time %d secs", + LttTime start_time = ltt_trace_system_description_trace_start_time(desc); + sprintf(trace_str, "Trace on system %s at time %lu.%09lu", ltt_trace_system_description_node_name(desc), - (ltt_trace_system_description_trace_start_time(desc)).tv_sec); + start_time.tv_sec, + start_time.tv_nsec); gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter,NAME_COLUMN,trace_str,-1); @@ -491,7 +491,6 @@ void show_statistic(StatisticViewerData * statistic_viewer_data, LttvAttribute* stats, GtkTextBuffer* buf) { int i, nb , flag; - LttvAttribute *subtree; LttvAttributeName name; LttvAttributeValue value; LttvAttributeType type; @@ -524,7 +523,7 @@ void show_statistic(StatisticViewerData * statistic_viewer_data, sprintf(type_value, " : %f\n", *value.v_double); break; case LTTV_TIME: - sprintf(type_value, " : %10u.%09u\n", value.v_time->tv_sec, + sprintf(type_value, " : %10lu.%09lu\n", value.v_time->tv_sec, value.v_time->tv_nsec); break; case LTTV_POINTER: @@ -660,7 +659,8 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data, */ static void init() { - lttvwindow_register_constructor("/", + lttvwindow_register_constructor("guistatistics", + "/", "Insert Statistic Viewer", hGuiStatisticInsert_xpm, "Insert Statistic Viewer", @@ -684,7 +684,6 @@ void statistic_destroy_walk(gpointer data, gpointer user_data) * everything that has been registered in the gtkTraceSet API. */ static void destroy() { - int i; g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL ); g_slist_free(g_statistic_viewer_data_list); -- 2.34.1