X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fcontrolflow%2Fprocesslist.c;h=924d8c52501b795eb673f579433b98304250ff9f;hb=4b7dc462963cae143ed66dd82a3d88a792f91b61;hp=4834da8f44218ec99b012793cb654bf83c5a5dbc;hpb=2309386913ad8c4ce16fa35b7ce749ea7845e292;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 4834da8f..924d8c52 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -32,7 +32,7 @@ * Methods to synchronize process list * *****************************************************************************/ -static guint get_cpu_number_from_name(GQuark name); +static __inline guint get_cpu_number_from_name(GQuark name); /* Enumeration of the columns */ enum @@ -233,16 +233,17 @@ gint process_sort_func ( GtkTreeModel *model, } -guint hash_fct(gconstpointer key) +static guint process_list_hash_fct(gconstpointer key) { - return ((ProcessInfo*)key)->pid; + guint pid = ((ProcessInfo*)key)->pid; + return ((pid>>8 ^ pid>>4 ^ pid>>2 ^ pid) ^ ((ProcessInfo*)key)->cpu); } -gboolean equ_fct(gconstpointer a, gconstpointer b) +static gboolean process_list_equ_fct(gconstpointer a, gconstpointer b) { const ProcessInfo *pa = (const ProcessInfo*)a; const ProcessInfo *pb = (const ProcessInfo*)b; - + if(pa->pid != pb->pid) return 0; @@ -276,6 +277,7 @@ ProcessList *processlist_construct(void) ProcessList* process_list = g_new(ProcessList,1); process_list->number_of_process = 0; + process_list->cell_height_cache = -1; /* Create the Process list */ process_list->list_store = gtk_list_store_new ( N_COLUMNS, @@ -306,7 +308,7 @@ ProcessList *processlist_construct(void) GTK_SORT_ASCENDING); process_list->process_hash = g_hash_table_new_full( - hash_fct, equ_fct, + process_list_hash_fct, process_list_equ_fct, destroy_hash_key, destroy_hash_data ); @@ -406,17 +408,9 @@ 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); + iter = hashed_process_data->y_iter; gtk_list_store_remove (process_list->list_store, &iter); @@ -441,18 +435,19 @@ GtkWidget *processlist_get_widget(ProcessList *process_list) -gint get_cell_height(GtkTreeView *tree_view) +static __inline gint get_cell_height(ProcessList *process_list, GtkTreeView *tree_view) { - gint height; - GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 0); - //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); - //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; + gint height = process_list->cell_height_cache; + if(height != -1) return height; + else { + GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 0); - //g_list_free(Render_List); - gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); - //g_critical("cell 0 height : %u",height); + gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, + &process_list->cell_height_cache); + } + - return height; + return process_list->cell_height_cache; } void destroy_hash_key(gpointer key) @@ -475,7 +470,6 @@ int processlist_add( ProcessList *process_list, guint *height, HashedProcessData **pm_hashed_process_data) { - GtkTreeIter iter ; ProcessInfo *Process_Info = g_new(ProcessInfo, 1); HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); *pm_hashed_process_data = hashed_process_data; @@ -500,12 +494,10 @@ int processlist_add( ProcessList *process_list, hashed_process_data->x.under = 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 ( - // gtk_tree_model_get_path ( - // GTK_TREE_MODEL(process_list->list_store), - // &iter))); - gtk_list_store_set ( process_list->list_store, &iter, + gtk_list_store_append ( process_list->list_store, + &hashed_process_data->y_iter); + + gtk_list_store_set ( process_list->list_store, &hashed_process_data->y_iter, PROCESS_COLUMN, name, PID_COLUMN, pid, PPID_COLUMN, ppid, @@ -514,11 +506,13 @@ int processlist_add( ProcessList *process_list, BIRTH_NS_COLUMN, birth->tv_nsec, TRACE_COLUMN, trace_num, -1); +#if 0 hashed_process_data->row_ref = gtk_tree_row_reference_new ( GTK_TREE_MODEL(process_list->list_store), gtk_tree_model_get_path( GTK_TREE_MODEL(process_list->list_store), &iter)); +#endif //0 g_hash_table_insert(process_list->process_hash, (gpointer)Process_Info, (gpointer)hashed_process_data); @@ -529,12 +523,11 @@ int processlist_add( ProcessList *process_list, // &iter))); process_list->number_of_process++; - *height = get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) + *height = get_cell_height(process_list, + GTK_TREE_VIEW(process_list->process_list_widget)) * process_list->number_of_process ; - return 0; - } int processlist_remove( ProcessList *process_list, @@ -549,7 +542,10 @@ int processlist_remove( ProcessList *process_list, GtkTreeIter iter; Process_Info.pid = pid; - Process_Info.cpu = cpu; + if(pid == 0) + Process_Info.cpu = cpu; + else + Process_Info.cpu = 0; Process_Info.birth = *birth; Process_Info.trace_num = trace_num; @@ -559,16 +555,7 @@ 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, tree_path); - - gtk_tree_path_free(tree_path); + iter = hashed_process_data->y_iter; gtk_list_store_remove (process_list->list_store, &iter); @@ -586,12 +573,13 @@ int processlist_remove( ProcessList *process_list, guint processlist_get_height(ProcessList *process_list) { - return get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) + return get_cell_height(process_list, + GTK_TREE_VIEW(process_list->process_list_widget)) * process_list->number_of_process ; } -gint processlist_get_process_pixels( ProcessList *process_list, +__inline gint processlist_get_process_pixels( ProcessList *process_list, guint pid, guint cpu, LttTime *birth, guint trace_num, guint *y, guint *height, @@ -603,7 +591,10 @@ gint processlist_get_process_pixels( ProcessList *process_list, HashedProcessData *hashed_process_data = NULL; Process_Info.pid = pid; - Process_Info.cpu = cpu; + if(pid == 0) + Process_Info.cpu = cpu; + else + Process_Info.cpu = 0; Process_Info.birth = *birth; Process_Info.trace_num = trace_num; @@ -612,11 +603,12 @@ gint processlist_get_process_pixels( ProcessList *process_list, process_list->process_hash, &Process_Info)) { - tree_path = gtk_tree_row_reference_get_path( - hashed_process_data->row_ref); + tree_path = gtk_tree_model_get_path( + GTK_TREE_MODEL(process_list->list_store), + &hashed_process_data->y_iter); path_indices = gtk_tree_path_get_indices (tree_path); - *height = get_cell_height( + *height = get_cell_height(process_list, GTK_TREE_VIEW(process_list->process_list_widget)); *y = *height * path_indices[0]; *pm_hashed_process_data = hashed_process_data; @@ -631,7 +623,7 @@ gint processlist_get_process_pixels( ProcessList *process_list, } -gint processlist_get_pixels_from_data( ProcessList *process_list, +__inline gint processlist_get_pixels_from_data( ProcessList *process_list, ProcessInfo *process_info, HashedProcessData *hashed_process_data, guint *y, @@ -640,11 +632,11 @@ gint processlist_get_pixels_from_data( ProcessList *process_list, gint *path_indices; GtkTreePath *tree_path; - tree_path = gtk_tree_row_reference_get_path( - hashed_process_data->row_ref); + tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(process_list->list_store), + &hashed_process_data->y_iter); path_indices = gtk_tree_path_get_indices (tree_path); - *height = get_cell_height( + *height = get_cell_height(process_list, GTK_TREE_VIEW(process_list->process_list_widget)); *y = *height * path_indices[0]; gtk_tree_path_free(tree_path); @@ -653,9 +645,8 @@ gint processlist_get_pixels_from_data( ProcessList *process_list, } -static guint get_cpu_number_from_name(GQuark name) +static __inline guint get_cpu_number_from_name(GQuark name) { - /* remember / */ const gchar *string; char *begin; guint cpu;