MainWindow * main_win);
+/**
+ * Function to redraw each viewer belonging to the current tab
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void update_traceset(MainWindow * main_win);
+
+
/**
* Function to register a hook function for a viewer to set/update its
* filter.
*/
LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win);
+
+LttvTracesetContext* get_traceset_context(MainWindow *main_win);
LttvHooks *before_event,
LttvHooks *after_event);
+void lttv_trace_context_add_hooks(LttvTraceContext *self,
+ LttvHooks *check_trace,
+ LttvHooks *before_trace,
+ LttvHooks *after_trace);
+
+void lttv_trace_context_remove_hooks(LttvTraceContext *self,
+ LttvHooks *check_trace,
+ LttvHooks *before_trace,
+ LttvHooks *after_trace);
+
+void lttv_tracefile_context_add_hooks(LttvTracefileContext *self,
+ LttvHooks *check_tracefile,
+ LttvHooks *before_tracefile,
+ LttvHooks *after_tracefile,
+ LttvHooks *check_event,
+ LttvHooks *before_event,
+ LttvHooks *after_event);
+
+void lttv_tracefile_context_remove_hooks(LttvTracefileContext *self,
+ LttvHooks *check_tracefile,
+ LttvHooks *before_tracefile,
+ LttvHooks *after_tracefile,
+ LttvHooks *check_event,
+ LttvHooks *before_event,
+ LttvHooks *after_event);
+
+void lttv_tracefile_context_add_hooks_by_id(LttvTracefileContext *self,
+ unsigned i,
+ LttvHooks *before_event_by_id,
+ LttvHooks *after_event_by_id);
+
+void lttv_tracefile_context_remove_hooks_by_id(LttvTracefileContext *self,
+ unsigned i);
+
typedef struct _LttvTraceHook {
LttvHook h;
guint id;
ltt_tracefile_find_time_block(t, time, t->which_block+1, t->block_number);
return ltt_tracefile_seek_time(t, time);
}else {
- g_print("End of file\n");
+ t->cur_event_pos = t->buffer + t->block_size;
+ g_print("End of file\n");
return;
}
}else if(tailTime == 0){
{
LttvAttributeValue value;
LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+ g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
"hooks/updatetraceset", LTTV_POINTER, &value));
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL){
{
LttvAttributeValue value;
LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+ g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
"hooks/updatetraceset", LTTV_POINTER, &value));
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL) return;
}
+/**
+ * Function to redraw each viewer belonging to the current tab
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void update_traceset(MainWindow * main_win)
+{
+ LttvAttributeValue value;
+ LttvHooks * tmp;
+ g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+ "hooks/updatetraceset", LTTV_POINTER, &value));
+ tmp = (LttvHooks*)*(value.v_pointer);
+ if(tmp == NULL) return;
+ lttv_hooks_call(tmp, NULL);
+}
+
+
/**
* Function to register a hook function for a viewer to set/update its
* filter.
{
return main_win->current_tab->traceset_info->traceset_context;
}
+
+
+LttvTracesetContext* get_traceset_context(MainWindow *main_win)
+{
+ return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context;
+}
char * get_unload_module(char ** loaded_module_name, int nb_module);
char * get_remove_trace(char ** all_trace_name, int nb_trace);
char * get_selection(char ** all_name, int nb, char *title, char * column_title);
-void get_filter_selection(LttvTracesetSelector *s, char *title, char * column_title);
+gboolean get_filter_selection(LttvTracesetSelector *s, char *title, char * column_title);
void * create_tab(MainWindow * parent, MainWindow * current_window,
GtkNotebook * notebook, char * label);
LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
-void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window, unsigned nb_events);
-
+void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window);
+unsigned get_max_event_number(MainWindow * mw_data);
enum {
CHECKBOX_COLUMN,
void
insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data)
{
- GdkWindow * win;
- GdkCursor * new;
guint val = 20;
- GtkWidget* widget = menuitem;
- new = gdk_cursor_new(GDK_X_CURSOR);
- if(GTK_IS_MENU_ITEM(menuitem)){
- widget = lookup_widget(menuitem, "MToolbar2");
- }
- win = gtk_widget_get_parent_window(widget);
- gdk_window_set_cursor(win, new);
- gdk_cursor_unref(new);
- gdk_window_stick(win);
- gdk_window_unstick(win);
-
insert_viewer((GtkWidget*)menuitem, (view_constructor)user_data);
// selected_hook(&val);
-
- gdk_window_set_cursor(win, NULL);
}
MainWindow * mw_data;
GtkWidget * viewer;
LttvTracesetSelector * s;
- unsigned * size;
TimeInterval * time_interval;
TimeWindow time_window;
// Added by MD
// g_object_unref(G_OBJECT(viewer));
- size = (unsigned*)g_object_get_data(G_OBJECT(viewer), MAX_NUMBER_EVENT);
- if(size == NULL) *size = G_MAXULONG;
-
time_window = mw_data->current_tab->time_window;
time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN);
if(time_interval){
time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime);
}
- redraw_viewer(mw_data,&time_window, *size);
+ redraw_viewer(mw_data,&time_window);
set_current_time(mw_data,&(mw_data->current_tab->current_time));
}
}
}
-void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window, unsigned nb_events)
+unsigned get_max_event_number(MainWindow * mw_data)
{
+ unsigned nb = 0, *size;
+ GtkWidget * w;
+
+ w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);
+ while(w){
+ size = (unsigned*)g_object_get_data(G_OBJECT(w), MAX_NUMBER_EVENT);
+ if(size == NULL){
+ nb = G_MAXULONG;
+ break;
+ }else{
+ if(nb < *size)
+ nb = *size;
+ }
+ w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);
+ }
+ return nb;
+}
+
+void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
+{
+ unsigned max_nb_events;
+ GdkWindow * win;
+ GdkCursor * new;
+ GtkWidget* widget;
+
+ new = gdk_cursor_new(GDK_X_CURSOR);
+ widget = lookup_widget(mw_data->mwindow, "MToolbar2");
+ win = gtk_widget_get_parent_window(widget);
+ gdk_window_set_cursor(win, new);
+ gdk_cursor_unref(new);
+ gdk_window_stick(win);
+ gdk_window_unstick(win);
+
//update time window of each viewer, let viewer insert hooks needed by process_traceset
set_time_window(mw_data, time_window);
+
+ max_nb_events = get_max_event_number(mw_data);
process_traceset_api(mw_data, time_window->start_time,
ltt_time_add(time_window->start_time,time_window->time_width),
- nb_events);
+ max_nb_events);
//call hooks to show each viewer and let them remove hooks
show_viewer(mw_data);
+
+ gdk_window_set_cursor(win, NULL);
}
void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * t)
gtk_widget_destroy((GtkWidget*)file_selector);
//update current tab
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window), G_MAXULONG);
+ update_traceset(mw_data);
+ redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
set_current_time(mw_data,&(mw_data->current_tab->current_time));
break;
case GTK_RESPONSE_REJECT:
LTTV_TRACESET_CONTEXT(mw_data->current_tab->
traceset_info->traceset_context),traceset);
//update current tab
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window), G_MAXULONG);
+ update_traceset(mw_data);
+ redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
set_current_time(mw_data,&(mw_data->current_tab->current_time));
}
break;
{
TimeInterval *time_span;
TimeWindow time_window;
- LttTime current_time, time_delta, time_s, time_e;
+ LttTime current_time, time_delta, time_s, time_e, time_t;
MainWindow * mw_data = get_window_data_struct(widget);
time_span = LTTV_TRACESET_CONTEXT(mw_data->current_tab->
if(ltt_time_compare(time_window.time_width,time_delta) > 0)
time_window.time_width = time_delta;
- time_s = ltt_time_sub(current_time,ltt_time_div(time_window.time_width, 2));
- time_e = ltt_time_add(current_time,ltt_time_div(time_window.time_width, 2));
+ time_t = ltt_time_div(time_window.time_width, 2);
+ if(ltt_time_compare(current_time, time_t) < 0){
+ time_s = time_span->startTime;
+ } else {
+ time_s = ltt_time_sub(current_time,time_t);
+ }
+ time_e = ltt_time_add(current_time,time_t);
if(ltt_time_compare(time_span->startTime, time_s) > 0){
time_s = time_span->startTime;
}else if(ltt_time_compare(time_span->endTime, time_e) < 0){
}
time_window.start_time = time_s;
}
- redraw_viewer(mw_data, &time_window, G_MAXULONG);
+ redraw_viewer(mw_data, &time_window);
set_current_time(mw_data,&(mw_data->current_tab->current_time));
gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
}
g_printf("There is no viewer yet\n");
return;
}
- get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles");
+ if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){
+ update_traceset(mw_data);
+ redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
+ set_current_time(mw_data,&(mw_data->current_tab->current_time));
+ }
}
void
}
}
-void get_filter_selection(LttvTracesetSelector *s,char *title, char * column_title)
+gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column_title)
{
GtkWidget * dialogue;
GtkTreeStore * store;
case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_OK:
update_filter(s, store);
+ gtk_widget_destroy(dialogue);
+ return TRUE;
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
default:
gtk_widget_destroy(dialogue);
break;
}
+ return FALSE;
}
char * get_remove_trace(char ** all_trace_name, int nb_trace)
LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->endTime.tv_sec;
tmp_time.tv_nsec = 0;
tmp_tab->time_window.time_width = tmp_time ;
- tmp_tab->current_time.tv_sec = tmp_time.tv_sec / 2;
- tmp_tab->current_time.tv_nsec = 0 ;
+ tmp_tab->current_time.tv_sec =
+ LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_sec;
+ tmp_tab->current_time.tv_nsec =
+ LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_nsec;
}
tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
// mw_data->current_tab = tmp_tab;
/** Array containing instanced objects. Used when module is unloaded */
static GSList *g_event_viewer_data_list = NULL ;
-/** hook functions for update time interval, current time ... */
-gboolean update_time_window(void * hook_data, void * call_data);
-gboolean update_current_time(void * hook_data, void * call_data);
-gboolean show_event_detail(void * hook_data, void * call_data);
-void remove_item_from_queue(GQueue * q, gboolean fromHead);
-void remove_all_items_from_queue(GQueue * q);
-
typedef struct _RawTraceData{
unsigned cpu_id;
char * event_name;
unsigned end_event_index; //the last event shown in the window
unsigned size; //maxi number of events loaded when instance the viewer
gboolean shown; //indicate if event detail is shown or not
-
+ char * filter_key;
+
//scroll window containing Tree View
GtkWidget * scroll_win;
} EventViewerData ;
+/** hook functions for update time interval, current time ... */
+gboolean update_time_window(void * hook_data, void * call_data);
+gboolean update_current_time(void * hook_data, void * call_data);
+gboolean show_event_detail(void * hook_data, void * call_data);
+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);
+void remove_context_hooks(EventViewerData * event_viewer_data,
+ LttvTracesetContext * tsc);
+
//! Event Viewer's constructor hook
GtkWidget *h_gui_events(MainWindow *parent_window, LttvTracesetSelector * s, char* key);
//! Event Viewer's constructor
reg_update_time_window(update_time_window,event_viewer_data, event_viewer_data->mw);
reg_update_current_time(update_current_time,event_viewer_data, event_viewer_data->mw);
reg_show_viewer(show_event_detail,event_viewer_data, event_viewer_data->mw);
+ reg_update_traceset(traceset_changed,event_viewer_data, event_viewer_data->mw);
event_viewer_data->scroll_win = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show ( event_viewer_data->scroll_win);
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),
- key,
+ event_viewer_data->filter_key,
s);
g_object_set_data_full(
gboolean show_event_detail(void * hook_data, void * call_data)
{
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
+ LttvTracesetContext * tsc = get_traceset_context(event_viewer_data->mw);
if(event_viewer_data->shown == FALSE){
event_viewer_data->shown = TRUE;
get_test_data(event_viewer_data->vadjust_c->value,
event_viewer_data->num_visible_events,
event_viewer_data);
- //remove hooks from context
- context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+
+ remove_context_hooks(event_viewer_data,tsc);
}
return 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--;
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++;
if(event_viewer_data->end_event_index >= event_viewer_data->number_of_events - 1 - list_height){
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++;
if(size < list_height){
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--;
break;
}
+ if(event_number < 0) event_number = 0;
+
//update the value of the scroll bar
if(direction != SCROLL_NONE && direction != SCROLL_JUMP){
first = event_viewer_data->raw_trace_data_queue->head;
- raw_data = (RawTraceData*)g_list_nth_data(first,event_number);
- 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;
+ if(first){
+ raw_data = (RawTraceData*)g_list_nth_data(first,event_number);
+ 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;
+ }
}
first = event_viewer_data->raw_trace_data_queue->head;
gtk_list_store_clear(event_viewer_data->store_m);
+ if(!first){
+ // event_viewer_data->previous_value = 0;
+ // event_viewer_data->vadjust_c->value = 0.0;
+ // gtk_widget_hide(event_viewer_data->vscroll_vc);
+ goto LAST;
+ }else gtk_widget_show(event_viewer_data->vscroll_vc);
+
for(i=event_number; i<event_number+list_height; i++)
{
guint64 real_data;
event_viewer_data->first_event = event_viewer_data->start_event_index ;
event_viewer_data->last_event = event_viewer_data->end_event_index ;
+ LAST:
if(widget)
gdk_window_set_cursor(win, NULL);
unreg_update_time_window(update_time_window,event_viewer_data, event_viewer_data->mw);
unreg_update_current_time(update_current_time,event_viewer_data, event_viewer_data->mw);
unreg_show_viewer(show_event_detail,event_viewer_data, event_viewer_data->mw);
+ unreg_update_traceset(traceset_changed,event_viewer_data, event_viewer_data->mw);
g_event_viewer_data_list = g_slist_remove(g_event_viewer_data_list, event_viewer_data);
g_free(event_viewer_data);
/* May already been done by GTK window closing */
if(GTK_IS_WIDGET(event_viewer_data->hbox_v)){
gtk_widget_destroy(event_viewer_data->hbox_v);
+ g_free(event_viewer_data->filter_key);
event_viewer_data = NULL;
}
}
+void add_context_hooks(EventViewerData * event_viewer_data,
+ LttvTracesetContext * tsc)
+{
+ gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ LttTrace *trace;
+ LttvTraceContext *tc;
+ LttvTracefileContext *tfc;
+ LttvTracesetSelector * ts_s;
+ LttvTraceSelector * t_s;
+ LttvTracefileSelector * tf_s;
+ gboolean selected;
+
+ ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v),
+ event_viewer_data->filter_key);
+
+ //if there are hooks for traceset, add them here
+
+ nbi = lttv_traceset_number(tsc->ts);
+ for(i = 0 ; i < nbi ; i++) {
+ t_s = lttv_traceset_selector_get(ts_s,i);
+ selected = lttv_trace_selector_get_selected(t_s);
+ if(!selected) continue;
+ tc = tsc->traces[i];
+ trace = tc->t;
+ //if there are hooks for trace, add them here
+
+ nb_control = ltt_trace_control_tracefile_number(trace);
+ nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
+ nb_tracefile = nb_control + nb_per_cpu;
+
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tf_s = lttv_trace_selector_get(t_s,j);
+ selected = lttv_tracefile_selector_get_selected(tf_s);
+ if(!selected) continue;
+
+ if(j < nb_control)
+ tfc = tc->control_tracefiles[j];
+ else
+ 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);
+ }
+ }
+
+ //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);
+}
+
+
+void remove_context_hooks(EventViewerData * event_viewer_data,
+ LttvTracesetContext * tsc)
+{
+ gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ LttTrace *trace;
+ LttvTraceContext *tc;
+ LttvTracefileContext *tfc;
+ LttvTracesetSelector * ts_s;
+ LttvTraceSelector * t_s;
+ LttvTracefileSelector * tf_s;
+ gboolean selected;
+
+ ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v),
+ event_viewer_data->filter_key);
+
+ //if there are hooks for traceset, remove them here
+
+ nbi = lttv_traceset_number(tsc->ts);
+ for(i = 0 ; i < nbi ; i++) {
+ t_s = lttv_traceset_selector_get(ts_s,i);
+ selected = lttv_trace_selector_get_selected(t_s);
+ if(!selected) continue;
+ tc = tsc->traces[i];
+ trace = tc->t;
+ //if there are hooks for trace, remove them here
+
+ nb_control = ltt_trace_control_tracefile_number(trace);
+ nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
+ nb_tracefile = nb_control + nb_per_cpu;
+
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tf_s = lttv_trace_selector_get(t_s,j);
+ selected = lttv_tracefile_selector_get_selected(tf_s);
+ if(!selected) continue;
+
+ if(j < nb_control)
+ tfc = tc->control_tracefiles[j];
+ else
+ 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);
+ }
+ }
+ //remove hooks from context
+ // context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
+ // NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+}
+
+
gboolean update_time_window(void * hook_data, void * call_data)
{
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
+ LttvTracesetContext * tsc = get_traceset_context(event_viewer_data->mw);
if(event_viewer_data->shown == FALSE){
event_viewer_data->time_window = *(TimeWindow*)call_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);
+
+ add_context_hooks(event_viewer_data, tsc);
}
return FALSE;
return FALSE;
}
+gboolean traceset_changed(void * hook_data, void * call_data)
+{
+ EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
+ LttTime start;
+
+ remove_all_items_from_queue(event_viewer_data->raw_trace_data_queue);
+ gtk_list_store_clear(event_viewer_data->store_m);
+ event_viewer_data->shown = FALSE;
+ event_viewer_data->append = TRUE;
+
+ get_traceset_time_span(event_viewer_data->mw, &event_viewer_data->time_span);
+ start = ltt_time_sub(event_viewer_data->time_span.endTime, event_viewer_data->time_span.startTime);
+ event_viewer_data->vadjust_c->upper = ltt_time_to_double(start) * NANOSECONDS_PER_SECOND;
+ // event_viewer_data->vadjust_c->value = 0;
+
+ return FALSE;
+}
+
+
void tree_v_grab_focus(GtkWidget *widget, gpointer data){
EventViewerData *event_viewer_data = (EventViewerData *)data;
MainWindow * mw = event_viewer_data->mw;
LttTime end,unsigned max_num_events, unsigned * real_num_events)
{
int size;
- context_add_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+ 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);
+ add_context_hooks(event_viewer_data,tsc);
+
process_traceset_api(event_viewer_data->mw, start, end, max_num_events);
- context_remove_hooks_api(event_viewer_data->mw, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL,event_viewer_data->before_event_hooks,NULL);
+
+ 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);
size = event_viewer_data->raw_trace_data_queue_tmp->length;
*real_num_events = size;
void statistic_destroy_hash_key(gpointer key);
void statistic_destroy_hash_data(gpointer data);
-void get_traceset_stats(StatisticViewerData * statistic_viewer_data);
void show_traceset_stats(StatisticViewerData * statistic_viewer_data);
void show_tree(StatisticViewerData * statistic_viewer_data,
LttvAttribute* stats, GtkTreeIter* parent);
LttvAttribute* stats, GtkTextBuffer* buf);
+/** hook functions for update time interval, current time ... */
+gboolean statistic_update_time_window(void * hook_data, void * call_data);
+gboolean statistic_show_viewer(void * hook_data, void * call_data);
+gboolean statistic_traceset_changed(void * hook_data, void * call_data);
+void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
+ LttvTracesetContext * tsc);
+void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
+ LttvTracesetContext * tsc);
+
enum
{
NAME_COLUMN,
MainWindow * mw;
LttvTracesetStats * stats;
+ TimeInterval time_span;
+ gboolean shown; //indicate if the statistic is shown or not
+ char * filter_key;
+
GtkWidget * hpaned_v;
GtkTreeStore * store_m;
GtkWidget * tree_v;
gui_statistic_free(StatisticViewerData *statistic_viewer_data)
{
if(statistic_viewer_data){
+ unreg_update_time_window(statistic_update_time_window,statistic_viewer_data, statistic_viewer_data->mw);
+ unreg_show_viewer(statistic_show_viewer,statistic_viewer_data, statistic_viewer_data->mw);
+ unreg_update_traceset(statistic_traceset_changed,statistic_viewer_data, statistic_viewer_data->mw);
+
g_hash_table_destroy(statistic_viewer_data->statistic_hash);
+ g_free(statistic_viewer_data->filter_key);
g_statistic_viewer_data_list = g_slist_remove(g_statistic_viewer_data_list, statistic_viewer_data);
g_free(statistic_viewer_data);
}
statistic_viewer_data->mw = parent_window;
statistic_viewer_data->stats = get_traceset_stats_api(statistic_viewer_data->mw);
+ reg_update_time_window(statistic_update_time_window,statistic_viewer_data, statistic_viewer_data->mw);
+ reg_show_viewer(statistic_show_viewer,statistic_viewer_data, statistic_viewer_data->mw);
+ reg_update_traceset(statistic_traceset_changed,statistic_viewer_data, statistic_viewer_data->mw);
+
statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
statistic_destroy_hash_key,
statistic_destroy_hash_data);
gtk_widget_show(statistic_viewer_data->text_v);
gtk_widget_show(statistic_viewer_data->hpaned_v);
+ //get the life span of the traceset and set the upper of the scroll bar
+ get_traceset_time_span(statistic_viewer_data->mw, &statistic_viewer_data->time_span);
+
+ statistic_viewer_data->shown = FALSE;
+ statistic_viewer_data->filter_key = g_strdup(key);
g_object_set_data(
G_OBJECT(statistic_viewer_data->hpaned_v),
- key,
+ statistic_viewer_data->filter_key,
s);
+ g_object_set_data(
+ G_OBJECT(statistic_viewer_data->hpaned_v),
+ TRACESET_TIME_SPAN,
+ &statistic_viewer_data->time_span);
+
g_object_set_data_full(
G_OBJECT(statistic_viewer_data->hpaned_v),
"statistic_viewer_data",
g_statistic_viewer_data_list,
statistic_viewer_data);
- get_traceset_stats(statistic_viewer_data);
-
return statistic_viewer_data;
}
// g_free(data);
}
-void get_traceset_stats(StatisticViewerData * statistic_viewer_data)
-{
- LttTime start, end;
-
- start.tv_sec = 0;
- start.tv_nsec = 0;
- end.tv_sec = G_MAXULONG;
- end.tv_nsec = G_MAXULONG;
-
- state_add_event_hooks_api(statistic_viewer_data->mw);
- stats_add_event_hooks_api(statistic_viewer_data->mw);
-
- process_traceset_api(statistic_viewer_data->mw, start, end, G_MAXULONG);
-
- state_remove_event_hooks_api(statistic_viewer_data->mw);
- stats_remove_event_hooks_api(statistic_viewer_data->mw);
-
- //establish tree view for stats
- show_traceset_stats(statistic_viewer_data);
-}
-
void show_traceset_stats(StatisticViewerData * statistic_viewer_data)
{
int i, nb;
}
}
+gboolean statistic_update_time_window(void * hook_data, void * call_data)
+{
+ StatisticViewerData *statistic_viewer_data = (StatisticViewerData*) hook_data;
+ LttvTracesetContext * tsc = get_traceset_context(statistic_viewer_data->mw);
+
+ if(statistic_viewer_data->shown == FALSE){
+ statistic_add_context_hooks(statistic_viewer_data, tsc);
+ }
+ return FALSE;
+}
+
+gboolean statistic_show_viewer(void * hook_data, void * call_data)
+{
+ StatisticViewerData *statistic_viewer_data = (StatisticViewerData*) hook_data;
+ LttvTracesetContext * tsc = get_traceset_context(statistic_viewer_data->mw);
+
+ if(statistic_viewer_data->shown == FALSE){
+ statistic_viewer_data->shown = TRUE;
+ show_traceset_stats(statistic_viewer_data);
+ statistic_remove_context_hooks(statistic_viewer_data,tsc);
+ }
+
+ return FALSE;
+}
+
+gboolean statistic_traceset_changed(void * hook_data, void * call_data)
+{
+ StatisticViewerData *statistic_viewer_data = (StatisticViewerData*) hook_data;
+
+ // gtk_tree_store_clear (statistic_viewer_data->store_m);
+ // statistic_viewer_data->shown = FALSE;
+
+ return FALSE;
+}
+
+void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
+ LttvTracesetContext * tsc)
+{
+ gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ LttTrace *trace;
+ LttvTraceContext *tc;
+ LttvTracefileContext *tfc;
+ LttvTracesetSelector * ts_s;
+ LttvTraceSelector * t_s;
+ LttvTracefileSelector * tf_s;
+ gboolean selected;
+
+ ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
+ statistic_viewer_data->filter_key);
+
+ //if there are hooks for traceset, add them here
+
+ nbi = lttv_traceset_number(tsc->ts);
+ for(i = 0 ; i < nbi ; i++) {
+ t_s = lttv_traceset_selector_get(ts_s,i);
+ selected = lttv_trace_selector_get_selected(t_s);
+ if(!selected) continue;
+ tc = tsc->traces[i];
+ trace = tc->t;
+ //if there are hooks for trace, add them here
+
+ nb_control = ltt_trace_control_tracefile_number(trace);
+ nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
+ nb_tracefile = nb_control + nb_per_cpu;
+
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tf_s = lttv_trace_selector_get(t_s,j);
+ selected = lttv_tracefile_selector_get_selected(tf_s);
+ if(!selected) continue;
+
+ if(j < nb_control)
+ tfc = tc->control_tracefiles[j];
+ else
+ 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,
+ // statistic_viewer_data->before_event_hooks,NULL);
+ }
+ }
+
+ //add state and stats hooks
+ state_add_event_hooks_api(statistic_viewer_data->mw);
+ stats_add_event_hooks_api(statistic_viewer_data->mw);
+
+}
+
+void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
+ LttvTracesetContext * tsc)
+{
+ gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ LttTrace *trace;
+ LttvTraceContext *tc;
+ LttvTracefileContext *tfc;
+ LttvTracesetSelector * ts_s;
+ LttvTraceSelector * t_s;
+ LttvTracefileSelector * tf_s;
+ gboolean selected;
+
+ ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
+ statistic_viewer_data->filter_key);
+
+ //if there are hooks for traceset, remove them here
+
+ nbi = lttv_traceset_number(tsc->ts);
+ for(i = 0 ; i < nbi ; i++) {
+ t_s = lttv_traceset_selector_get(ts_s,i);
+ selected = lttv_trace_selector_get_selected(t_s);
+ if(!selected) continue;
+ tc = tsc->traces[i];
+ trace = tc->t;
+ //if there are hooks for trace, remove them here
+
+ nb_control = ltt_trace_control_tracefile_number(trace);
+ nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
+ nb_tracefile = nb_control + nb_per_cpu;
+
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tf_s = lttv_trace_selector_get(t_s,j);
+ selected = lttv_tracefile_selector_get_selected(tf_s);
+ if(!selected) continue;
+
+ if(j < nb_control)
+ tfc = tc->control_tracefiles[j];
+ else
+ 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,
+ // statistic_viewer_data->before_event_hooks,NULL);
+ }
+ }
+
+ //remove state and stats hooks
+ state_remove_event_hooks_api(statistic_viewer_data->mw);
+ stats_remove_event_hooks_api(statistic_viewer_data->mw);
+}
+
}
}
+void lttv_trace_context_add_hooks(LttvTraceContext *tc,
+ LttvHooks *check_trace,
+ LttvHooks *before_trace,
+ LttvHooks *after_trace)
+{
+ lttv_hooks_add_list(tc->check, check_trace);
+ lttv_hooks_add_list(tc->before, before_trace);
+ lttv_hooks_add_list(tc->after, after_trace);
+}
+
+void lttv_trace_context_remove_hooks(LttvTraceContext *tc,
+ LttvHooks *check_trace,
+ LttvHooks *before_trace,
+ LttvHooks *after_trace)
+{
+ lttv_hooks_remove_list(tc->check, check_trace);
+ lttv_hooks_remove_list(tc->before, before_trace);
+ lttv_hooks_remove_list(tc->after, after_trace);
+}
+
+void lttv_tracefile_context_add_hooks(LttvTracefileContext *tfc,
+ LttvHooks *check_tracefile,
+ LttvHooks *before_tracefile,
+ LttvHooks *after_tracefile,
+ LttvHooks *check_event,
+ LttvHooks *before_event,
+ LttvHooks *after_event)
+{
+ lttv_hooks_add_list(tfc->check, check_tracefile);
+ lttv_hooks_add_list(tfc->before, before_tracefile);
+ lttv_hooks_add_list(tfc->after, after_tracefile);
+ lttv_hooks_add_list(tfc->check_event, check_event);
+ lttv_hooks_add_list(tfc->before_event, before_event);
+ lttv_hooks_add_list(tfc->after_event, after_event);
+}
+
+void lttv_tracefile_context_remove_hooks(LttvTracefileContext *tfc,
+ LttvHooks *check_tracefile,
+ LttvHooks *before_tracefile,
+ LttvHooks *after_tracefile,
+ LttvHooks *check_event,
+ LttvHooks *before_event,
+ LttvHooks *after_event)
+{
+ lttv_hooks_remove_list(tfc->check, check_tracefile);
+ lttv_hooks_remove_list(tfc->before, before_tracefile);
+ lttv_hooks_remove_list(tfc->after, after_tracefile);
+ lttv_hooks_remove_list(tfc->check_event, check_event);
+ lttv_hooks_remove_list(tfc->before_event, before_event);
+ lttv_hooks_remove_list(tfc->after_event, after_event);
+}
+
+void lttv_tracefile_context_add_hooks_by_id(LttvTracefileContext *tfc,
+ unsigned i,
+ LttvHooks *before_event_by_id,
+ LttvHooks *after_event_by_id)
+{
+ LttvHooks * h;
+ h = lttv_hooks_by_id_find(tfc->before_event_by_id, i);
+ lttv_hooks_add_list(h, before_event_by_id);
+ h = lttv_hooks_by_id_find(tfc->after_event_by_id, i);
+ lttv_hooks_add_list(h, after_event_by_id);
+}
+
+void lttv_tracefile_context_remove_hooks_by_id(LttvTracefileContext *tfc,
+ unsigned i)
+{
+ lttv_hooks_by_id_remove(tfc->before_event_by_id, i);
+ lttv_hooks_by_id_remove(tfc->after_event_by_id, i);
+}
static LttvTracesetContext *
new_traceset_context(LttvTracesetContext *self)
g_ptr_array_add(tracefiles, tfc);
lttv_hooks_call(tfc->before, tfc);
- if(event != NULL) {
- g_tree_insert(pqueue, &(tfc->timestamp), tfc);
+ if(tfc->e != NULL) {
+ if(tfc->timestamp.tv_sec < end.tv_sec ||
+ (tfc->timestamp.tv_sec == end.tv_sec && tfc->timestamp.tv_nsec <= end.tv_nsec)){
+ g_tree_insert(pqueue, &(tfc->timestamp), tfc);
+ }
}
}
}