X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fcontrolflow%2Fprocesslist.c;h=55715cd8206d57caf3df8c5604e735c6da1f1d92;hb=f37a2002e940e771ef47c9936f9b82b79e64d086;hp=a1d03ac3b19d38926a322a1d5d5858df6064ccac;hpb=88feb618dc79481733516a77f285bb6514bb1d17;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c index a1d03ac3..55715cd8 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -1,3 +1,20 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2003-2004 Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ #include #include @@ -5,6 +22,10 @@ #include "processlist.h" #include "drawitem.h" +#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) + + /***************************************************************************** * Methods to synchronize process list * *****************************************************************************/ @@ -16,6 +37,7 @@ enum PID_COLUMN, BIRTH_S_COLUMN, BIRTH_NS_COLUMN, + TRACE_COLUMN, N_COLUMNS }; @@ -129,6 +151,37 @@ gint process_sort_func ( GtkTreeModel *model, g_value_unset(&a); g_value_unset(&b); + /* Order by trace_num */ + gtk_tree_model_get_value( model, + it_a, + TRACE_COLUMN, + &a); + + gtk_tree_model_get_value( model, + it_b, + TRACE_COLUMN, + &b); + + if(G_VALUE_TYPE(&a) == G_TYPE_ULONG + && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) + { + if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 1; + } + if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) + { + g_value_unset(&a); + g_value_unset(&b); + return 0; + } + + } + + + return 0; } @@ -151,6 +204,9 @@ gboolean equ_fct(gconstpointer a, gconstpointer b) return 0; // g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); + if(((ProcessInfo*)a)->trace_num != ((ProcessInfo*)b)->trace_num) + return 0; + return 1; } @@ -175,13 +231,13 @@ ProcessList *processlist_construct(void) G_TYPE_STRING, G_TYPE_UINT, G_TYPE_ULONG, + G_TYPE_ULONG, G_TYPE_ULONG); process_list->process_list_widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (process_list->list_store)); - g_object_unref (G_OBJECT (process_list->list_store)); gtk_tree_sortable_set_sort_func( @@ -203,7 +259,7 @@ ProcessList *processlist_construct(void) gtk_tree_view_set_headers_visible( - GTK_TREE_VIEW(process_list->process_list_widget), FALSE); + GTK_TREE_VIEW(process_list->process_list_widget), TRUE); /* Create a column, associating the "text" attribute of the * cell_renderer to the first column of the model */ @@ -218,7 +274,9 @@ ProcessList *processlist_construct(void) gtk_tree_view_column_set_fixed_width (column, 45); gtk_tree_view_append_column ( GTK_TREE_VIEW (process_list->process_list_widget), column); - + + process_list->button = column->button; + column = gtk_tree_view_column_new_with_attributes ( "PID", renderer, "text", @@ -246,6 +304,15 @@ ProcessList *processlist_construct(void) gtk_tree_view_append_column ( GTK_TREE_VIEW (process_list->process_list_widget), column); + column = gtk_tree_view_column_new_with_attributes ( "TRACE", + renderer, + "text", + TRACE_COLUMN, + NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (process_list->process_list_widget), column); + + //gtk_tree_view_column_set_visible(column, 0); g_object_set_data_full( @@ -256,14 +323,49 @@ ProcessList *processlist_construct(void) return process_list; } + void processlist_destroy(ProcessList *process_list) { + g_debug("processlist_destroy %p", process_list); g_hash_table_destroy(process_list->process_hash); process_list->process_hash = NULL; g_free(process_list); + g_debug("processlist_destroy end"); +} + +static gboolean remove_hash_item(ProcessInfo *process_info, + HashedProcessData *hashed_process_data, + ProcessList *process_list) +{ + GtkTreePath *tree_path; + GtkTreeIter iter; + + tree_path = gtk_tree_row_reference_get_path( + hashed_process_data->row_ref); + + gtk_tree_model_get_iter ( + GTK_TREE_MODEL(process_list->list_store), + &iter, tree_path); + + gtk_tree_path_free(tree_path); + + gtk_list_store_remove (process_list->list_store, &iter); + + return TRUE; /* remove the element from the hash table */ } +void processlist_clear(ProcessList *process_list) +{ + g_info("processlist_clear %p", process_list); + + g_hash_table_foreach_remove(process_list->process_hash, + (GHRFunc)remove_hash_item, + (gpointer)process_list); + process_list->number_of_process = 0; +} + + GtkWidget *processlist_get_widget(ProcessList *process_list) { return process_list->process_list_widget; @@ -298,7 +400,8 @@ void destroy_hash_data(gpointer data) int processlist_add( ProcessList *process_list, guint pid, LttTime *birth, - gchar *name, + guint trace_num, + const gchar *name, guint *height, HashedProcessData **pm_hashed_process_data) { @@ -309,7 +412,17 @@ int processlist_add( ProcessList *process_list, Process_Info->pid = pid; Process_Info->birth = *birth; + Process_Info->trace_num = trace_num; + + /* When we create it from before state update, we are sure that the + * last event occured before the beginning of the global area. + * + * If it is created after state update, this value (0) will be + * overriden by the new state before anything is drawn. + */ + hashed_process_data->x = 0; +#if 0 hashed_process_data->draw_context = g_new(DrawContext, 1); hashed_process_data->draw_context->drawable = NULL; hashed_process_data->draw_context->gc = NULL; @@ -354,7 +467,8 @@ int processlist_add( ProcessList *process_list, hashed_process_data->draw_context->previous->modify_under->x = -1; hashed_process_data->draw_context->previous->modify_under->y = -1; hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; - +#endif //0 + /* Add a new row to the model */ gtk_list_store_append ( process_list->list_store, &iter); //g_critical ( "iter before : %s", gtk_tree_path_to_string ( @@ -366,6 +480,7 @@ int processlist_add( ProcessList *process_list, PID_COLUMN, pid, BIRTH_S_COLUMN, birth->tv_sec, BIRTH_NS_COLUMN, birth->tv_nsec, + TRACE_COLUMN, trace_num, -1); hashed_process_data->row_ref = gtk_tree_row_reference_new ( GTK_TREE_MODEL(process_list->list_store), @@ -392,7 +507,8 @@ int processlist_add( ProcessList *process_list, int processlist_remove( ProcessList *process_list, guint pid, - LttTime *birth) + LttTime *birth, + guint trace_num) { ProcessInfo Process_Info; gint *path_indices; @@ -401,6 +517,7 @@ int processlist_remove( ProcessList *process_list, Process_Info.pid = pid; Process_Info.birth = *birth; + Process_Info.trace_num = trace_num; if(hashed_process_data = @@ -408,32 +525,19 @@ int processlist_remove( ProcessList *process_list, process_list->process_hash, &Process_Info)) { + GtkTreePath *tree_path; + + tree_path = gtk_tree_row_reference_get_path( + hashed_process_data->row_ref); + gtk_tree_model_get_iter ( GTK_TREE_MODEL(process_list->list_store), - &iter, - gtk_tree_row_reference_get_path( - (GtkTreeRowReference*)hashed_process_data->row_ref) - ); + &iter, tree_path); + + gtk_tree_path_free(tree_path); gtk_list_store_remove (process_list->list_store, &iter); - g_free(hashed_process_data->draw_context->previous->modify_under); - g_free(hashed_process_data->draw_context->previous->modify_middle); - g_free(hashed_process_data->draw_context->previous->modify_over); - g_free(hashed_process_data->draw_context->previous->under); - g_free(hashed_process_data->draw_context->previous->middle); - g_free(hashed_process_data->draw_context->previous->over); - g_free(hashed_process_data->draw_context->previous); - g_free(hashed_process_data->draw_context->current->modify_under); - g_free(hashed_process_data->draw_context->current->modify_middle); - g_free(hashed_process_data->draw_context->current->modify_over); - g_free(hashed_process_data->draw_context->current->under); - g_free(hashed_process_data->draw_context->current->middle); - g_free(hashed_process_data->draw_context->current->over); - g_free(hashed_process_data->draw_context->current); - g_free(hashed_process_data->draw_context); - g_free(hashed_process_data); - g_hash_table_remove(process_list->process_hash, &Process_Info); @@ -454,7 +558,7 @@ guint processlist_get_height(ProcessList *process_list) gint processlist_get_process_pixels( ProcessList *process_list, - guint pid, LttTime *birth, + guint pid, LttTime *birth, guint trace_num, guint *y, guint *height, HashedProcessData **pm_hashed_process_data) @@ -466,6 +570,7 @@ gint processlist_get_process_pixels( ProcessList *process_list, Process_Info.pid = pid; Process_Info.birth = *birth; + Process_Info.trace_num = trace_num; if(hashed_process_data = (HashedProcessData*)g_hash_table_lookup( @@ -480,6 +585,8 @@ gint processlist_get_process_pixels( ProcessList *process_list, GTK_TREE_VIEW(process_list->process_list_widget)); *y = *height * path_indices[0]; *pm_hashed_process_data = hashed_process_data; + gtk_tree_path_free(tree_path); + return 0; } else { *pm_hashed_process_data = hashed_process_data; @@ -505,6 +612,7 @@ gint processlist_get_pixels_from_data( ProcessList *process_list, *height = get_cell_height( GTK_TREE_VIEW(process_list->process_list_widget)); *y = *height * path_indices[0]; + gtk_tree_path_free(tree_path); return 0;