From 8a9490128c708275a242badad25527fba94f6a51 Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 17 Jan 2004 04:31:36 +0000 Subject: [PATCH] change authors to reflect reality, and retab so every tab is 2 spaces long git-svn-id: http://ltt.polymtl.ca/svn@394 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/modules/guiEvents.c | 1143 ++++++++++---------- 1 file changed, 568 insertions(+), 575 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/guiEvents.c b/ltt/branches/poly/lttv/modules/guiEvents.c index 490e9175..feeb029f 100644 --- a/ltt/branches/poly/lttv/modules/guiEvents.c +++ b/ltt/branches/poly/lttv/modules/guiEvents.c @@ -14,15 +14,8 @@ * creates ans register through API functions what is needed to interact * with the TraceSet window. * - * Coding standard : - * pm : parameter - * l : local - * g : global - * s : static - * h : hook - * - * Author : Karim Yaghmour - * Integrated to LTTng by Mathieu Desnoyers, June 2003 + * Authors : Mathieu Desnoyers and XangXiu Yang, June to December 2003 + * Inspired from original LTT, made by Karim Yaghmour */ #include @@ -113,7 +106,7 @@ typedef struct _EventViewerData { /* Vertical scrollbar and it's adjustment */ GtkWidget *vscroll_vc; GtkAdjustment *vadjust_c ; - + /* Selection handler */ GtkTreeSelection *select_c; @@ -135,9 +128,9 @@ gboolean traceset_changed(void * hook_data, void * call_data); void remove_item_from_queue(GQueue * q, gboolean fromHead); void remove_all_items_from_queue(GQueue * q); void add_context_hooks(EventViewerData * event_viewer_data, - LttvTracesetContext * tsc); + LttvTracesetContext * tsc); void remove_context_hooks(EventViewerData * event_viewer_data, - LttvTracesetContext * tsc); + LttvTracesetContext * tsc); //! Event Viewer's constructor hook GtkWidget *h_gui_events(MainWindow *parent_window, LttvTracesetSelector * s, char* key); @@ -163,14 +156,14 @@ static void tree_v_grab_focus(GtkWidget *widget, gpointer data); static void get_test_data(double time, guint list_height, - EventViewerData *event_viewer_data); + EventViewerData *event_viewer_data); void add_test_data(EventViewerData *event_viewer_data); static void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size); static void get_events(EventViewerData* event_viewer_data, LttTime start, - LttTime end, unsigned max_num_events, unsigned * real_num_events); + LttTime end, unsigned max_num_events, unsigned * real_num_events); static gboolean parse_event(void *hook_data, void *call_data); static LttvModule *main_win_module; @@ -189,7 +182,7 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { g_critical("Can't load Control Flow Viewer : missing mainwin\n"); return; } - + /* Register the toolbar insert button */ toolbar_item_reg(hGuiEventsInsert_xpm, "Insert Event Viewer", h_gui_events); @@ -221,7 +214,7 @@ G_MODULE_EXPORT void destroy() { /* Unregister the toolbar insert button */ toolbar_item_unreg(h_gui_events); - + /* Unregister the menu item insert entry */ menu_item_unreg(h_gui_events); } @@ -255,7 +248,7 @@ h_gui_events(MainWindow * parent_window, LttvTracesetSelector * s, char* key) if(event_viewer_data) return event_viewer_data->hbox_v; else return NULL; - + } /** @@ -291,7 +284,7 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) event_viewer_data->scroll_win = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show ( event_viewer_data->scroll_win); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(event_viewer_data->scroll_win), - GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); /* TEST DATA, TO BE READ FROM THE TRACE */ event_viewer_data->currently_selected_event = FALSE ; @@ -299,39 +292,39 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) /* Create a model for storing the data list */ event_viewer_data->store_m = gtk_list_store_new ( - N_COLUMNS, /* Total number of columns */ - G_TYPE_INT, /* CPUID */ - G_TYPE_STRING, /* Event */ - G_TYPE_UINT64, /* Time */ - G_TYPE_INT, /* PID */ - G_TYPE_INT, /* Entry length */ - G_TYPE_STRING); /* Event's description */ - + N_COLUMNS, /* Total number of columns */ + G_TYPE_INT, /* CPUID */ + G_TYPE_STRING, /* Event */ + G_TYPE_UINT64, /* Time */ + G_TYPE_INT, /* PID */ + G_TYPE_INT, /* Entry length */ + G_TYPE_STRING); /* Event's description */ + /* Create the viewer widget for the columned list */ event_viewer_data->tree_v = gtk_tree_view_new_with_model (GTK_TREE_MODEL (event_viewer_data->store_m)); - + g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "size-allocate", - G_CALLBACK (tree_v_size_allocate_cb), - event_viewer_data); + G_CALLBACK (tree_v_size_allocate_cb), + event_viewer_data); g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "size-request", - G_CALLBACK (tree_v_size_request_cb), - event_viewer_data); + G_CALLBACK (tree_v_size_request_cb), + event_viewer_data); g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "cursor-changed", - G_CALLBACK (tree_v_cursor_changed_cb), - event_viewer_data); - + G_CALLBACK (tree_v_cursor_changed_cb), + event_viewer_data); + g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "move-cursor", - G_CALLBACK (tree_v_move_cursor_cb), - event_viewer_data); + G_CALLBACK (tree_v_move_cursor_cb), + event_viewer_data); g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "grab-focus", - G_CALLBACK (tree_v_grab_focus), - event_viewer_data); - + G_CALLBACK (tree_v_grab_focus), + event_viewer_data); + // Use on each column! //gtk_tree_view_column_set_sizing(event_viewer_data->tree_v, GTK_TREE_VIEW_COLUMN_FIXED); - + /* The view now holds a reference. We can get rid of our own * reference */ g_object_unref (G_OBJECT (event_viewer_data->store_m)); @@ -342,54 +335,54 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("CPUID", - renderer, - "text", CPUID_COLUMN, - NULL); + renderer, + "text", CPUID_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 0.0); gtk_tree_view_column_set_fixed_width (column, 45); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Event", - renderer, - "text", EVENT_COLUMN, - NULL); + renderer, + "text", EVENT_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 0.0); gtk_tree_view_column_set_fixed_width (column, 120); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Time", - renderer, - "text", TIME_COLUMN, - NULL); + renderer, + "text", TIME_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_column_set_fixed_width (column, 120); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("PID", - renderer, - "text", PID_COLUMN, - NULL); + renderer, + "text", PID_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_column_set_fixed_width (column, 45); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Entry Length", - renderer, - "text", ENTRY_LEN_COLUMN, - NULL); + renderer, + "text", ENTRY_LEN_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_column_set_fixed_width (column, 60); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Event's Description", - renderer, - "text", EVENT_DESCR_COLUMN, - NULL); + renderer, + "text", EVENT_DESCR_COLUMN, + NULL); gtk_tree_view_column_set_alignment (column, 0.0); gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), column); @@ -398,9 +391,9 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) event_viewer_data->select_c = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_viewer_data->tree_v)); gtk_tree_selection_set_mode (event_viewer_data->select_c, GTK_SELECTION_SINGLE); g_signal_connect (G_OBJECT (event_viewer_data->select_c), "changed", - G_CALLBACK (tree_selection_changed_cb), - event_viewer_data); - + G_CALLBACK (tree_selection_changed_cb), + event_viewer_data); + gtk_container_add (GTK_CONTAINER (event_viewer_data->scroll_win), event_viewer_data->tree_v); event_viewer_data->hbox_v = gtk_hbox_new(0, 0); @@ -409,19 +402,19 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) /* Create vertical scrollbar and pack it */ event_viewer_data->vscroll_vc = gtk_vscrollbar_new(NULL); gtk_range_set_update_policy (GTK_RANGE(event_viewer_data->vscroll_vc), - GTK_UPDATE_CONTINUOUS); - // Changed by MD : more user friendly :) - //GTK_UPDATE_DISCONTINUOUS); + GTK_UPDATE_CONTINUOUS); + // Changed by MD : more user friendly :) + //GTK_UPDATE_DISCONTINUOUS); gtk_box_pack_start(GTK_BOX(event_viewer_data->hbox_v), event_viewer_data->vscroll_vc, FALSE, TRUE, 0); /* Get the vertical scrollbar's adjustment */ event_viewer_data->vadjust_c = gtk_range_get_adjustment(GTK_RANGE(event_viewer_data->vscroll_vc)); event_viewer_data->vtree_adjust_c = gtk_tree_view_get_vadjustment( - GTK_TREE_VIEW (event_viewer_data->tree_v)); + GTK_TREE_VIEW (event_viewer_data->tree_v)); g_signal_connect (G_OBJECT (event_viewer_data->vadjust_c), "value-changed", - G_CALLBACK (v_scroll_cb), - event_viewer_data); + G_CALLBACK (v_scroll_cb), + event_viewer_data); /* Set the upper bound to the last event number */ event_viewer_data->previous_value = 0; event_viewer_data->vadjust_c->lower = 0.0; @@ -463,26 +456,26 @@ gui_events(MainWindow *parent_window, LttvTracesetSelector * s,char* key ) event_viewer_data->current_time_updated = FALSE; event_viewer_data->size = RESERVE_SMALL_SIZE; g_object_set_data( - G_OBJECT(event_viewer_data->hbox_v), - MAX_NUMBER_EVENT, - &event_viewer_data->size); + G_OBJECT(event_viewer_data->hbox_v), + MAX_NUMBER_EVENT, + &event_viewer_data->size); g_object_set_data( - G_OBJECT(event_viewer_data->hbox_v), - TRACESET_TIME_SPAN, - &event_viewer_data->time_span); + G_OBJECT(event_viewer_data->hbox_v), + TRACESET_TIME_SPAN, + &event_viewer_data->time_span); event_viewer_data->filter_key = g_strdup(key); g_object_set_data( - G_OBJECT(event_viewer_data->hbox_v), - event_viewer_data->filter_key, - s); + G_OBJECT(event_viewer_data->hbox_v), + event_viewer_data->filter_key, + s); g_object_set_data_full( - G_OBJECT(event_viewer_data->hbox_v), - "event_viewer_data", - event_viewer_data, - (GDestroyNotify)gui_events_free); + G_OBJECT(event_viewer_data->hbox_v), + "event_viewer_data", + event_viewer_data, + (GDestroyNotify)gui_events_free); return event_viewer_data; } @@ -494,12 +487,12 @@ void tree_v_set_cursor(EventViewerData *event_viewer_data) if(event_viewer_data->selected_event && event_viewer_data->first_event != -1) { // gtk_adjustment_set_value(event_viewer_data->vadjust_c, - // event_viewer_data->currently_selected_event); + // event_viewer_data->currently_selected_event); path = gtk_tree_path_new_from_indices( - event_viewer_data->currently_selected_event- - event_viewer_data->first_event, - -1); + event_viewer_data->currently_selected_event- + event_viewer_data->first_event, + -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); gtk_tree_path_free(path); @@ -510,7 +503,7 @@ void tree_v_get_cursor(EventViewerData *event_viewer_data) { GtkTreePath *path; gint *indices; - + gtk_tree_view_get_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), &path, NULL); indices = gtk_tree_path_get_indices(path); @@ -518,7 +511,7 @@ void tree_v_get_cursor(EventViewerData *event_viewer_data) { event_viewer_data->selected_event = TRUE; event_viewer_data->currently_selected_event = - event_viewer_data->first_event + indices[0]; + event_viewer_data->first_event + indices[0]; } else { event_viewer_data->selected_event = FALSE; @@ -554,37 +547,37 @@ void tree_v_move_cursor_cb (GtkWidget *widget, GtkMovementStep arg1, gint arg2, { /* Move one line */ if(arg2 == 1) - { - /* move one line down */ - if(indices[0] == event_viewer_data->num_visible_events - 1) - { - if(value + event_viewer_data->num_visible_events <= - event_viewer_data->number_of_events -1) - { - event_viewer_data->currently_selected_event += 1; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value+1); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - } - } - } else { - /* Move one line up */ - if(indices[0] == 0) - { - if(value - 1 >= 0 ) - { - event_viewer_data->currently_selected_event -= 1; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value-1); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(0, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - } - - } - } + { + /* move one line down */ + if(indices[0] == event_viewer_data->num_visible_events - 1) + { + if(value + event_viewer_data->num_visible_events <= + event_viewer_data->number_of_events -1) + { + event_viewer_data->currently_selected_event += 1; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value+1); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + } + } + } else { + /* Move one line up */ + if(indices[0] == 0) + { + if(value - 1 >= 0 ) + { + event_viewer_data->currently_selected_event -= 1; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value-1); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(0, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + } + + } + } } @@ -592,53 +585,53 @@ void tree_v_move_cursor_cb (GtkWidget *widget, GtkMovementStep arg1, gint arg2, { /* Move one page */ if(arg2 == 1) - { - if(event_viewer_data->num_visible_events == 1) - value += 1 ; - /* move one page down */ - if(value + event_viewer_data->num_visible_events-1 <= - event_viewer_data->number_of_events ) - { - event_viewer_data->currently_selected_event += event_viewer_data->num_visible_events-1; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, - // value+(event_viewer_data->num_visible_events-1)); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(0, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - } - } else { - /* Move one page up */ - if(event_viewer_data->num_visible_events == 1) - value -= 1 ; - - if(indices[0] < event_viewer_data->num_visible_events - 2 ) - { - if(value - (event_viewer_data->num_visible_events-1) >= 0) - { - event_viewer_data->currently_selected_event -= event_viewer_data->num_visible_events-1; - - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, - // value-(event_viewer_data->num_visible_events-1)); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(0, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - - } else { - /* Go to first Event */ - event_viewer_data->currently_selected_event == 0 ; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, - // 0); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(0, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - - } - } - - } + { + if(event_viewer_data->num_visible_events == 1) + value += 1 ; + /* move one page down */ + if(value + event_viewer_data->num_visible_events-1 <= + event_viewer_data->number_of_events ) + { + event_viewer_data->currently_selected_event += event_viewer_data->num_visible_events-1; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, + // value+(event_viewer_data->num_visible_events-1)); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(0, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + } + } else { + /* Move one page up */ + if(event_viewer_data->num_visible_events == 1) + value -= 1 ; + + if(indices[0] < event_viewer_data->num_visible_events - 2 ) + { + if(value - (event_viewer_data->num_visible_events-1) >= 0) + { + event_viewer_data->currently_selected_event -= event_viewer_data->num_visible_events-1; + + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, + // value-(event_viewer_data->num_visible_events-1)); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(0, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + + } else { + /* Go to first Event */ + event_viewer_data->currently_selected_event == 0 ; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, + // 0); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(0, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + + } + } + + } } @@ -646,25 +639,25 @@ void tree_v_move_cursor_cb (GtkWidget *widget, GtkMovementStep arg1, gint arg2, { /* Move to the ends of the buffer */ if(arg2 == 1) - { - /* move end of buffer */ - event_viewer_data->currently_selected_event = event_viewer_data->number_of_events-1 ; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, - // event_viewer_data->number_of_events - - // event_viewer_data->num_visible_events); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - } else { - /* Move beginning of buffer */ - event_viewer_data->currently_selected_event = 0 ; - // gtk_adjustment_set_value(event_viewer_data->vadjust_c, 0); - //gtk_tree_path_free(path); - //path = gtk_tree_path_new_from_indices(0, -1); - //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); - g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); - } + { + /* move end of buffer */ + event_viewer_data->currently_selected_event = event_viewer_data->number_of_events-1 ; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, + // event_viewer_data->number_of_events - + // event_viewer_data->num_visible_events); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + } else { + /* Move beginning of buffer */ + event_viewer_data->currently_selected_event = 0 ; + // gtk_adjustment_set_value(event_viewer_data->vadjust_c, 0); + //gtk_tree_path_free(path); + //path = gtk_tree_path_new_from_indices(0, -1); + //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE); + g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor"); + } } @@ -680,7 +673,7 @@ void tree_v_cursor_changed_cb (GtkWidget *widget, gpointer data) GtkTreeIter iter; GtkTreeModel* model = GTK_TREE_MODEL(event_viewer_data->store_m); GtkTreePath *path; - + /* On cursor change, modify the currently selected event by calling * the right API function */ tree_v_get_cursor(event_viewer_data); @@ -709,7 +702,7 @@ void v_scroll_cb (GtkAdjustment *adjustment, gpointer data) GtkTreePath *tree_path; get_test_data(adjustment->value, event_viewer_data->num_visible_events, - event_viewer_data); + event_viewer_data); if(event_viewer_data->currently_selected_event @@ -722,12 +715,12 @@ void v_scroll_cb (GtkAdjustment *adjustment, gpointer data) { tree_path = gtk_tree_path_new_from_indices( - event_viewer_data->currently_selected_event- - event_viewer_data->first_event, - -1); + event_viewer_data->currently_selected_event- + event_viewer_data->first_event, + -1); // gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), tree_path, - // NULL, FALSE); + // NULL, FALSE); gtk_tree_path_free(tree_path); } @@ -754,7 +747,7 @@ void tree_v_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer gdouble exact_num_visible; exact_num_visible = ( alloc->height - - TREE_VIEW_HEADER_HEIGHT (GTK_TREE_VIEW(event_viewer_data->tree_v)) ) + TREE_VIEW_HEADER_HEIGHT (GTK_TREE_VIEW(event_viewer_data->tree_v)) ) / (double)cell_height ; event_viewer_data->num_visible_events = ceil(exact_num_visible) ; @@ -769,8 +762,8 @@ void tree_v_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer if(event_viewer_data->num_visible_events != last_num_visible_events) { get_test_data(event_viewer_data->vadjust_c->value, - event_viewer_data->num_visible_events, - event_viewer_data); + event_viewer_data->num_visible_events, + event_viewer_data); } @@ -781,11 +774,11 @@ void tree_v_size_request_cb (GtkWidget *widget, GtkRequisition *requisition, gpo gint h; EventViewerData *event_viewer_data = (EventViewerData*)data; gint cell_height = get_cell_height(GTK_TREE_VIEW(event_viewer_data->tree_v)); - + h = cell_height + TREE_VIEW_HEADER_HEIGHT (GTK_TREE_VIEW(event_viewer_data->tree_v)); requisition->height = h; - + } gboolean show_event_detail(void * hook_data, void * call_data) @@ -796,11 +789,11 @@ gboolean show_event_detail(void * hook_data, void * call_data) if(event_viewer_data->shown == FALSE){ event_viewer_data->shown = TRUE; update_raw_data_array(event_viewer_data, - event_viewer_data->raw_trace_data_queue_tmp->length); + event_viewer_data->raw_trace_data_queue_tmp->length); get_test_data(event_viewer_data->vadjust_c->value, - event_viewer_data->num_visible_events, - event_viewer_data); + event_viewer_data->num_visible_events, + event_viewer_data); remove_context_hooks(event_viewer_data,tsc); } @@ -827,18 +820,18 @@ void insert_data_into_model(EventViewerData *event_viewer_data, int start, int e real_data += raw_data->time.tv_nsec; gtk_list_store_append (event_viewer_data->store_m, &iter); gtk_list_store_set (event_viewer_data->store_m, &iter, - CPUID_COLUMN, raw_data->cpu_id, - EVENT_COLUMN, raw_data->event_name, - TIME_COLUMN, real_data, - PID_COLUMN, raw_data->pid, - ENTRY_LEN_COLUMN, raw_data->entry_length, - EVENT_DESCR_COLUMN, raw_data->event_description, - -1); + CPUID_COLUMN, raw_data->cpu_id, + EVENT_COLUMN, raw_data->event_name, + TIME_COLUMN, real_data, + PID_COLUMN, raw_data->pid, + ENTRY_LEN_COLUMN, raw_data->entry_length, + EVENT_DESCR_COLUMN, raw_data->event_description, + -1); } } void get_test_data(double time_value, guint list_height, - EventViewerData *event_viewer_data) + EventViewerData *event_viewer_data) { GtkTreeIter iter; int i; @@ -870,9 +863,9 @@ void get_test_data(double time_value, guint list_height, } - // if(event_number > event_viewer_data->last_event || - // event_number + list_height-1 < event_viewer_data->first_event || - // event_viewer_data->first_event == -1) + // if(event_number > event_viewer_data->last_event || + // event_number + list_height-1 < event_viewer_data->first_event || + // event_viewer_data->first_event == -1) { /* no event can be reused, clear and start from nothing */ if(value == -1.0) direction = SCROLL_STEP_DOWN; @@ -885,170 +878,170 @@ void get_test_data(double time_value, guint list_height, switch(direction){ case SCROLL_STEP_UP: case SCROLL_PAGE_UP: - if(direction == SCROLL_PAGE_UP){ - backward = list_height>event_viewer_data->start_event_index ? TRUE : FALSE; - }else{ - backward = event_viewer_data->start_event_index == 0 ? TRUE : FALSE; - } - if(backward){ - event_viewer_data->append = FALSE; - do{ - if(direction == SCROLL_PAGE_UP){ - minNum = list_height - event_viewer_data->start_event_index ; - }else{ - minNum = 1; - } - - first = event_viewer_data->raw_trace_data_queue->head; - if(!first)break; - raw_data = (RawTraceData*)g_list_nth_data(first,0); - end = raw_data->time; - end.tv_nsec--; - ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf); - if(size !=0){ - if(event_num > minNum){ - backward_num = event_num > RESERVE_SMALL_SIZE - ? event_num - RESERVE_SMALL_SIZE : 1; - ltt_event_position_set(raw_data->ep, block_num, backward_num); - ltt_tracefile_seek_position(tf, raw_data->ep); - ev = ltt_tracefile_read(tf); - start = ltt_event_time(ev); - maxNum = RESERVE_SMALL_SIZE_CUBE; - }else{ - if(block_num > 1){ - ltt_event_position_set(raw_data->ep, block_num-1, 1); - ltt_tracefile_seek_position(tf, raw_data->ep); - ev = ltt_tracefile_read(tf); - start = ltt_event_time(ev); - }else{ - start.tv_sec = 0; - start.tv_nsec = 0; - } - maxNum = RESERVE_SMALL_SIZE_CUBE; - } - }else{ - if(block_num > count){ - ltt_event_position_set(raw_data->ep, block_num-count, 1); - ltt_tracefile_seek_position(tf, raw_data->ep); - ev = ltt_tracefile_read(tf); - start = ltt_event_time(ev); - }else{ - start.tv_sec = 0; - start.tv_nsec = 0; - } - maxNum = RESERVE_SMALL_SIZE_CUBE; - } - - event_viewer_data->current_event_index = event_viewer_data->start_event_index; - get_events(event_viewer_data, start, end, maxNum, &size); - event_viewer_data->start_event_index = event_viewer_data->current_event_index; - - if(size < minNum && (start.tv_sec !=0 || start.tv_nsec !=0)) - need_backward_again = TRUE; - else need_backward_again = FALSE; - if(size == 0){ - count++; - }else{ - count = 0; - } - }while(need_backward_again); - } - if(direction == SCROLL_STEP_UP) - event_number = event_viewer_data->start_event_index - 1; - else - event_number = event_viewer_data->start_event_index - list_height; - break; + if(direction == SCROLL_PAGE_UP){ + backward = list_height>event_viewer_data->start_event_index ? TRUE : FALSE; + }else{ + backward = event_viewer_data->start_event_index == 0 ? TRUE : FALSE; + } + if(backward){ + event_viewer_data->append = FALSE; + do{ + if(direction == SCROLL_PAGE_UP){ + minNum = list_height - event_viewer_data->start_event_index ; + }else{ + minNum = 1; + } + + first = event_viewer_data->raw_trace_data_queue->head; + if(!first)break; + raw_data = (RawTraceData*)g_list_nth_data(first,0); + end = raw_data->time; + end.tv_nsec--; + ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf); + if(size !=0){ + if(event_num > minNum){ + backward_num = event_num > RESERVE_SMALL_SIZE + ? event_num - RESERVE_SMALL_SIZE : 1; + ltt_event_position_set(raw_data->ep, block_num, backward_num); + ltt_tracefile_seek_position(tf, raw_data->ep); + ev = ltt_tracefile_read(tf); + start = ltt_event_time(ev); + maxNum = RESERVE_SMALL_SIZE_CUBE; + }else{ + if(block_num > 1){ + ltt_event_position_set(raw_data->ep, block_num-1, 1); + ltt_tracefile_seek_position(tf, raw_data->ep); + ev = ltt_tracefile_read(tf); + start = ltt_event_time(ev); + }else{ + start.tv_sec = 0; + start.tv_nsec = 0; + } + maxNum = RESERVE_SMALL_SIZE_CUBE; + } + }else{ + if(block_num > count){ + ltt_event_position_set(raw_data->ep, block_num-count, 1); + ltt_tracefile_seek_position(tf, raw_data->ep); + ev = ltt_tracefile_read(tf); + start = ltt_event_time(ev); + }else{ + start.tv_sec = 0; + start.tv_nsec = 0; + } + maxNum = RESERVE_SMALL_SIZE_CUBE; + } + + event_viewer_data->current_event_index = event_viewer_data->start_event_index; + get_events(event_viewer_data, start, end, maxNum, &size); + event_viewer_data->start_event_index = event_viewer_data->current_event_index; + + if(size < minNum && (start.tv_sec !=0 || start.tv_nsec !=0)) + need_backward_again = TRUE; + else need_backward_again = FALSE; + if(size == 0){ + count++; + }else{ + count = 0; + } + }while(need_backward_again); + } + if(direction == SCROLL_STEP_UP) + event_number = event_viewer_data->start_event_index - 1; + else + event_number = event_viewer_data->start_event_index - list_height; + break; case SCROLL_STEP_DOWN: - if(event_viewer_data->end_event_index == event_viewer_data->number_of_events - 1){ - event_viewer_data->append = TRUE; - first = event_viewer_data->raw_trace_data_queue->head; - if(!first)break; - raw_data = (RawTraceData*)g_list_nth_data(first,event_viewer_data->number_of_events - 1); - start = raw_data->time; - start.tv_nsec++; - end.tv_sec = G_MAXULONG; - end.tv_nsec = G_MAXULONG; - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE, &size); - if(size == 0){ - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); - if(size == 0) - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); - } - if(size==0) event_number = event_viewer_data->start_event_index; - else event_number = event_viewer_data->number_of_events - size - list_height + 1; - }else event_number = event_viewer_data->start_event_index + 1; - break; + if(event_viewer_data->end_event_index == event_viewer_data->number_of_events - 1){ + event_viewer_data->append = TRUE; + first = event_viewer_data->raw_trace_data_queue->head; + if(!first)break; + raw_data = (RawTraceData*)g_list_nth_data(first,event_viewer_data->number_of_events - 1); + start = raw_data->time; + start.tv_nsec++; + end.tv_sec = G_MAXULONG; + end.tv_nsec = G_MAXULONG; + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE, &size); + if(size == 0){ + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); + if(size == 0) + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); + } + if(size==0) event_number = event_viewer_data->start_event_index; + else event_number = event_viewer_data->number_of_events - size - list_height + 1; + }else event_number = event_viewer_data->start_event_index + 1; + break; case SCROLL_PAGE_DOWN: - i = event_viewer_data->number_of_events - 1 - list_height; - if((gint)(event_viewer_data->end_event_index) >= i){ - int remain_events = event_viewer_data->number_of_events - 1 - - event_viewer_data->end_event_index; - event_viewer_data->append = TRUE; - first = event_viewer_data->raw_trace_data_queue->head; - if(!first)break; - raw_data = (RawTraceData*)g_list_nth_data(first,event_viewer_data->number_of_events - 1); - start = raw_data->time; - start.tv_nsec++; - end.tv_sec = G_MAXULONG; - end.tv_nsec = G_MAXULONG; - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size); - if(size == 0){ - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); - if(size == 0) - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); - } - remain_events += size; - if(list_height <= remain_events) - event_number = event_viewer_data->number_of_events - remain_events - 1; - else - event_number = event_viewer_data->number_of_events - 1 - list_height; - }else event_number = event_viewer_data->start_event_index + list_height - 1; - break; + i = event_viewer_data->number_of_events - 1 - list_height; + if((gint)(event_viewer_data->end_event_index) >= i){ + int remain_events = event_viewer_data->number_of_events - 1 + - event_viewer_data->end_event_index; + event_viewer_data->append = TRUE; + first = event_viewer_data->raw_trace_data_queue->head; + if(!first)break; + raw_data = (RawTraceData*)g_list_nth_data(first,event_viewer_data->number_of_events - 1); + start = raw_data->time; + start.tv_nsec++; + end.tv_sec = G_MAXULONG; + end.tv_nsec = G_MAXULONG; + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size); + if(size == 0){ + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); + if(size == 0) + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); + } + remain_events += size; + if(list_height <= remain_events) + event_number = event_viewer_data->number_of_events - remain_events - 1; + else + event_number = event_viewer_data->number_of_events - 1 - list_height; + }else event_number = event_viewer_data->start_event_index + list_height - 1; + break; case SCROLL_JUMP: - event_viewer_data->append = TRUE; - remove_all_items_from_queue(event_viewer_data->raw_trace_data_queue); - end.tv_sec = G_MAXULONG; - end.tv_nsec = G_MAXULONG; - time = ltt_time_from_double(time_value / NANOSECONDS_PER_SECOND); - start = ltt_time_add(event_viewer_data->time_span.startTime, time); - event_viewer_data->previous_value = time_value; - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size); - if(size < list_height && size > 0){ - event_viewer_data->append = FALSE; - first = event_viewer_data->raw_trace_data_queue->head; - if(!first)break; - raw_data = (RawTraceData*)g_list_nth_data(first,0); - end = raw_data->time; - end.tv_nsec--; - ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf); - - if(event_num > list_height - size){ - backward_num = event_num > RESERVE_SMALL_SIZE - ? event_num - RESERVE_SMALL_SIZE : 1; - ltt_event_position_set(raw_data->ep, block_num, backward_num); - ltt_tracefile_seek_position(tf, raw_data->ep); - ev = ltt_tracefile_read(tf); - start = ltt_event_time(ev); - maxNum = RESERVE_SMALL_SIZE_CUBE; - event_viewer_data->current_event_index = 0; - get_events(event_viewer_data, start, end, maxNum, &size); - event_viewer_data->start_event_index = event_viewer_data->current_event_index; - } - event_number = event_viewer_data->raw_trace_data_queue->length - list_height; - }else if(size == 0){ - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); - if(size == 0) - get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); - event_number = 0; - }else{ - event_number = 0; - } - break; + event_viewer_data->append = TRUE; + remove_all_items_from_queue(event_viewer_data->raw_trace_data_queue); + end.tv_sec = G_MAXULONG; + end.tv_nsec = G_MAXULONG; + time = ltt_time_from_double(time_value / NANOSECONDS_PER_SECOND); + start = ltt_time_add(event_viewer_data->time_span.startTime, time); + event_viewer_data->previous_value = time_value; + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size); + if(size < list_height && size > 0){ + event_viewer_data->append = FALSE; + first = event_viewer_data->raw_trace_data_queue->head; + if(!first)break; + raw_data = (RawTraceData*)g_list_nth_data(first,0); + end = raw_data->time; + end.tv_nsec--; + ltt_event_position_get(raw_data->ep, &block_num, &event_num, &tf); + + if(event_num > list_height - size){ + backward_num = event_num > RESERVE_SMALL_SIZE + ? event_num - RESERVE_SMALL_SIZE : 1; + ltt_event_position_set(raw_data->ep, block_num, backward_num); + ltt_tracefile_seek_position(tf, raw_data->ep); + ev = ltt_tracefile_read(tf); + start = ltt_event_time(ev); + maxNum = RESERVE_SMALL_SIZE_CUBE; + event_viewer_data->current_event_index = 0; + get_events(event_viewer_data, start, end, maxNum, &size); + event_viewer_data->start_event_index = event_viewer_data->current_event_index; + } + event_number = event_viewer_data->raw_trace_data_queue->length - list_height; + }else if(size == 0){ + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_SQUARE,&size); + if(size == 0) + get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE_CUBE,&size); + event_number = 0; + }else{ + event_number = 0; + } + break; case SCROLL_NONE: - event_number = event_viewer_data->current_event_index; - break; + event_number = event_viewer_data->current_event_index; + break; default: - break; + break; } if(event_number < 0) event_number = 0; @@ -1057,12 +1050,12 @@ void get_test_data(double time_value, guint list_height, if(direction != SCROLL_NONE && direction != SCROLL_JUMP){ first = event_viewer_data->raw_trace_data_queue->head; if(first){ - raw_data = (RawTraceData*)g_list_nth_data(first,event_number); - if(!raw_data) raw_data = (RawTraceData*)g_list_nth_data(first,0); - time = ltt_time_sub(raw_data->time, event_viewer_data->time_span.startTime); - event_viewer_data->vadjust_c->value = ltt_time_to_double(time) * NANOSECONDS_PER_SECOND; - g_signal_stop_emission_by_name(G_OBJECT(event_viewer_data->vadjust_c), "value-changed"); - event_viewer_data->previous_value = event_viewer_data->vadjust_c->value; + raw_data = (RawTraceData*)g_list_nth_data(first,event_number); + if(!raw_data) raw_data = (RawTraceData*)g_list_nth_data(first,0); + time = ltt_time_sub(raw_data->time, event_viewer_data->time_span.startTime); + event_viewer_data->vadjust_c->value = ltt_time_to_double(time) * NANOSECONDS_PER_SECOND; + g_signal_stop_emission_by_name(G_OBJECT(event_viewer_data->vadjust_c), "value-changed"); + event_viewer_data->previous_value = event_viewer_data->vadjust_c->value; } } @@ -1085,59 +1078,59 @@ void get_test_data(double time_value, guint list_height, insert_data_into_model(event_viewer_data,event_number, event_number+list_height); } #ifdef DEBUG //do not use this, it's slower and broken - // } else { + // } else { /* Some events will be reused */ if(event_number < event_viewer_data->first_event) { /* scrolling up, prepend events */ tree_path = gtk_tree_path_new_from_indices - (event_number+list_height-1 - - event_viewer_data->first_event + 1, - -1); + (event_number+list_height-1 - + event_viewer_data->first_event + 1, + -1); for(i=0; ilast_event-(event_number+list_height-1); - i++) - { - /* Remove the last events from the list */ - if(gtk_tree_model_get_iter(model, &iter, tree_path)) - gtk_list_store_remove(event_viewer_data->store_m, &iter); - } + i++) + { + /* Remove the last events from the list */ + if(gtk_tree_model_get_iter(model, &iter, tree_path)) + gtk_list_store_remove(event_viewer_data->store_m, &iter); + } for(i=event_viewer_data->first_event-1; i>=event_number; i--) - { - if(i>=event_viewer_data->number_of_events) break; - /* Prepend new events */ - gtk_list_store_prepend (event_viewer_data->store_m, &iter); - gtk_list_store_set (event_viewer_data->store_m, &iter, - CPUID_COLUMN, 0, - EVENT_COLUMN, "event irq", - TIME_COLUMN, i, - PID_COLUMN, 100, - ENTRY_LEN_COLUMN, 17, - EVENT_DESCR_COLUMN, "Detailed information", - -1); - } + { + if(i>=event_viewer_data->number_of_events) break; + /* Prepend new events */ + gtk_list_store_prepend (event_viewer_data->store_m, &iter); + gtk_list_store_set (event_viewer_data->store_m, &iter, + CPUID_COLUMN, 0, + EVENT_COLUMN, "event irq", + TIME_COLUMN, i, + PID_COLUMN, 100, + ENTRY_LEN_COLUMN, 17, + EVENT_DESCR_COLUMN, "Detailed information", + -1); + } } else { /* Scrolling down, append events */ for(i=event_viewer_data->first_event; istore_m, &iter); - } + { + /* Remove these events from the list */ + gtk_tree_model_get_iter_first(model, &iter); + gtk_list_store_remove(event_viewer_data->store_m, &iter); + } for(i=event_viewer_data->last_event+1; i=event_viewer_data->number_of_events) break; - /* Append new events */ - gtk_list_store_append (event_viewer_data->store_m, &iter); - gtk_list_store_set (event_viewer_data->store_m, &iter, - CPUID_COLUMN, 0, - EVENT_COLUMN, "event irq", - TIME_COLUMN, i, - PID_COLUMN, 100, - ENTRY_LEN_COLUMN, 17, - EVENT_DESCR_COLUMN, "Detailed information", - -1); - } + { + if(i>=event_viewer_data->number_of_events) break; + /* Append new events */ + gtk_list_store_append (event_viewer_data->store_m, &iter); + gtk_list_store_set (event_viewer_data->store_m, &iter, + CPUID_COLUMN, 0, + EVENT_COLUMN, "event irq", + TIME_COLUMN, i, + PID_COLUMN, 100, + ENTRY_LEN_COLUMN, 17, + EVENT_DESCR_COLUMN, "Detailed information", + -1); + } } //} @@ -1150,7 +1143,7 @@ void get_test_data(double time_value, guint list_height, gdk_window_set_cursor(win, NULL); } - + void add_test_data(EventViewerData *event_viewer_data) { @@ -1162,17 +1155,17 @@ void add_test_data(EventViewerData *event_viewer_data) /* Add a new row to the model */ gtk_list_store_append (event_viewer_data->store_m, &iter); gtk_list_store_set (event_viewer_data->store_m, &iter, - CPUID_COLUMN, 0, - EVENT_COLUMN, "event irq", - TIME_COLUMN, i, - PID_COLUMN, 100, - ENTRY_LEN_COLUMN, 17, - EVENT_DESCR_COLUMN, "Detailed information", - -1); + CPUID_COLUMN, 0, + EVENT_COLUMN, "event irq", + TIME_COLUMN, i, + PID_COLUMN, 100, + ENTRY_LEN_COLUMN, 17, + EVENT_DESCR_COLUMN, "Detailed information", + -1); } } - + void gui_events_free(EventViewerData *event_viewer_data) { @@ -1251,7 +1244,7 @@ int event_selected_hook(void *hook_data, void *call_data) * (add/remove_context_hooks functions) should be put in common place */ void add_context_hooks(EventViewerData * event_viewer_data, - LttvTracesetContext * tsc) + LttvTracesetContext * tsc) { gint i, j, k, m,n, nbi, id; gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event; @@ -1267,7 +1260,7 @@ void add_context_hooks(EventViewerData * event_viewer_data, LttvEventtypeSelector * eventtype; ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v), - event_viewer_data->filter_key); + event_viewer_data->filter_key); //if there are hooks for traceset, add them here @@ -1290,31 +1283,31 @@ void add_context_hooks(EventViewerData * event_viewer_data, if(!selected) continue; if(j < nb_control) - tfc = tc->control_tracefiles[j]; + tfc = tc->control_tracefiles[j]; else - tfc = tc->per_cpu_tracefiles[j - nb_control]; + tfc = tc->per_cpu_tracefiles[j - nb_control]; //if there are hooks for tracefile, add them here // lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL, - // event_viewer_data->before_event_hooks,NULL); + // event_viewer_data->before_event_hooks,NULL); nb_facility = ltt_trace_facility_number(trace); n = 0; for(k=0;kbefore_event_hooks, - NULL); - } - n++; - } + fac = ltt_trace_facility_get(trace,k); + nb_event = (int) ltt_facility_eventtype_number(fac); + for(m=0;mbefore_event_hooks, + NULL); + } + n++; + } } } @@ -1322,12 +1315,12 @@ void add_context_hooks(EventViewerData * event_viewer_data, //add hooks for process_traceset // context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL, - // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); + // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); } void remove_context_hooks(EventViewerData * event_viewer_data, - LttvTracesetContext * tsc) + LttvTracesetContext * tsc) { gint i, j, k, m, nbi, n, id; gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event; @@ -1343,7 +1336,7 @@ void remove_context_hooks(EventViewerData * event_viewer_data, LttvEventtypeSelector * eventtype; ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v), - event_viewer_data->filter_key); + event_viewer_data->filter_key); //if there are hooks for traceset, remove them here @@ -1366,35 +1359,35 @@ void remove_context_hooks(EventViewerData * event_viewer_data, if(!selected) continue; if(j < nb_control) - tfc = tc->control_tracefiles[j]; + tfc = tc->control_tracefiles[j]; else - tfc = tc->per_cpu_tracefiles[j - nb_control]; + tfc = tc->per_cpu_tracefiles[j - nb_control]; //if there are hooks for tracefile, remove them here // lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL, - // event_viewer_data->before_event_hooks,NULL); + // event_viewer_data->before_event_hooks,NULL); nb_facility = ltt_trace_facility_number(trace); n = 0; for(k=0;kmw, NULL, NULL, NULL, NULL, NULL, NULL, - // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); + // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); } @@ -1439,13 +1432,13 @@ gboolean update_current_time(void * hook_data, void * call_data) while(1){ gtk_tree_model_get(model, &iter, TIME_COLUMN, &time, -1); if(time < nsec){ - if(!gtk_tree_model_iter_next(model, &iter)){ - count = -1; - break; - } - count++; + if(!gtk_tree_model_iter_next(model, &iter)){ + count = -1; + break; + } + count++; }else{ - break; + break; } } // event_selected_hook(event_viewer_data, &count); @@ -1463,20 +1456,20 @@ gboolean update_current_time(void * hook_data, void * call_data) if(ltt_time_compare(data->time, event_viewer_data->current_time)<=0 && ltt_time_compare(data1->time, event_viewer_data->current_time)>=0){ for(i=0;iraw_trace_data_queue->length;i++){ - data = (RawTraceData*)g_list_nth_data(list,i); - if(ltt_time_compare(data->time, event_viewer_data->current_time) < 0){ - count++; - continue; - } - break; + data = (RawTraceData*)g_list_nth_data(list,i); + if(ltt_time_compare(data->time, event_viewer_data->current_time) < 0){ + count++; + continue; + } + break; } if(event_viewer_data->raw_trace_data_queue->length-count < event_viewer_data->num_visible_events){ - j = event_viewer_data->raw_trace_data_queue->length - event_viewer_data->num_visible_events; - count -= j; - data = (RawTraceData*)g_list_nth_data(list,j); + j = event_viewer_data->raw_trace_data_queue->length - event_viewer_data->num_visible_events; + count -= j; + data = (RawTraceData*)g_list_nth_data(list,j); }else{ - j = count; - count = 0; + j = count; + count = 0; } t = ltt_time_sub(data->time, event_viewer_data->time_span.startTime); event_viewer_data->vadjust_c->value = ltt_time_to_double(t) * NANOSECONDS_PER_SECOND; @@ -1538,7 +1531,7 @@ void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size) //if the queue is full, remove some data, keep the size of the queue constant while(event_viewer_data->raw_trace_data_queue->length + size > RESERVE_BIG_SIZE){ remove_item_from_queue(event_viewer_data->raw_trace_data_queue, - event_viewer_data->append); + event_viewer_data->append); } //update pid if it is not known @@ -1546,89 +1539,89 @@ void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size) list = event_viewer_data->raw_trace_data_queue->head; tmpList = event_viewer_data->raw_trace_data_queue_tmp->head; if(event_viewer_data->append){ - for(i= event_viewer_data->raw_trace_data_queue->length-1;i>=0;i--){ - data = (RawTraceData*)g_list_nth_data(list,i); - len = data->pid==0 ? -2 : data->pid; - if(data->cpu_id+1 > pid_array->len){ - pid_array = g_array_set_size(pid_array,data->cpu_id+1); - pid_array = g_array_insert_val(pid_array,data->cpu_id,len); - pid_array = g_array_remove_index(pid_array,data->cpu_id+1); - }else if(data->cpu_id+1 < pid_array->len){ - pid = g_array_index(pid_array,int,data->cpu_id); - if(pid == 0){ - pid_array = g_array_insert_val(pid_array,data->cpu_id,len); - pid_array = g_array_remove_index(pid_array,data->cpu_id+1); - } - } - } - - for(i=0;iraw_trace_data_queue_tmp->length;i++){ - data = (RawTraceData*)g_list_nth_data(tmpList,i); - len = data->pid==0 ? -2 : data->pid; - if(data->cpu_id+1 > tmp_pid_array->len){ - tmp_pid_array = g_array_set_size(tmp_pid_array,data->cpu_id+1); - tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); - tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); - }else if(data->cpu_id+1 < tmp_pid_array->len){ - pid = g_array_index(tmp_pid_array,int,data->cpu_id); - if(pid == 0){ - tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); - tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); - } - } - } + for(i= event_viewer_data->raw_trace_data_queue->length-1;i>=0;i--){ + data = (RawTraceData*)g_list_nth_data(list,i); + len = data->pid==0 ? -2 : data->pid; + if(data->cpu_id+1 > pid_array->len){ + pid_array = g_array_set_size(pid_array,data->cpu_id+1); + pid_array = g_array_insert_val(pid_array,data->cpu_id,len); + pid_array = g_array_remove_index(pid_array,data->cpu_id+1); + }else if(data->cpu_id+1 < pid_array->len){ + pid = g_array_index(pid_array,int,data->cpu_id); + if(pid == 0){ + pid_array = g_array_insert_val(pid_array,data->cpu_id,len); + pid_array = g_array_remove_index(pid_array,data->cpu_id+1); + } + } + } + + for(i=0;iraw_trace_data_queue_tmp->length;i++){ + data = (RawTraceData*)g_list_nth_data(tmpList,i); + len = data->pid==0 ? -2 : data->pid; + if(data->cpu_id+1 > tmp_pid_array->len){ + tmp_pid_array = g_array_set_size(tmp_pid_array,data->cpu_id+1); + tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); + tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); + }else if(data->cpu_id+1 < tmp_pid_array->len){ + pid = g_array_index(tmp_pid_array,int,data->cpu_id); + if(pid == 0){ + tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); + tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); + } + } + } }else{ - for(i=0;iraw_trace_data_queue->length;i++){ - data = (RawTraceData*)g_list_nth_data(list,i); - len = data->pid==0 ? -2 : data->pid; - if(data->cpu_id+1 > pid_array->len){ - pid_array = g_array_set_size(pid_array,data->cpu_id+1); - pid_array = g_array_insert_val(pid_array,data->cpu_id,len); - pid_array = g_array_remove_index(pid_array,data->cpu_id+1); - }else if(data->cpu_id+1 < pid_array->len){ - pid = g_array_index(pid_array,int,data->cpu_id); - if(pid == 0){ - pid_array = g_array_insert_val(pid_array,data->cpu_id,len); - pid_array = g_array_remove_index(pid_array,data->cpu_id+1); - } - } - } - - for(i=event_viewer_data->raw_trace_data_queue_tmp->length-1;i>=0;i--){ - data = (RawTraceData*)g_list_nth_data(tmpList,i); - len = data->pid==0 ? -2 : data->pid; - if(data->cpu_id+1 > tmp_pid_array->len){ - tmp_pid_array = g_array_set_size(tmp_pid_array,data->cpu_id+1); - tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); - tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); - }else if(data->cpu_id+1 < tmp_pid_array->len){ - pid = g_array_index(tmp_pid_array,int,data->cpu_id); - if(pid == 0){ - tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); - tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); - } - } - } + for(i=0;iraw_trace_data_queue->length;i++){ + data = (RawTraceData*)g_list_nth_data(list,i); + len = data->pid==0 ? -2 : data->pid; + if(data->cpu_id+1 > pid_array->len){ + pid_array = g_array_set_size(pid_array,data->cpu_id+1); + pid_array = g_array_insert_val(pid_array,data->cpu_id,len); + pid_array = g_array_remove_index(pid_array,data->cpu_id+1); + }else if(data->cpu_id+1 < pid_array->len){ + pid = g_array_index(pid_array,int,data->cpu_id); + if(pid == 0){ + pid_array = g_array_insert_val(pid_array,data->cpu_id,len); + pid_array = g_array_remove_index(pid_array,data->cpu_id+1); + } + } + } + + for(i=event_viewer_data->raw_trace_data_queue_tmp->length-1;i>=0;i--){ + data = (RawTraceData*)g_list_nth_data(tmpList,i); + len = data->pid==0 ? -2 : data->pid; + if(data->cpu_id+1 > tmp_pid_array->len){ + tmp_pid_array = g_array_set_size(tmp_pid_array,data->cpu_id+1); + tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); + tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); + }else if(data->cpu_id+1 < tmp_pid_array->len){ + pid = g_array_index(tmp_pid_array,int,data->cpu_id); + if(pid == 0){ + tmp_pid_array = g_array_insert_val(tmp_pid_array,data->cpu_id,len); + tmp_pid_array = g_array_remove_index(tmp_pid_array,data->cpu_id+1); + } + } + } } len = pid_array->len > tmp_pid_array->len ? tmp_pid_array->len : pid_array->len; for(j=0;jraw_trace_data_queue->length;i++){ - data = (RawTraceData*)g_list_nth_data(list,i); - if(data->pid == -1 && data->cpu_id == j) data->pid = tmpPid; - } - }else if(pid != -1 && tmpPid == -1){ - for(i=0;iraw_trace_data_queue_tmp->length;i++){ - data = (RawTraceData*)g_list_nth_data(tmpList,i); - if(data->pid == -1 && data->cpu_id == j) data->pid = pid; - } - } + pid = g_array_index(pid_array,int, j); + tmpPid = g_array_index(tmp_pid_array,int,j); + if(pid == -2)pid = 0; + if(tmpPid == -2) tmpPid = 0; + + if(pid == -1 && tmpPid != -1){ + for(i=0;iraw_trace_data_queue->length;i++){ + data = (RawTraceData*)g_list_nth_data(list,i); + if(data->pid == -1 && data->cpu_id == j) data->pid = tmpPid; + } + }else if(pid != -1 && tmpPid == -1){ + for(i=0;iraw_trace_data_queue_tmp->length;i++){ + data = (RawTraceData*)g_list_nth_data(tmpList,i); + if(data->pid == -1 && data->cpu_id == j) data->pid = pid; + } + } } } @@ -1640,35 +1633,35 @@ void update_raw_data_array(EventViewerData* event_viewer_data, unsigned size) + event_viewer_data->raw_trace_data_queue_tmp->length; if(event_viewer_data->append){ if(event_viewer_data->raw_trace_data_queue->length > 0) - event_viewer_data->current_event_index = event_viewer_data->raw_trace_data_queue->length - 1; + event_viewer_data->current_event_index = event_viewer_data->raw_trace_data_queue->length - 1; else event_viewer_data->current_event_index = 0; while((data = g_queue_pop_head(event_viewer_data->raw_trace_data_queue_tmp)) != NULL){ - g_queue_push_tail(event_viewer_data->raw_trace_data_queue, data); + g_queue_push_tail(event_viewer_data->raw_trace_data_queue, data); } }else{ event_viewer_data->current_event_index += event_viewer_data->raw_trace_data_queue_tmp->length; while((data = g_queue_pop_tail(event_viewer_data->raw_trace_data_queue_tmp)) != NULL){ - g_queue_push_head(event_viewer_data->raw_trace_data_queue, data); + g_queue_push_head(event_viewer_data->raw_trace_data_queue, data); } } } } void get_events(EventViewerData* event_viewer_data, LttTime start, - LttTime end,unsigned max_num_events, unsigned * real_num_events) + LttTime end,unsigned max_num_events, unsigned * real_num_events) { int size; LttvTracesetContext * tsc = get_traceset_context(event_viewer_data->mw); // context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL, - // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); + // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); add_context_hooks(event_viewer_data,tsc); process_traceset_api(event_viewer_data->mw, start, end, max_num_events); remove_context_hooks(event_viewer_data,tsc); // context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL, - // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); + // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL); size = event_viewer_data->raw_trace_data_queue_tmp->length; *real_num_events = size; @@ -1713,7 +1706,7 @@ static void get_event_detail(LttEvent *e, LttField *f, GString * s) element = ltt_field_element(f); for(i = 0 ; i < nb ; i++) { ltt_event_field_element_select(e,f,i); - get_event_detail(e, element, s); + get_event_detail(e, element, s); } g_string_append_printf(s, " }"); break; @@ -1723,8 +1716,8 @@ static void get_event_detail(LttEvent *e, LttField *f, GString * s) nb = ltt_type_member_number(type); for(i = 0 ; i < nb ; i++) { element = ltt_field_member(f,i); - ltt_type_member_type(type, i, &name); - g_string_append_printf(s, " %s = ", name); + ltt_type_member_type(type, i, &name); + g_string_append_printf(s, " %s = ", name); get_event_detail(e, element, s); } g_string_append_printf(s, " }"); @@ -1783,8 +1776,8 @@ gboolean parse_event(void *hook_data, void *call_data) for(i=event_viewer_data->raw_trace_data_queue_tmp->length-1;i>=0;i--){ data = (RawTraceData *)g_list_nth_data(list,i); if(data->cpu_id == tmp_raw_trace_data->cpu_id){ - prev_raw_trace_data = data; - break; + prev_raw_trace_data = data; + break; } } } @@ -1806,10 +1799,10 @@ gboolean parse_event(void *hook_data, void *call_data) if(prev_raw_trace_data && prev_raw_trace_data->pid == -1){ list = event_viewer_data->raw_trace_data_queue_tmp->head; for(i=0;iraw_trace_data_queue_tmp->length;i++){ - data = (RawTraceData *)g_list_nth_data(list,i); - if(data->cpu_id == tmp_raw_trace_data->cpu_id){ - data->pid = out; - } + data = (RawTraceData *)g_list_nth_data(list,i); + if(data->cpu_id == tmp_raw_trace_data->cpu_id){ + data->pid = out; + } } } } @@ -1821,10 +1814,10 @@ gboolean parse_event(void *hook_data, void *call_data) list = g_list_last(event_viewer_data->raw_trace_data_queue_tmp->head); data = (RawTraceData *)(list->data); if(data->time.tv_sec == time.tv_sec && - data->time.tv_nsec == time.tv_nsec){ - g_queue_push_tail(event_viewer_data->raw_trace_data_queue_tmp,tmp_raw_trace_data); + data->time.tv_nsec == time.tv_nsec){ + g_queue_push_tail(event_viewer_data->raw_trace_data_queue_tmp,tmp_raw_trace_data); }else{ - g_free(tmp_raw_trace_data); + g_free(tmp_raw_trace_data); } }else{ remove_item_from_queue(event_viewer_data->raw_trace_data_queue_tmp,TRUE); -- 2.34.1