#include <lttv/iattribute.h>
#include <lttv/stats.h>
#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/mainwindow-private.h>
#include <lttvwindow/menu.h>
#include <lttvwindow/toolbar.h>
#include <lttvwindow/lttvwindow.h>
/** Array containing instanced objects. */
extern GSList * g_main_window_list;
-static int g_win_count = 0;
-
/** MD : keep old directory. */
static char remember_plugins_dir[PATH_LENGTH] = "";
static char remember_trace_dir[PATH_LENGTH] = "";
char * get_remove_trace(char ** all_trace_name, int nb_trace);
char * get_selection(char ** all_name, int nb, char *title, char * column_title);
gboolean get_filter_selection(LttvTracesetSelector *s, char *title, char * column_title);
-void * create_tab(MainWindow * parent, MainWindow * current_window,
+void * create_tab(MainWindow * mw, Tab *copy_tab,
GtkNotebook * notebook, char * label);
-void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
+static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
void update_filter(LttvTracesetSelector *s, GtkTreeStore *store );
void checkbox_changed(GtkTreeView *treeview,
gpointer user_data);
void remove_trace_from_traceset_selector(GtkMultiVPaned * paned, unsigned i);
void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * trace);
+void create_new_tab(GtkWidget* widget, gpointer user_data);
LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
static gboolean lttvwindow_process_pending_requests(Tab *tab);
-unsigned get_max_event_number(MainWindow * mw_data);
enum {
CHECKBOX_COLUMN,
/* internal functions */
-static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
+void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
{
GtkMultiVPaned * multi_vpaned;
MainWindow * mw_data = get_window_data_struct(widget);
TimeInterval * time_interval;
Tab *tab = mw_data->current_tab;
- if(!tab) return;
+ if(!tab) create_new_tab(widget, NULL);
multi_vpaned = tab->multi_vpaned;
s = construct_traceset_selector(tab->traceset_info->traceset);
mw = lookup_widget(widget, "MWindow");
if(mw == NULL){
g_printf("Main window does not exist\n");
- return;
+ return NULL;
}
- mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"mainWindow");
+ mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"main_window_data");
if(mw_data == NULL){
g_printf("Main window data does not exist\n");
- return;
+ return NULL;
}
return mw_data;
}
}
-/* get_max_event_number returns the event number limit used by
- * lttv_process_traceset(LttvTracesetContext, endTime, maxNumEvents)
- * each viewer can set the limit
- */
-
-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;
-}
-
-
/* lttvwindow_process_pending_requests
*
* This internal function gets called by g_idle, taking care of the pending
GSList *list_in = NULL;
LttTime end_time;
guint end_nb_events;
+ guint count;
LttvTracesetContextPosition *end_position;
//set the cursor to be X shape, indicating that the computer is busy in doing its job
new = gdk_cursor_new(GDK_X_CURSOR);
- widget = lookup_widget(tab->mw_data->mwindow, "MToolbar1");
+ widget = lookup_widget(tab->mw->mwindow, "MToolbar1");
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);
- g_debug("SIZE events req len : %d", g_slist_length(events_request));
+ g_debug("SIZE events req len : %d", g_slist_length(events_requests));
/* Events processing algorithm implementation */
/* A. Servicing loop */
/* list in is empty, need a seek */
{
/* 1.1 Add requests to list_in */
- GArray *ltime = g_array_new(FALSE, FALSE, sizeof(guint));
- GArray *lpos = g_array_new(FALSE, FALSE, sizeof(guint));
- guint i;
+ GSList *ltime = NULL;
+ GSList *lpos = NULL;
+ GSList *iter = NULL;
/* 1.1.1 Find all time requests with the lowest start time in list_out
* (ltime)
*/
- if(list_out->len > 0)
- g_array_append_val(ltime, 0);
- for(i=1;i<list_out->len;i++) {
+ if(g_slist_length(list_out) > 0)
+ ltime = g_slist_append(ltime, g_slist_nth_data(list_out, 0));
+ for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
/* Find all time requests with the lowest start time in list_out */
guint index_ltime = g_array_index(ltime, guint, 0);
- EventsRequest *event_request_ltime = &g_array_index(list_out,
- EventsRequest,
- index_ltime);
- EventsRequest *event_request_list_out = &g_array_index(list_out,
- EventsRequest,
- i);
+ EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
+ EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
+
int comp;
comp = ltt_time_compare(event_request_ltime->start_time,
event_request_list_out->start_time);
if(comp == 0)
- g_array_append_val(ltime, i);
+ ltime = g_slist_append(ltime, event_request_list_out);
else if(comp > 0) {
/* Remove all elements from ltime, and add current */
- g_array_remove_range(ltime, 0, ltime->len);
- g_array_append_val(ltime, i);
-
+ while(ltime != NULL)
+ ltime = g_slist_delete_link(ltime, g_slist_nth(ltime, 0));
+ ltime = g_slist_append(ltime, event_request_list_out);
}
}
/* 1.1.2 Find all position requests with the lowest position in list_out
* (lpos)
*/
- if(list_out->len > 0)
- g_array_append(lpos, 0);
- for(i=1;i<list_out->len;i++) {
+ if(g_slist_length(list_out) > 0)
+ lpos = g_slist_append(lpos, g_slist_nth_data(list_out, 0));
+ for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
/* Find all position requests with the lowest position in list_out */
guint index_lpos = g_array_index(lpos, guint, 0);
- EventsRequest *event_request_lpos = &g_array_index(lpos,
- EventsRequest,
- index_lpos);
- EventsRequest *event_request_list_out = &g_array_index(list_out,
- EventsRequest,
- i);
+ EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
+ EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
+
int comp;
- comp = lttv_traceset_context_pos_pos_compare
- (event_request_pos->start_position,
+ if(event_request_lpos->start_position != NULL
+ && event_request_list_out->start_position != NULL)
+ {
+ comp = lttv_traceset_context_pos_pos_compare
+ (event_request_lpos->start_position,
event_request_list_out->start_position);
+ } else {
+ comp = -1;
+ }
if(comp == 0)
- g_array_append_val(lpos, i);
+ lpos = g_slist_append(lpos, event_request_list_out);
else if(comp > 0) {
/* Remove all elements from lpos, and add current */
- g_array_remove_range(lpos, 0, lpos->len);
- g_array_append_val(lpos, i);
+ while(lpos != NULL)
+ lpos = g_slist_delete_link(lpos, g_slist_nth(lpos, 0));
+ lpos = g_slist_append(lpos, event_request_list_out);
}
}
/* 1.1.3 If lpos.start time < ltime */
{
- guint i;
- EventsRequest *event_request_lpos = &g_array_index(lpos, 0);
- EventsRequest *event_request_ltime = &g_array_index(ltime,0);
- LttTime lpos_start_time =
- lttv_traceset_context_position_get_time(event_request_lpos);
+ EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
+ EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
+ LttTime lpos_start_time;
- if(ltt_time_compare(lpos_start_time,
- event_request_ltime->start_time)<0) {
- /* Add lpos to list_in, remove them from list_out */
-
- for(i=0;i<lpos->len;i++) {
- /* Add to list_in */
- guint index_lpos = g_array_index(lpos, guint, i);
- EventsRequest *event_request_lpos =
- &g_array_index(lpos,index_lpos);
-
- g_array_append_val(list_in, *event_request_lpos);
-
+ if(event_request_lpos != NULL
+ && event_request_lpos->start_position != NULL) {
+
+ lpos_start_time = lttv_traceset_context_position_get_time(
+ event_request_lpos->start_position);
+ if(ltt_time_compare(lpos_start_time,
+ event_request_ltime->start_time)<0) {
+ /* Add lpos to list_in, remove them from list_out */
+
+ for(iter=lpos;iter!=NULL;iter=g_slist_next(iter)) {
+ /* Add to list_in */
+ EventsRequest *event_request_lpos =
+ (EventsRequest*)iter->data;
+
+ g_slist_append(list_in, event_request_lpos);
+ /* Remove from list_out */
+ g_slist_remove(list_out, event_request_lpos);
+ }
}
-
- for(i=0;i<lpos->len;i++) {
- /* Remove from list_out */
- guint index_lpos = g_array_index(lpos, guint, i);
-
- g_array_remove_index_fast(list_out, index_lpos);
- }
-
} else {
/* 1.1.4 (lpos.start time >= ltime) */
/* Add ltime to list_in, remove them from list_out */
- for(i=0;i<ltime->len;i++) {
+ for(iter=ltime;iter!=NULL;iter=g_slist_next(iter)) {
/* Add to list_in */
- guint index_ltime = g_array_index(ltime, guint, i);
EventsRequest *event_request_ltime =
- &g_array_index(ltime,index_ltime);
-
- g_array_append_val(list_in, *event_request_ltime);
- }
+ (EventsRequest*)iter->data;
- for(i=0;i<ltime->len;i++) {
+ g_slist_append(list_in, event_request_ltime);
/* Remove from list_out */
- guint index_ltime = g_array_index(ltime, guint, i);
-
- g_array_remove_index_fast(list_out, index_ltime);
+ g_slist_remove(list_out, event_request_ltime);
}
}
}
- g_array_free(lpos, TRUE);
- g_array_free(ltime, TRUE);
+ g_slist_free(lpos);
+ g_slist_free(ltime);
}
/* 1.2 Seek */
{
- EventsRequest *events_request = &g_array_index(list_in,
- EventsRequest,
- 0);
+ tfc = lttv_traceset_context_get_current_tfc(tsc);
+ g_assert(g_slist_length(list_in)>0);
+ EventsRequest *events_request = g_slist_nth_data(list_in, 0);
/* 1.2.1 If first request in list_in is a time request */
if(events_request->start_position == NULL) {
- /* 1.2.1.1 Seek to that time */
- lttv_process_traceset_seek_time(tsc, events_request->start_time);
+ /* - If first req in list_in start time != current time */
+ if(tfc != NULL && ltt_time_compare(events_request->start_time,
+ tfc->timestamp) != 0)
+ /* - Seek to that time */
+ lttv_process_traceset_seek_time(tsc, events_request->start_time);
} else {
/* Else, the first request in list_in is a position request */
- /* 1.2.2.1 Seek to that position */
- lttv_process_traceset_seek_position(tsc, events_request->start_position);
+ /* If first req in list_in pos != current pos */
+ g_assert(events_request->start_position != NULL);
+ if(lttv_traceset_context_ctx_pos_compare(tsc,
+ events_request->start_position) != 0) {
+ /* 1.2.2.1 Seek to that position */
+ lttv_process_traceset_seek_position(tsc, events_request->start_position);
+ }
}
}
- /* 1.3 Call begin for all list_in members */
+ /* 1.3 Add hooks and call before request for all list_in members */
{
- guint i;
-
- for(i=0;i<list_in->len;i++) {
- EventsRequest *events_request = &g_array_index(list_in,
- EventsRequest,
- i);
- /* (1.3.1 begin hooks called) */
- /* (1.3.2 middle hooks added) */
- lttv_process_traceset_begin(tsc, events_request->before_traceset,
- events_request->before_trace,
- events_request->before_tracefile,
+ GSList *iter = NULL;
+
+ for(iter=list_in;iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
+ /* 1.3.1 If !servicing */
+ if(events_request->servicing == FALSE) {
+ /* - begin request hooks called
+ * - servicing = TRUE
+ */
+ lttv_hooks_call(events_request->before_request, NULL);
+ events_request->servicing = TRUE;
+ }
+ /* 1.3.2 call before chunk
+ * 1.3.3 events hooks added
+ */
+ lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
+ events_request->before_chunk_trace,
+ events_request->before_chunk_tracefile,
events_request->event,
events_request->event_by_id);
}
}
} else {
/* 2. Else, list_in is not empty, we continue a read */
- guint i;
+ GSList *iter = NULL;
tfc = lttv_traceset_context_get_current_tfc(tsc);
/* 2.1 For each req of list_out */
- for(i=0;i<list_out->len;i++) {
- EventsRequest *events_request = &g_array_index(list_out,
- EventsRequest,
- i);
- if(ltt_time_compare(events_request->start_time,
- tfc->timestamp) == 0) {
- /* if req.start time == current context time */
- /* Call Begin */
- lttv_process_traceset_begin(tsc, events_request->before_traceset,
- events_request->before_trace,
- events_request->before_tracefile,
+ for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
+
+ /* if req.start time == current context time
+ * or req.start position == current position*/
+ if( ltt_time_compare(events_request->start_time,
+ tfc->timestamp) == 0
+ ||
+ (events_request->start_position != NULL
+ &&
+ lttv_traceset_context_ctx_pos_compare(tsc,
+ events_request->start_position) == 0)
+ ) {
+ /* - Add to list_in, remove from list_out */
+ g_slist_append(list_in, events_request);
+ g_slist_remove(list_out, events_request);
+
+ /* - If !servicing */
+ if(events_request->servicing == FALSE) {
+ /* - begin request hooks called
+ * - servicing = TRUE
+ */
+ lttv_hooks_call(events_request->before_request, NULL);
+ events_request->servicing = TRUE;
+ }
+ /* call before chunk
+ * events hooks added
+ */
+ lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
+ events_request->before_chunk_trace,
+ events_request->before_chunk_tracefile,
events_request->event,
events_request->event_by_id);
-
-
- /* Add to list_in */
- g_array_append_val(list_in, *events_request);
- } else if(events_request->start_position != NULL &&
- lttv_traceset_context_ctx_pos_compare(tsc,
- events_request->start_position) == 0) {
- /* if req.start position == current position */
- /* Call Begin */
- lttv_process_traceset_begin(tsc, events_request->before_traceset,
- events_request->before_trace,
- events_request->before_tracefile,
- events_request->event,
- events_request->event_by_id);
-
-
- /* Add to list_in */
- g_array_append_val(list_in, *events_request);
-
- }
-
- }
-
-
- for(i=0;i<list_out->len;i++) {
- EventsRequest *events_request = &g_array_index(list_out,
- EventsRequest,
- i);
- if(ltt_time_compare(events_request->start_time,
- tfc->timestamp) == 0) {
- /* if req.start time == current context time */
- /* Remove from list_out */
- g_array_remove_index_fast(list_out, i);
- } else if(events_request->start_position != NULL &&
- lttv_traceset_context_ctx_pos_compare(tsc,
- events_request->start_position) == 0) {
- /* if req.start position == current position */
- /* Remove from list_out */
- g_array_remove_index_fast(list_out, i);
-
}
}
}
-
-
/* 3. Find end criterions */
{
/* 3.1 End time */
- guint i;
+ GSList *iter;
/* 3.1.1 Find lowest end time in list_in */
- end_time = g_array_index(list_in, EventsRequest,0).end_time;
+ g_assert(g_slist_length(list_in)>0);
+ end_time = ((EventsRequest*)g_slist_nth_data(list_in,0))->end_time;
- for(i=1;i<list_in->len;i++) {
- EventsRequest *events_request = &g_array_index(list_in,
- EventsRequest,
- i);
+ for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
+
if(ltt_time_compare(events_request->end_time,
end_time) < 0)
end_time = events_request->end_time;
}
/* 3.1.2 Find lowest start time in list_out */
- for(i=0;i<list_out->len;i++) {
- EventsRequest *events_request = &g_array_index(list_out,
- EventsRequest,
- i);
+ for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
+
if(ltt_time_compare(events_request->start_time,
end_time) < 0)
end_time = events_request->start_time;
/* 3.2 Number of events */
/* 3.2.1 Find lowest number of events in list_in */
- guint i;
+ GSList *iter;
+
+ end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,0))->num_events;
- end_nb_events = g_array_index(list_in, EventsRequest, 0).num_events;
+ for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
- for(i=1;i<list_in->len;i++) {
- EventsRequest *events_request = &g_array_index(list_in,
- EventsRequest,
- i);
if(events_request->num_events < end_nb_events)
end_nb_events = events_request->num_events;
}
+
+ /* 3.2.2 Use min(CHUNK_NUM_EVENTS, min num events in list_in) as
+ * num_events */
+
+ end_nb_events = MIN(CHUNK_NUM_EVENTS, end_nb_events);
}
{
/* 3.3 End position */
/* 3.3.1 Find lowest end position in list_in */
- guint i;
+ GSList *iter;
- end_position = g_array_index(list_in, EventsRequest, 0).end_position;
+ end_position =((EventsRequest*)g_slist_nth_data(list_in,0))->end_position;
- for(i=1;i<list_in->len;i++) {
- EventsRequest *events_request = &g_array_index(list_in,
- EventsRequest,
- i);
+ for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
- if(lttv_traceset_context_pos_pos_compare(events_request->end_position,
+ if(events_request->end_position != NULL && end_position != NULL &&
+ lttv_traceset_context_pos_pos_compare(events_request->end_position,
end_position) <0)
end_position = events_request->end_position;
}
{
/* 3.3.2 Find lowest start position in list_out */
- guint i;
+ GSList *iter;
- for(i=0;i<list_out->len;i++) {
- EventsRequest *events_request = &g_array_index(list_out,
- EventsRequest,
- i);
+ for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
+ EventsRequest *events_request = (EventsRequest*)iter->data;
- if(lttv_traceset_context_pos_pos_compare(events_request->end_position,
+ if(events_request->end_position != NULL && end_position != NULL &&
+ lttv_traceset_context_pos_pos_compare(events_request->end_position,
end_position) <0)
end_position = events_request->end_position;
}
}
+ {
+ /* 4. Call process traceset middle */
+ count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position);
+ }
+ {
+ /* 5. After process traceset middle */
+ tfc = lttv_traceset_context_get_current_tfc(tsc);
+
+ /* - if current context time > traceset.end time */
+ if(tfc == NULL || ltt_time_compare(tfc->timestamp,
+ tsc->time_span.end_time) > 0) {
+ /* - For each req in list_in */
+ GSList *iter = list_in;
+
+ while(iter != NULL) {
+
+ gboolean remove = FALSE;
+ gboolean free_data = FALSE;
+ EventsRequest *events_request = (EventsRequest *)iter->data;
+
+ /* - Remove events hooks for req
+ * - Call end chunk for req
+ */
+ lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
+ events_request->after_chunk_trace,
+ events_request->after_chunk_tracefile,
+ events_request->event,
+ events_request->event_by_id);
+ /* - Call end request for req */
+ lttv_hooks_call(events_request->after_request, NULL);
+
+ /* - remove req from list_in */
+ /* Destroy the request */
+ remove = TRUE;
+ free_data = TRUE;
+
+ /* Go to next */
+ if(remove)
+ {
+ GSList *remove_iter = iter;
+
+ iter = g_slist_next(iter);
+ if(free_data) g_free(remove_iter->data);
+ list_in = g_slist_remove_link(list_in, remove_iter);
+ } else { // not remove
+ iter = g_slist_next(iter);
+ }
+ }
+ }
+
+ {
+ /* 5.1 For each req in list_in */
+ GSList *iter = list_in;
+
+ while(iter != NULL) {
+ gboolean remove = FALSE;
+ gboolean free_data = FALSE;
+ EventsRequest *events_request = (EventsRequest *)iter->data;
+
+ /* - Remove events hooks for req
+ * - Call end chunk for req
+ */
+ lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
+ events_request->after_chunk_trace,
+ events_request->after_chunk_tracefile,
+ events_request->event,
+ events_request->event_by_id);
+
+ /* - req.num -= count */
+ g_assert(events_request->num_events >= count);
+ events_request->num_events -= count;
+
+ g_assert(tfc != NULL);
+ /* - if req.num == 0
+ * or
+ * current context time > req.end time
+ * or
+ * req.end pos == current pos
+ * or
+ * req.stop_flag == TRUE
+ */
+ if( events_request->num_events == 0
+ ||
+ events_request->stop_flag == TRUE
+ ||
+ ltt_time_compare(tfc->timestamp,
+ events_request->end_time) > 0
+ ||
+ (events_request->start_position != NULL
+ &&
+ lttv_traceset_context_ctx_pos_compare(tsc,
+ events_request->start_position) != 0)
+
+ ) {
+ /* - Call end request for req
+ * - remove req from list_in */
+ lttv_hooks_call(events_request->after_request, NULL);
+ /* - remove req from list_in */
+ /* Destroy the request */
+ remove = TRUE;
+ free_data = TRUE;
+ }
+
+ /* Go to next */
+ if(remove)
+ {
+ GSList *remove_iter = iter;
+
+ iter = g_slist_next(iter);
+ if(free_data) g_free(remove_iter->data);
+ list_in = g_slist_remove_link(list_in, remove_iter);
+ } else { // not remove
+ iter = g_slist_next(iter);
+ }
+ }
+ }
+ }
}
- /* B. When interrupted */
+ /* B. When interrupted between chunks */
- /* 1. for each request in list_in */
{
GSList *iter = list_in;
+ /* 1. for each request in list_in */
while(iter != NULL) {
gboolean remove = FALSE;
gboolean free_data = FALSE;
- EventsRequest events_request = (EventsRequest *)iter->data;
+ EventsRequest *events_request = (EventsRequest *)iter->data;
/* 1.1. Use current postition as start position */
g_free(events_request->start_position);
lttv_traceset_context_position_save(tsc, events_request->start_position);
/* 1.2. Remove start time */
- events_request->start_time = { G_MAXUINT, G_MAXUINT };
+ events_request->start_time.tv_sec = G_MAXUINT;
+ events_request->start_time.tv_nsec = G_MAXUINT;
- /* 1.3. Call after_traceset */
- /* 1.4. Remove event hooks */
- lttv_process_traceset_end(tsc, events_request->after_traceset,
- events_request->after_trace,
- events_request->after_tracefile,
- events_request->event,
- events_request->event_by_id);
-
- /* 1.5. Put it back in list_out */
+ /* 1.3. Move from list_in to list_out */
remove = TRUE;
free_data = FALSE;
list_out = g_slist_append(list_out, events_request);
-
/* Go to next */
if(remove)
{
}
- /* 2. Save current state into saved_state. */
- {
- /* 2.1 Free old saved state. */
- //FIXME : free will need to be able to remove state for a traceset
- //with changed traces!
- //FIXME lttv_state_state_saved_free( , tab->interrupted_state);
-
- /* 2.2 save current state. */
- //FIXME
- //lttv_state_save( ,tab->interrupted_state);
-
- }
-
//set the cursor back to normal
gdk_window_set_cursor(win, NULL);
-
- if( g_slist_length(list_in) == 0 && g_slist_length(list_out) == 0 ) {
+ g_assert(g_slist_length(list_in) == 0);
+ if( g_slist_length(list_out) == 0 ) {
/* Put tab's request pending flag back to normal */
- tab->time_request_pending = FALSE;
+ tab->events_request_pending = FALSE;
return FALSE; /* Remove the idle function */
}
-
return TRUE; /* Leave the idle function */
-
}
-#ifdef TESTCODE
- GSList *iter = list_in;
-
- /* 1. for each request in list_in */
- while(iter != NULL) {
-
- gboolean remove = FALSE;
- gboolean free_data = FALSE;
-
-
-
- /* Go to next */
- if(remove)
- {
- GSList *remove_iter = iter;
-
- iter = g_slist_next(iter);
- if(free_data) g_free(remove_iter->data);
- list_in = g_slist_remove_link(list_in, remove_iter);
- } else { // not remove
- iter = g_slist_next(iter);
- }
- }
-#endif //TESTCODE
-
/* add_trace_into_traceset_selector, each instance of a viewer has an associated
}
+static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v)
+{
+ LttvTraceset *traceset = tab->traceset_info->traceset;
+ guint i;
+
+ //Keep a reference to the traces so they are not freed.
+ for(i=0; i<lttv_traceset_number(traceset); i++)
+ {
+ LttvTrace * trace = lttv_traceset_get(traceset, i);
+ lttv_trace_ref(trace);
+ }
+
+ //remove state update hooks
+ lttv_state_remove_event_hooks(
+ (LttvTracesetState*)tab->traceset_info->traceset_context);
+
+ lttv_context_fini(LTTV_TRACESET_CONTEXT(
+ tab->traceset_info->traceset_context));
+ g_object_unref(tab->traceset_info->traceset_context);
+
+ lttv_traceset_add(traceset, trace_v);
+
+ /* Create new context */
+ tab->traceset_info->traceset_context =
+ g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+ lttv_context_init(
+ LTTV_TRACESET_CONTEXT(tab->traceset_info->
+ traceset_context),
+ traceset);
+ //add state update hooks
+ lttv_state_add_event_hooks(
+ (LttvTracesetState*)tab->traceset_info->traceset_context);
+ //Remove local reference to the traces.
+ for(i=0; i<lttv_traceset_number(traceset); i++)
+ {
+ LttvTrace * trace = lttv_traceset_get(traceset, i);
+ lttv_trace_unref(trace);
+ }
+
+ add_trace_into_traceset_selector(tab->multi_vpaned, lttv_trace(trace_v));
+}
+
/* add_trace adds a trace into the current traceset. It first displays a
* directory selection dialogue to let user choose a trace, then recreates
* tracset_context, and redraws all the viewer of the current tab
gint id;
gint i;
MainWindow * mw_data = get_window_data_struct(widget);
+ Tab *tab = mw_data->current_tab;
+
GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
gtk_dir_selection_hide_fileop_buttons(file_selector);
+
+ if(!tab) create_new_tab(widget, NULL);
+
if(remember_trace_dir[0] != '\0')
gtk_dir_selection_set_filename(file_selector, remember_trace_dir);
trace = ltt_trace_open(dir);
if(trace == NULL) g_critical("cannot open trace %s", dir);
trace_v = lttv_trace_new(trace);
- traceset = mw_data->current_tab->traceset_info->traceset;
-
- //Keep a reference to the traces so they are not freed.
- for(i=0; i<lttv_traceset_number(traceset); i++)
- {
- LttvTrace * trace = lttv_traceset_get(traceset, i);
- lttv_trace_ref(trace);
- }
- //remove state update hooks
- lttv_state_remove_event_hooks(
- (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
-
- lttv_context_fini(LTTV_TRACESET_CONTEXT(
- mw_data->current_tab->traceset_info->traceset_context));
- g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
-
-
- lttv_traceset_add(traceset, trace_v);
-
- /* Create new context */
- mw_data->current_tab->traceset_info->traceset_context =
- g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
- lttv_context_init(
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
- traceset_context),
- traceset);
- //add state update hooks
- lttv_state_add_event_hooks(
- (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
- //Remove local reference to the traces.
- for(i=0; i<lttv_traceset_number(traceset); i++)
- {
- LttvTrace * trace = lttv_traceset_get(traceset, i);
- lttv_trace_unref(trace);
- }
-
-
- add_trace_into_traceset_selector(mw_data->current_tab->multi_vpaned, trace);
+ lttvwindow_add_trace(tab, trace_v);
gtk_widget_destroy((GtkWidget*)file_selector);
//update current tab
//update_traceset(mw_data);
- //get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span);
- if(
- lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1
- || ltt_time_compare(mw_data->current_tab->current_time,
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
- traceset_context)->time_span.start_time)<0)
- {
- /* Set initial time if this is the first trace in the traceset */
- mw_data->current_tab->current_time =
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
- traceset_context)->time_span.start_time;
- mw_data->current_tab->time_window.start_time =
- mw_data->current_tab->current_time;
- mw_data->current_tab->time_window.time_width.tv_sec =
- DEFAULT_TIME_WIDTH_S;
- mw_data->current_tab->time_window.time_width.tv_nsec = 0;
- }
-
/* Call the updatetraceset hooks */
- SetTraceset(mw_data, (gpointer)traceset);
+ traceset = tab->traceset_info->traceset;
+ SetTraceset(tab, traceset);
// in expose now call_pending_read_hooks(mw_data);
- //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ //lttvwindow_report_current_time(mw_data,&(tab->current_time));
break;
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
gint i, j, nb_trace;
char ** name, *remove_trace_name;
MainWindow * mw_data = get_window_data_struct(widget);
+ Tab *tab = mw_data->current_tab;
LttvTracesetSelector * s;
LttvTraceSelector * t;
GtkWidget * w;
gboolean selected;
- nb_trace =lttv_traceset_number(mw_data->current_tab->traceset_info->traceset);
+ if(!tab) return;
+
+ nb_trace =lttv_traceset_number(tab->traceset_info->traceset);
name = g_new(char*,nb_trace);
for(i = 0; i < nb_trace; i++){
- trace_v = lttv_traceset_get(mw_data->current_tab->
- traceset_info->traceset, i);
+ trace_v = lttv_traceset_get(tab->traceset_info->traceset, i);
trace = lttv_trace(trace_v);
name[i] = ltt_trace_name(trace);
}
for(i=0; i<nb_trace; i++){
if(strcmp(remove_trace_name,name[i]) == 0){
//unselect the trace from the current viewer
- w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);
+ w = gtk_multi_vpaned_get_widget(tab->multi_vpaned);
if(w){
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
if(s){
}
//check if other viewers select the trace
- w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);
+ w = gtk_multi_vpaned_get_first_widget(tab->multi_vpaned);
while(w){
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
if(s){
selected = lttv_trace_selector_get_selected(t);
if(selected)break;
}
- w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);
+ w = gtk_multi_vpaned_get_next_widget(tab->multi_vpaned);
}
}else selected = FALSE;
//if no viewer selects the trace, remove it
if(!selected){
- remove_trace_from_traceset_selector(mw_data->current_tab->multi_vpaned, i);
+ remove_trace_from_traceset_selector(tab->multi_vpaned, i);
- traceset = mw_data->current_tab->traceset_info->traceset;
+ traceset = tab->traceset_info->traceset;
trace_v = lttv_traceset_get(traceset, i);
if(lttv_trace_get_ref_number(trace_v) <= 1)
ltt_trace_close(lttv_trace(trace_v));
//remove state update hooks
lttv_state_remove_event_hooks(
- (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
- lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context));
- g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
+ (LttvTracesetState*)tab->traceset_info->traceset_context);
+ lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context));
+ g_object_unref(tab->traceset_info->traceset_context);
lttv_traceset_remove(traceset, i);
if(!lttv_trace_get_ref_number(trace_v))
lttv_trace_destroy(trace_v);
- mw_data->current_tab->traceset_info->traceset_context =
+ tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
lttv_context_init(
- LTTV_TRACESET_CONTEXT(mw_data->current_tab->
+ LTTV_TRACESET_CONTEXT(tab->
traceset_info->traceset_context),traceset);
//add state update hooks
lttv_state_add_event_hooks(
- (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
+ (LttvTracesetState*)tab->traceset_info->traceset_context);
//Remove local reference to the traces.
for(j=0; j<lttv_traceset_number(traceset); j++)
SetTraceset(mw_data, (gpointer)traceset);
// in expose now call_pending_read_hooks(mw_data);
- //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ //lttvwindow_report_current_time(mw_data,&(tab->current_time));
}else{
- if(mw_data->current_tab){
- while(mw_data->current_tab->multi_vpaned->num_children){
- gtk_multi_vpaned_widget_delete(mw_data->current_tab->multi_vpaned);
+ if(tab){
+ while(tab->multi_vpaned->num_children){
+ gtk_multi_vpaned_widget_delete(tab->multi_vpaned);
}
}
}
LttTime current_time, time_delta, time_s, time_e, time_tmp;
MainWindow * mw_data = get_window_data_struct(widget);
Tab *tab = mw_data->current_tab;
- LttvTracesetContext *tsc =
- LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+ LttvTracesetContext *tsc;
+ if(tab==NULL) return;
if(size == 1) return;
+ tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
time_span = &tsc->time_span;
new_time_window = tab->time_window;
current_time = tab->current_time;
//lttvwindow_report_time_window(mw_data, &new_time_window);
//call_pending_read_hooks(mw_data);
- //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ //lttvwindow_report_current_time(mw_data,&(tab->current_time));
set_time_window(tab, &new_time_window);
// in expose now call_pending_read_hooks(mw_data);
gtk_multi_vpaned_set_adjust(tab->multi_vpaned, &new_time_window, FALSE);
void create_new_tab(GtkWidget* widget, gpointer user_data){
gchar label[PATH_LENGTH];
MainWindow * mw_data = get_window_data_struct(widget);
+
GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook");
if(notebook == NULL){
g_printf("Notebook does not exist\n");
return;
}
-
+
+
strcpy(label,"Page");
if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name"))
- create_tab (NULL, mw_data, notebook, label);
+ create_tab (mw_data, NULL, notebook, label);
}
void
}
-/* remove the current tab from the main window if it is not the default tab
+/* remove the current tab from the main window
*/
void
on_close_tab_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- GList * list;
- int count = 0;
+ gint page_num;
GtkWidget * notebook;
- Tab * tmp;
+ GtkWidget * page;
MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
notebook = lookup_widget((GtkWidget*)menuitem, "MNotebook");
if(notebook == NULL){
g_printf("Notebook does not exist\n");
return;
}
+
+ page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
- if(mw_data->tab == mw_data->current_tab){
- // tmp = mw_data->current_tb;
- // mw_data->tab = mw_data->current_tab->next;
- g_printf("The default TAB can not be deleted\n");
- return;
- }else{
- tmp = mw_data->tab;
- while(tmp != mw_data->current_tab){
- tmp = tmp->next;
- count++;
- }
- }
+ gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), page_num);
- gtk_notebook_remove_page((GtkNotebook*)notebook, count);
- list = gtk_container_get_children(GTK_CONTAINER(notebook));
- if(g_list_length(list)==1)
- gtk_notebook_set_show_tabs((GtkNotebook*)notebook, FALSE);
+ if( gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)) == 0 )
+ mw_data->current_tab = NULL;
+ else {
+ page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
+ gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
+ mw_data->current_tab =
+ (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+ }
}
{
MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
LttvTracesetSelector * s;
- GtkWidget * w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);
+ Tab *tab = mw_data->current_tab;
+ GtkWidget * w;
+
+ if(tab == NULL) return ;
+
+ w = gtk_multi_vpaned_get_widget(tab->multi_vpaned);
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
if(!s){
//FIXME report filter change
//update_traceset(mw_data);
//call_pending_read_hooks(mw_data);
- //lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
+ //lttvwindow_report_current_time(mw_data,&(tab->current_time));
}
}
}
void
-on_MWindow_destroy (GtkObject *object,
+on_MWindow_destroy (GtkWidget *widget,
gpointer user_data)
{
- MainWindow *main_window = get_window_data_struct((GtkWidget*)object);
- GtkWidget *widget;
- Tab *tab = main_window->tab;
+ MainWindow *main_window = get_window_data_struct(widget);
LttvIAttribute *attributes = main_window->attributes;
LttvAttributeValue value;
g_assert(lttv_iattribute_find_by_path(attributes,
"viewers/toolbar", LTTV_POINTER, &value));
lttv_toolbars_destroy((LttvToolbars*)*(value.v_pointer));
-
- while(main_window->tab){
- lttv_state_remove_event_hooks(
- (LttvTracesetState*)main_window->tab->traceset_info->traceset_context);
- main_window->tab = main_window->tab->next;
- }
+
g_object_unref(main_window->attributes);
g_main_window_list = g_slist_remove(g_main_window_list, main_window);
- g_win_count--;
g_printf("There are now : %d windows\n",g_slist_length(g_main_window_list));
- if(g_win_count == 0)
+ if(g_slist_length(g_main_window_list) == 0)
gtk_main_quit ();
}
add_all_menu_toolbar_constructors(new_m_window, NULL);
- g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window);
+ g_object_set_data_full(G_OBJECT(new_window),
+ "main_window_data",
+ (gpointer)new_m_window,
+ (GDestroyNotify)g_free);
//create a default tab
notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
if(notebook == NULL){
}
//for now there is no name field in LttvTraceset structure
//Use "Traceset" as the label for the default tab
- create_tab(parent, new_m_window, notebook, "Traceset");
-
- g_object_set_data_full(
- G_OBJECT(new_m_window->mwindow),
- "Main_Window_Data",
- new_m_window,
- NULL);
+ if(parent)
+ create_tab(new_m_window, parent->current_tab, notebook, "Traceset");
+ else {
+ create_tab(new_m_window, NULL, notebook, "Traceset");
+ if(g_init_trace != NULL){
+ lttvwindow_add_trace(new_m_window->current_tab,
+ g_init_trace);
+ }
+ }
- g_win_count++;
g_printf("There are now : %d windows\n",g_slist_length(g_main_window_list));
}
/* Create a tab and insert it into the current main window
*/
-void * create_tab(MainWindow * parent, MainWindow* current_window,
+void * create_tab(MainWindow * mw, Tab *copy_tab,
GtkNotebook * notebook, char * label)
{
GList * list;
Tab * tmp_tab;
- MainWindow * mw_data = current_window;
LttTime tmp_time;
//create a new tab data structure
- tmp_tab = mw_data->tab;
+ tmp_tab = mw->tab;
while(tmp_tab && tmp_tab->next) tmp_tab = tmp_tab->next;
if(!tmp_tab){
- mw_data->current_tab = NULL;
+ mw->current_tab = NULL;
tmp_tab = g_new(Tab,1);
- mw_data->tab = tmp_tab;
+ mw->tab = tmp_tab;
}else{
tmp_tab->next = g_new(Tab,1);
tmp_tab = tmp_tab->next;
//construct and initialize the traceset_info
tmp_tab->traceset_info = g_new(TracesetInfo,1);
- if(parent){
- if(parent->current_tab){
- tmp_tab->traceset_info->traceset =
- lttv_traceset_new();
- //FIXME lttv_traceset_copy(parent->current_tab->traceset_info->traceset);
- }else{
- tmp_tab->traceset_info->traceset = lttv_traceset_new();
- }
- }else{ /* Initial window */
- if(mw_data->current_tab){
- tmp_tab->traceset_info->traceset =
- lttv_traceset_new();
- //FIXME lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset);
- }else{
- tmp_tab->traceset_info->traceset = lttv_traceset_new();
- /* Add the command line trace */
- if(g_init_trace != NULL){
- lttv_traceset_add(tmp_tab->traceset_info->traceset, g_init_trace);
- }
- }
+ if(copy_tab) {
+ tmp_tab->traceset_info->traceset =
+ lttv_traceset_copy(copy_tab->traceset_info->traceset);
+ } else {
+ tmp_tab->traceset_info->traceset = lttv_traceset_new();
}
-
+
+//FIXME : this is g_debug level
+ lttv_attribute_write_xml(
+ lttv_traceset_attribute(tmp_tab->traceset_info->traceset),
+ stdout,
+ 0, 4);
+ fflush(stdout);
+
+
//FIXME copy not implemented in lower level
tmp_tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
(LttvTracesetState*)tmp_tab->traceset_info->traceset_context);
//determine the current_time and time_window of the tab
- if(mw_data->current_tab){
+ if(mw->current_tab){
// Will have to read directly at the main window level, as we want
// to be able to modify a traceset on the fly.
- tmp_tab->time_window = mw_data->current_tab->time_window;
- tmp_tab->current_time = mw_data->current_tab->current_time;
+ tmp_tab->time_window = mw->current_tab->time_window;
+ tmp_tab->current_time = mw->current_tab->current_time;
}else{
// Will have to read directly at the main window level, as we want
// to be able to modify a traceset on the fly.
LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->time_span.start_time.tv_nsec;
}
/* Become the current tab */
- mw_data->current_tab = tmp_tab;
+ mw->current_tab = tmp_tab;
tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
tmp_tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
tmp_tab->multi_vpaned = (GtkMultiVPaned*)gtk_multi_vpaned_new();
- tmp_tab->multi_vpaned->tab = mw_data->current_tab;
+ tmp_tab->multi_vpaned->tab = mw->current_tab;
gtk_widget_show((GtkWidget*)tmp_tab->multi_vpaned);
tmp_tab->next = NULL;
- tmp_tab->mw = mw_data;
+ tmp_tab->mw = mw;
tmp_tab->label = gtk_label_new (label);
gtk_widget_show (tmp_tab->label);
LttvAttributeValue value;
LttvHooks * tmp;
int i;
- LttvTracesetContext * tsc =
- (LttvTracesetContext*)main_win->current_tab->
- traceset_info->traceset_context;
+ LttvTracesetContext * tsc;
+ Tab *tab = main_win->current_tab;
+
+ if(tab == NULL) return ;
+
+ tsc =(LttvTracesetContext*)tab->traceset_info->traceset_context;
- g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+ g_assert(lttv_iattribute_find_by_path(tab->attributes,
"hooks/showviewer", LTTV_POINTER, &value));
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL)