static GSList *sEvent_Viewer_Data_List = NULL ;
/** hook functions for update time interval, current time ... */
-gboolean updateTimeInterval(void * hook_data, void * call_data);
+gboolean updateTimeWindow(void * hook_data, void * call_data);
gboolean updateCurrentTime(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 _EventViewerData {
mainWindow * mw;
- TimeInterval time_interval;
+ TimeWindow time_window;
LttTime current_time;
LttvHooks * before_event_hooks;
GQueue * raw_trace_data_queue_tmp; //tmp buf to contain raw data
unsigned current_event_index;
double previous_value; //value of the slide
- LttTime trace_start;
- LttTime trace_end;
+ TimeInterval time_span;
+ // LttTime trace_start;
+ // LttTime trace_end;
unsigned start_event_index; //the first event shown in the window
unsigned end_event_index; //the last event shown in the window
EventViewerData *GuiEvents(mainWindow *pmParentWindow);
//! Event Viewer's destructor
void GuiEvents_Destructor(EventViewerData *Event_Viewer_Data);
+void GuiEvents_free(EventViewerData *Event_Viewer_Data);
static int Event_Selected_Hook(void *hook_data, void *call_data);
LttTime end, unsigned maxNumEvents, unsigned * realNumEvent);
static gboolean parse_event(void *hook_data, void *call_data);
+static LttvModule *Main_Win_Module;
+
/**
* plugin's init function
*
* This function initializes the Event Viewer functionnality through the
* gtkTraceSet API.
*/
-G_MODULE_EXPORT void init() {
+G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
+
+ Main_Win_Module = lttv_module_require(self, "mainwin", argc, argv);
+
+ if(Main_Win_Module == NULL)
+ {
+ g_critical("Can't load Control Flow Viewer : missing mainwin\n");
+ return;
+ }
+
g_critical("GUI Event Viewer init()");
g_critical("GUI Event Viewer destroy()");
g_slist_foreach(sEvent_Viewer_Data_List, destroy_walk, NULL );
-
+
+ g_slist_free(sEvent_Viewer_Data_List);
+
/* Unregister the toolbar insert button */
ToolbarItemUnreg(hGuiEvents);
EventViewerData* Event_Viewer_Data = GuiEvents(pmParentWindow) ;
if(Event_Viewer_Data)
- return Event_Viewer_Data->HBox_V ;
+ return Event_Viewer_Data->HBox_V;
else return NULL;
}
GtkCellRenderer *renderer;
EventViewerData* Event_Viewer_Data = g_new(EventViewerData,1) ;
RawTraceData * data;
- double time_value;
unsigned size;
Event_Viewer_Data->mw = pmParentWindow;
- GetTimeInterval(Event_Viewer_Data->mw, &Event_Viewer_Data->time_interval);
+ GetTimeWindow(Event_Viewer_Data->mw, &Event_Viewer_Data->time_window);
GetCurrentTime(Event_Viewer_Data->mw, &Event_Viewer_Data->current_time);
Event_Viewer_Data->before_event_hooks = lttv_hooks_new();
Event_Viewer_Data->raw_trace_data_queue = g_queue_new();
Event_Viewer_Data->raw_trace_data_queue_tmp = g_queue_new();
- RegUpdateTimeInterval(updateTimeInterval,Event_Viewer_Data, Event_Viewer_Data->mw);
+ RegUpdateTimeWindow(updateTimeWindow,Event_Viewer_Data, Event_Viewer_Data->mw);
RegUpdateCurrentTime(updateCurrentTime,Event_Viewer_Data, Event_Viewer_Data->mw);
Event_Viewer_Data->Scroll_Win = gtk_scrolled_window_new (NULL, NULL);
Event_Viewer_Data->Selected_Event = 0;
/* 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 */
+ 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 */
/* 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));
Event_Viewer_Data->Num_Visible_Events = 1;
//get the life span of the traceset and set the upper of the scroll bar
- getTracesetTimeSpan(Event_Viewer_Data->mw, &Event_Viewer_Data->trace_start,
- &Event_Viewer_Data->trace_end);
- time_value = Event_Viewer_Data->trace_end.tv_sec - Event_Viewer_Data->trace_start.tv_sec;
- time_value *= NANSECOND_CONST;
- time_value += (double)Event_Viewer_Data->trace_end.tv_nsec - Event_Viewer_Data->trace_start.tv_nsec;
- Event_Viewer_Data->VAdjust_C->upper = time_value;
+ getTracesetTimeSpan(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->append = TRUE;
/* Set the Selected Event */
// Tree_V_set_cursor(Event_Viewer_Data);
+
+
+ g_object_set_data_full(
+ G_OBJECT(Event_Viewer_Data->HBox_V),
+ "Event_Viewer_Data",
+ Event_Viewer_Data,
+ (GDestroyNotify)GuiEvents_free);
return Event_Viewer_Data;
}
gtk_tree_view_get_cursor(GTK_TREE_VIEW(Event_Viewer_Data->Tree_V), &path, NULL);
if(gtk_tree_model_get_iter(model,&iter,path)){
gtk_tree_model_get(model, &iter, TIME_COLUMN, &time, -1);
- ltt_time.tv_sec = time / NANSECOND_CONST;
- ltt_time.tv_nsec = time % NANSECOND_CONST;
+ ltt_time.tv_sec = time / NANOSECONDS_PER_SECOND;
+ ltt_time.tv_nsec = time % NANOSECONDS_PER_SECOND;
if(ltt_time.tv_sec != Event_Viewer_Data->current_time.tv_sec ||
ltt_time.tv_nsec != Event_Viewer_Data->current_time.tv_nsec)
remove_all_items_from_queue(Event_Viewer_Data->raw_trace_data_queue);
end.tv_sec = G_MAXULONG;
end.tv_nsec = G_MAXULONG;
- start = Event_Viewer_Data->trace_start;
- value = (int)(time_value / NANSECOND_CONST);
- start.tv_sec += value;
- value = time_value / NANSECOND_CONST - value;
- value *= NANSECOND_CONST;
- start.tv_nsec += value;
- if(start.tv_nsec > NANSECOND_CONST){
- start.tv_sec++;
- start.tv_nsec -= NANSECOND_CONST;
- }
+ 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){
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{
+ Event_Number = 0;
}
- Event_Number = Event_Viewer_Data->raw_trace_data_queue->length - List_Height;
break;
case SCROLL_NONE:
Event_Number = Event_Viewer_Data->current_event_index;
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);
- value = raw_data->time.tv_sec;
- value -= Event_Viewer_Data->trace_start.tv_sec;
- value *= NANSECOND_CONST;
- value -= Event_Viewer_Data->trace_start.tv_nsec;
- value += raw_data->time.tv_nsec;
- Event_Viewer_Data->VAdjust_C->value = value;
+ 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 = value;
}
// Add a new row to the model
real_data = raw_data->time.tv_sec;
- real_data *= NANSECOND_CONST;
+ real_data *= NANOSECONDS_PER_SECOND;
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,
}
+void
+GuiEvents_free(EventViewerData *Event_Viewer_Data)
+{
+ if(Event_Viewer_Data){
+ lttv_hooks_remove(Event_Viewer_Data->before_event_hooks,parse_event);
+ lttv_hooks_destroy(Event_Viewer_Data->before_event_hooks);
+
+ remove_all_items_from_queue (Event_Viewer_Data->raw_trace_data_queue);
+ g_queue_free(Event_Viewer_Data->raw_trace_data_queue);
+ g_queue_free(Event_Viewer_Data->raw_trace_data_queue_tmp);
+
+ UnregUpdateTimeWindow(updateTimeWindow,Event_Viewer_Data, Event_Viewer_Data->mw);
+ UnregUpdateCurrentTime(updateCurrentTime,Event_Viewer_Data, Event_Viewer_Data->mw);
+
+ sEvent_Viewer_Data_List = g_slist_remove(sEvent_Viewer_Data_List, Event_Viewer_Data);
+ g_warning("Delete Event data\n");
+ g_free(Event_Viewer_Data);
+ }
+}
void
GuiEvents_Destructor(EventViewerData *Event_Viewer_Data)
guint index;
/* May already been done by GTK window closing */
- if(GTK_IS_WIDGET(Event_Viewer_Data->HBox_V))
+ if(GTK_IS_WIDGET(Event_Viewer_Data->HBox_V)){
gtk_widget_destroy(Event_Viewer_Data->HBox_V);
+ Event_Viewer_Data = NULL;
+ }
/* Destroy the Tree View */
//gtk_widget_destroy(Event_Viewer_Data->Tree_V);
//gtk_list_store_clear(Event_Viewer_Data->Store_M);
//gtk_widget_destroy(GTK_WIDGET(Event_Viewer_Data->Store_M));
- g_slist_remove(sEvent_Viewer_Data_List,Event_Viewer_Data);
- g_free(Event_Viewer_Data);
+ g_warning("Delete Event data from destroy\n");
+ //GuiEvents_free(Event_Viewer_Data);
}
//FIXME : call hGuiEvents_Destructor for corresponding data upon widget destroy
}
-gboolean updateTimeInterval(void * hook_data, void * call_data)
+gboolean updateTimeWindow(void * hook_data, void * call_data)
{
EventViewerData *Event_Viewer_Data = (EventViewerData*) hook_data;
- Event_Viewer_Data->time_interval = *(TimeInterval*)call_data;
+ Event_Viewer_Data->time_window = *(TimeWindow*)call_data;
return FALSE;
}
{
EventViewerData *Event_Viewer_Data = (EventViewerData*) hook_data;
Event_Viewer_Data->current_time = *(LttTime*)call_data;
- uint64_t nsec = Event_Viewer_Data->current_time.tv_sec * NANSECOND_CONST
+ uint64_t nsec = Event_Viewer_Data->current_time.tv_sec * NANOSECONDS_PER_SECOND
+ Event_Viewer_Data->current_time.tv_nsec;
GtkTreeIter iter;
uint64_t time;
}
// Event_Selected_Hook(Event_Viewer_Data, &count);
}
-
+
return FALSE;
}
+
+
/* Imported code from LTT 0.9.6pre2 tracevisualizer */
#ifdef DEBUG