X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Fcontrolflow%2Fprocesslist.c;h=7825860a24732bac9293a3eb73b88182d2ab358e;hb=e92eabafdcce0d00c518e7ef8f83ddddbe5a6086;hp=4145f745ddbdaeeccee2447f69b1b2b096e30452;hpb=d0cd7f0949c2fd90d5a39361b192c9b2d96bf5d4;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 4145f745..7825860a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -22,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 * *****************************************************************************/ @@ -31,6 +35,7 @@ enum { PROCESS_COLUMN, PID_COLUMN, + PPID_COLUMN, BIRTH_S_COLUMN, BIRTH_NS_COLUMN, TRACE_COLUMN, @@ -226,6 +231,7 @@ ProcessList *processlist_construct(void) process_list->list_store = gtk_list_store_new ( N_COLUMNS, G_TYPE_STRING, G_TYPE_UINT, + G_TYPE_UINT, G_TYPE_ULONG, G_TYPE_ULONG, G_TYPE_ULONG); @@ -234,7 +240,6 @@ ProcessList *processlist_construct(void) 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( @@ -271,7 +276,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", @@ -280,6 +287,13 @@ 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 ( "PPID", + renderer, + "text", + PPID_COLUMN, + NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (process_list->process_list_widget), column); column = gtk_tree_view_column_new_with_attributes ( "Birth sec", renderer, @@ -318,14 +332,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; @@ -359,9 +408,10 @@ void destroy_hash_data(gpointer data) int processlist_add( ProcessList *process_list, guint pid, + guint ppid, LttTime *birth, guint trace_num, - gchar *name, + const gchar *name, guint *height, HashedProcessData **pm_hashed_process_data) { @@ -371,9 +421,19 @@ int processlist_add( ProcessList *process_list, *pm_hashed_process_data = hashed_process_data; Process_Info->pid = pid; + Process_Info->ppid = ppid; 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; @@ -418,7 +478,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 ( @@ -428,6 +489,7 @@ int processlist_add( ProcessList *process_list, gtk_list_store_set ( process_list->list_store, &iter, PROCESS_COLUMN, name, PID_COLUMN, pid, + PPID_COLUMN, ppid, BIRTH_S_COLUMN, birth->tv_sec, BIRTH_NS_COLUMN, birth->tv_nsec, TRACE_COLUMN, trace_num, @@ -475,32 +537,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); @@ -548,6 +597,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; @@ -573,6 +624,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;