X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fstatistics%2Fstatistics.c;h=7e781adbca6281d99ccc36cd9f4ef0191827fcb2;hb=0a06ab49ede668b34dee3ecf5406a4f1d37b6f97;hp=9f63a9e7742a0269601f1c80b1a394f10a626db0;hpb=b5e17af510367e54b9bae1523766c2fba85905f9;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c index 9f63a9e7..7e781adb 100644 --- a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c +++ b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c @@ -39,6 +39,7 @@ #include #include +#include #include "hGuiStatisticInsert.xpm" @@ -57,9 +58,9 @@ static void request_background_data(StatisticViewerData *svd); GtkWidget *guistatistic_get_widget(StatisticViewerData *svd); //! Statistic Viewer's constructor hook -GtkWidget *h_gui_statistic(Tab *tab); +GtkWidget *h_gui_statistic(LttvPlugin *plugin); //! Statistic Viewer's constructor -StatisticViewerData *gui_statistic(Tab *tab); +StatisticViewerData *gui_statistic(LttvPluginTab *ptab); //! Statistic Viewer's destructor void gui_statistic_destructor(StatisticViewerData *statistic_viewer_data); @@ -91,6 +92,7 @@ enum struct _StatisticViewerData{ Tab *tab; + LttvPluginTab *ptab; //LttvTracesetStats * stats; int size; @@ -113,6 +115,8 @@ struct _StatisticViewerData{ //hash GHashTable *statistic_hash; + + guint background_info_waiting; }; @@ -130,12 +134,16 @@ static gint background_ready(void *hook_data, void *call_data) Tab *tab = svd->tab; LttvTrace *trace = (LttvTrace*)call_data; - g_debug("statistics viewer : background computation data ready."); + svd->background_info_waiting--; + + if(svd->background_info_waiting == 0) { + g_message("statistics viewer : background computation data ready."); - gtk_tree_store_clear (svd->store_m); + gtk_tree_store_clear (svd->store_m); - lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab)); - show_traceset_stats(svd); + lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab)); + show_traceset_stats(svd); + } return 0; } @@ -151,11 +159,15 @@ static void request_background_data(StatisticViewerData *svd) gint num_traces = lttvwindowtraces_get_number(); gint i; LttvTrace *trace; + GtkTextBuffer* buf; LttvHooks *background_ready_hook = lttv_hooks_new(); lttv_hooks_add(background_ready_hook, background_ready, svd, LTTV_PRIO_DEFAULT); + svd->background_info_waiting = num_traces; + buf = gtk_text_view_get_buffer((GtkTextView*)svd->text_v); + gtk_text_buffer_set_text(buf,"", -1); for(i=0;ibackground_info_waiting = 1; + lttv_hooks_call(background_ready_hook, NULL); + } lttv_hooks_destroy(background_ready_hook); } @@ -232,9 +248,10 @@ gui_statistic_destructor(StatisticViewerData *statistic_viewer_data) * @return The widget created. */ GtkWidget * -h_gui_statistic(Tab *tab) +h_gui_statistic(LttvPlugin *plugin) { - StatisticViewerData* statistic_viewer_data = gui_statistic(tab) ; + LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); + StatisticViewerData* statistic_viewer_data = gui_statistic(ptab) ; if(statistic_viewer_data) return guistatistic_get_widget(statistic_viewer_data); @@ -268,14 +285,15 @@ gboolean statistic_insert_traceset_stats(void * stats) * @return The Statistic viewer data created. */ StatisticViewerData * -gui_statistic(Tab *tab) +gui_statistic(LttvPluginTab *ptab) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; StatisticViewerData* statistic_viewer_data = g_new(StatisticViewerData,1); - + Tab *tab = ptab->tab; statistic_viewer_data->tab = tab; + statistic_viewer_data->ptab = ptab; // statistic_viewer_data->stats = // lttvwindow_get_traceset_stats(statistic_viewer_data->tab); // statistic_viewer_data->calculate_stats = @@ -284,8 +302,7 @@ gui_statistic(Tab *tab) lttvwindow_register_traceset_notify(statistic_viewer_data->tab, statistic_traceset_changed, statistic_viewer_data); - request_background_data(statistic_viewer_data); - + statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash, g_str_equal, statistic_destroy_hash_key, @@ -356,6 +373,8 @@ gui_statistic(Tab *tab) g_statistic_viewer_data_list, statistic_viewer_data); + request_background_data(statistic_viewer_data); + return statistic_viewer_data; } @@ -426,7 +445,7 @@ void show_traceset_stats(StatisticViewerData * statistic_viewer_data) ts = tscs->parent.parent.ts; nb = lttv_traceset_number(ts); - if(nb == 0)return; + if(nb == 0) return; gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter, @@ -471,6 +490,7 @@ void show_tree(StatisticViewerData * statistic_viewer_data, LttvAttributeName name; LttvAttributeValue value; LttvAttributeType type; + gboolean is_named; gchar * str, dir_str[PATH_LENGTH]; GtkTreePath * path; GtkTreeIter iter; @@ -478,17 +498,20 @@ void show_tree(StatisticViewerData * statistic_viewer_data, nb = lttv_attribute_get_number(stats); for(i = 0 ; i < nb ; i++) { - type = lttv_attribute_get(stats, i, &name, &value); + type = lttv_attribute_get(stats, i, &name, &value, &is_named); switch(type) { case LTTV_GOBJECT: if(LTTV_IS_ATTRIBUTE(*(value.v_gobject))) { - sprintf(dir_str, "%s", g_quark_to_string(name)); subtree = (LttvAttribute *)*(value.v_gobject); - gtk_tree_store_append (store, &iter, parent); - gtk_tree_store_set (store, &iter,NAME_COLUMN,dir_str,-1); - path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); - str = gtk_tree_path_to_string (path); - g_hash_table_insert(statistic_viewer_data->statistic_hash, + if(is_named) + sprintf(dir_str, "%s", g_quark_to_string(name)); + else + sprintf(dir_str, "%u", name); + gtk_tree_store_append (store, &iter, parent); + gtk_tree_store_set (store, &iter,NAME_COLUMN,dir_str,-1); + path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); + str = gtk_tree_path_to_string (path); + g_hash_table_insert(statistic_viewer_data->statistic_hash, (gpointer)str, subtree); show_tree(statistic_viewer_data, subtree, &iter); } @@ -506,14 +529,18 @@ void show_statistic(StatisticViewerData * statistic_viewer_data, LttvAttributeName name; LttvAttributeValue value; LttvAttributeType type; + gboolean is_named; gchar type_name[PATH_LENGTH], type_value[PATH_LENGTH]; GtkTextIter text_iter; flag = 0; nb = lttv_attribute_get_number(stats); for(i = 0 ; i < nb ; i++) { - type = lttv_attribute_get(stats, i, &name, &value); - sprintf(type_name,"%s", g_quark_to_string(name)); + type = lttv_attribute_get(stats, i, &name, &value, &is_named); + if(is_named) + sprintf(type_name,"%s", g_quark_to_string(name)); + else + sprintf(type_name,"%u", name); type_value[0] = '\0'; switch(type) { case LTTV_INT: