insertion and removal will be done between each traceset processing based on
the time intervals and event positions related to each hook. We must therefore
provide a simple interface for hooks passing between the viewers and the main
-window, make them easier to manage from the main window. A modification to the
+window, making them easier to manage from the main window. A modification to the
LttvHooks type solves this problem.
Permitted GTK Events Between Chunks
-All GTK Events will be enabled between chunks. This is due to the fact that the
-background processing and a high priority request are seen as the same case.
-While a background processing is in progress, the whole graphical interface must
-be enabled.
+All GTK Events will be enabled between chunks. A viewer could ask for a
+long computation that has no impact on the display : in that case, it is
+necessary to keep the graphical interface active. While a processing is in
+progress, the whole graphical interface must be enabled.
We needed to deal with the coherence of background processing and diverse GTK
events anyway. This algorithm provides a generalized way to deal with any type
Background Computation Request
-The types of background computation that can be requested by a viewer : state
-computation (main window scope) or viewer specific background computation.
-
+A background computation has a trace scope, and is therefore not linked to a
+main window. It is not detailed in this document.
+see requests_servicing_schedulers.txt
A New "Redraw" Button
LttTime end_time;/* Unset : { G_MAXUINT, G_MAXUINT } */
guint num_events; /* Unset : G_MAXUINT */
LttvTracesetContextPosition *end_position; /* Unset : NULL */
- LttvHooks *before_traceset; /* Unset : NULL */
- LttvHooks *before_trace; /* Unset : NULL */
- LttvHooks *before_tracefile;/* Unset : NULL */
+ LttvHooks *before_chunk_traceset; /* Unset : NULL */
+ LttvHooks *before_chunk_trace; /* Unset : NULL */
+ LttvHooks *before_chunk_tracefile;/* Unset : NULL */
LttvHooks *event; /* Unset : NULL */
LttvHooksById *event_by_id; /* Unset : NULL */
- LttvHooks *after_tracefile; /* Unset : NULL */
- LttvHooks *after_trace; /* Unset : NULL */
- LttvHooks *after_traceset; /* Unset : NULL */
+ LttvHooks *after_chunk_tracefile; /* Unset : NULL */
+ LttvHooks *after_chunk_trace; /* Unset : NULL */
+ LttvHooks *after_chunk_traceset; /* Unset : NULL */
LttvHooks *before_request; /* Unset : NULL */
- LttvHooks *after_request /* Unset : NULL */
+ LttvHooks *after_request; /* Unset : NULL */
} EventsRequest;
+
- lttvwindow_events_request_remove_all
It removes all the events requests from the pool that has their "owner" field
list_out : many events requests
-// NOT A. While (list_in !empty or list_out !empty) and !GTK Event pending
-
-We do this once, go back to GTK, then get called again...
-We remove the g_idle function when list_in and list_out are empty
-
+A. While (list_in !empty or list_out !empty) and !GTK Event pending
1. If list_in is empty (need a seek)
1.1 Add requests to list_in
1.1.1 Find all time requests with lowest start time in list_out (ltime)
2. Else, list_in is not empty, we continue a read
2.1 For each req of list_out
- if req.start time == current context time
+ or req.start position == current position
- Add to list_in, remove from list_out
- If !servicing
- Call before request
- servicing = TRUE
- Call before chunk
- events hooks added
- - if req.start position == current position
- - Add to list_in, remove from list_out
- - If !servicing
- - Call before request
- - servicing = TRUE
- - Call before_chunk
- - events hooks added
3. Find end criterions
3.1 End time
3.3 End position
3.3.1 Find lowest end position in list_in
3.3.2 Find lowest start position in list_out (>= than current
- position)
+ position *not used)
3.3.3 Use lowest of both as end position
4. Call process traceset middle
- Call end request for req
- remove req from list_in
5.1 For each req in list_in
+ - Call end chunk for req
+ - Remove events hooks for req
- req.num -= count
- - if req.num == 0
- - Remove events hooks for req
- - Call end chunk for req
- - Call end request for req
- - remove req from list_in
- - if current context time > req.end time
- - Remove events hooks for req
- - Call end chunk for req
- - Call end request for req
- - remove req from list_in
- - if req.end pos == current pos
- - Remove events hooks for req
- - Call end_chunk for req
- - Call end request for req
- - remove req from list_in
- - if req.stop_flag == TRUE
- - Remove events hooks for req
- - Call end chunk for req
+ - if req.num == 0
+ or
+ current context time > req.end time
+ or
+ req.end pos == current pos
+ or
+ req.stop_flag == TRUE
- Call end request for req
- remove req from list_in
-B. Between each chunk (interrupted or not)
+B. When interrupted between chunks
1. for each request in list_in
1.1. Use current postition as start position
1.2. Remove start time
- 1.3. Call after_chunk_traceset
- 1.4. Remove event hooks
- 1.5. Put it back in list_out
+ 1.3. Move from list_in to list_out
list_in : currently serviced requests
list_out : queue of requests waiting for processing
+notification lists :
+notify_in : currently checked notifications
+notify_out : queue of notifications that comes along with next processing.
+
1. Before processing
if list_in is empty
- add hooks to context
- set hooks'in_progress flag to TRUE
- seek trace to start
+ - Move all notifications from notify_out to notify_in.
2. call process traceset middle for a chunk
(assert list_in is not empty! : should not even be called in that case)
3. After the chunk
3.1 call after_chunk hooks from list_in
+ 3.2 for each notify_in
+ - if current time >= notify time, call notify and remove from notify_in
+ - if current position >= notify position, call notify and remove from
+ notify_in
3.2 if end of trace reached
- for each request in list_in
- set hooks'in_progress flag to FALSE
- set hooks'ready flag to TRUE
- - call end request
- remove hooks from context
- remove request
+ - for each notifications in notify_in
+ - call notify and remove from notify_in
- return FALSE (scheduler stopped)
3.3 else
- return TRUE (scheduler still registered)
}
-void lttv_state__state_saved_free(LttvTraceState *self,
+void lttv_state_state_saved_free(LttvTraceState *self,
LttvAttribute *container)
{
LTTV_TRACE_STATE_GET_CLASS(self)->state_saved_free(self, container);
}
struct _LttvTraceContextPosition {
- LttEventPosition **tf_pos; /* Position in each trace */
+ LttEventPosition **tf_pos; /* Position in each tracefile */
guint nb_tracefile; /* Number of tracefiles (check) */
};
struct _LttvTracesetContextPosition {
- LttvTraceContextPosition *t_pos; /* Position in each trace */
+ LttvTraceContextPosition *t_pos; /* Position in each trace */
guint nb_trace; /* Number of traces (check) */
+ LttTime timestamp; /* Current time at the saved position */
};
void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts)
tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
}
}
+ self->pqueue = g_tree_new(compare_tracefile);
lttv_process_traceset_seek_time(self, null_time);
lttv_traceset_context_compute_time_span(self, &self->time_span);
- self->pqueue = g_tree_new(compare_tracefile);
}
LttEvent *event;
+ LttTime timestamp = self->time_span.end_time;
+
pos->nb_trace = nb_trace = lttv_traceset_number(self->ts);
pos->t_pos = g_new(LttvTraceContextPosition, nb_trace);
event = tfc->e;
ltt_event_position(event,
pos->t_pos[iter_trace].tf_pos[iter_tracefile]);
+ if(ltt_time_compare(tfc->timestamp, timestamp) < 0)
+ timestamp = tfc->timestamp;
}
}
+ pos->timestamp = timestamp;
}
void lttv_traceset_context_position_destroy(LttvTracesetContextPosition *pos)
}
+LttTime lttv_traceset_context_position_get_time(
+ const LttvTracesetContextPosition *pos)
+{
+ return pos->timestamp;
+}
+
+
+LttvTracefileContext *lttv_traceset_context_get_current_tfc(LttvTracesetContext *self)
+{
+ GTree *pqueue = self->pqueue;
+ LttvTracefileContext *tfc;
+
+ g_tree_foreach(pqueue, get_first, &tfc);
+
+ return tfc;
+}
char *field1, char *field2, char *field3, LttvHook h, LttvTraceHook *th);
+LttvTracefileContext *lttv_traceset_context_get_current_tfc(
+ LttvTracesetContext *self);
+
void lttv_traceset_context_position_save(const LttvTracesetContext *self,
LttvTracesetContextPosition *pos);
gint lttv_traceset_context_pos_pos_compare(const LttvTracesetContextPosition *a,
const LttvTracesetContextPosition *b);
+LttTime lttv_traceset_context_position_get_time(
+ const LttvTracesetContextPosition *pos);
#endif // PROCESSTRACE_H
struct _ControlFlowData {
GtkWidget *scrolled_window;
- MainWindow *mw;
+ Tab *tab;
GtkWidget *h_paned;
#define _CFV_H
#include <gtk/gtk.h>
-#include <lttvwindow/common.h>
#include <lttvwindow/mainwindow.h>
#include "processlist.h"
#include <lttv/lttv.h>
#include <lttv/tracecontext.h>
-#include <lttvwindow/viewer.h>
+#include <lttvwindow/lttvwindow.h>
#include <lttv/state.h>
#include <lttv/hook.h>
#include <lttv/lttv.h>
#include <lttv/hook.h>
-#include <lttvwindow/common.h>
#include <lttv/state.h>
-#include <lttvwindow/viewer.h>
+#include <lttvwindow/lttvwindow.h>
#include "eventhooks.h"
#include <glib.h>
#include <lttv/lttv.h>
#include <lttv/module.h>
-#include <lttvwindow/viewer.h>
+#include <lttvwindow/lttvwindow.h>
#include "cfv.h"
#include "eventhooks.h"
noinst_HEADERS = \
support.h \
interface.h \
- callbacks.h
+ callbacks.h\
+ mainwindow-private.h
lttvwindowinclude_HEADERS = \
- common.h\
gtkdirsel.h\
gtkmultivpaned.h\
lttvwindow.h\
#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] = "";
void * create_tab(MainWindow * parent, MainWindow * current_window,
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,
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);
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 = g_array_index(list_in, EventsRequest, 0).num_events;
+ end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,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
/* Call the updatetraceset hooks */
- SetTraceset(mw_data, (gpointer)traceset);
+ SetTraceset(mw_data->current_tab, traceset);
// in expose now call_pending_read_hooks(mw_data);
//lttvwindow_report_current_time(mw_data,&(mw_data->current_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){
//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);
-
- g_win_count++;
g_printf("There are now : %d windows\n",g_slist_length(g_main_window_list));
}
*/
#include <gtk/gtk.h>
-#include <lttvwindow/common.h>
#include <lttvwindow/mainwindow.h>
/* internal functions */
void main_window_destructor(MainWindow * mw);
void show_viewer(MainWindow *main_win);
+void insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data);
+gboolean execute_events_requests(Tab *tab);
+
/* callback functions*/
gpointer user_data);
void
-on_MWindow_destroy (GtkObject *object,
+on_MWindow_destroy (GtkWidget *widget,
gpointer user_data);
gboolean
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu Yang
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License Version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <stdio.h>
-#include <ltt/ltt.h>
-#include <gtk/gtk.h>
-#include <lttvwindow/lttvfilter.h>
-
-#define MAX_NUMBER_EVENT "MAX_NUMBER_EVENT"
-#define TRACESET_TIME_SPAN "TRACESET_TIME_SPAN"
-
-typedef struct _MainWindow MainWindow;
-typedef struct _Tab Tab;
-
-typedef struct _TimeWindow {
- LttTime start_time;
- LttTime time_width;
-} TimeWindow;
-
-#endif // COMMON_H
#include <gtk/gtk.h>
#include <lttvwindow/gtkmultivpaned.h>
-//#include "gtkintl.h"
#include <lttvwindow/mainwindow.h>
-#include <lttvwindow/lttvwindow.h>
+#include <lttvwindow/mainwindow-private.h>
+//#include "gtkintl.h"
static void gtk_multi_vpaned_class_init (GtkMultiVPanedClass *klass);
static void gtk_multi_vpaned_init (GtkMultiVPaned *multi_vpaned);
{
TimeInterval *time_span;
double len, start;
+ Tab *tab = (Tab*)multi_vpaned->tab;
LttvTracesetContext *tsc =
- LTTV_TRACESET_CONTEXT(multi_vpaned->tab->traceset_info->traceset_context);
+ LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
if(first_time){
{
GtkPaned * tmpPane;
GtkWidget * w;
+ Tab *tab = (Tab*)multi_vpaned->tab;
g_return_if_fail(GTK_IS_MULTI_VPANED(multi_vpaned));
g_object_ref(G_OBJECT(widget1));
gtk_widget_show(multi_vpaned->hscrollbar);
multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar));
- gtk_multi_vpaned_set_adjust(multi_vpaned, &multi_vpaned->tab->time_window, TRUE);
+ gtk_multi_vpaned_set_adjust(multi_vpaned, &tab->time_window, TRUE);
gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar),
GTK_UPDATE_CONTINUOUS);
GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg;
gdouble value = gtk_adjustment_get_value(adjust);
gdouble upper, lower, ratio;
+ Tab *tab = (Tab*)multi_vpaned->tab;
LttvTracesetContext * tsc =
- LTTV_TRACESET_CONTEXT(multi_vpaned->tab->traceset_info->traceset_context);
+ LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
- time_window = multi_vpaned->tab->time_window;
+ time_window = tab->time_window;
time_span = &tsc->time_span ;
lower = multi_vpaned->hadjust->lower;
if(ltt_time_compare(time,time_window.time_width) < 0){
time_window.time_width = time;
}
- set_time_window(multi_vpaned->tab, &time_window);
+ set_time_window(tab, &time_window);
}
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gtk/gtkcontainer.h>
-#include <lttvwindow/common.h>
+#include <lttvwindow/mainwindow.h>
+
#ifdef __cplusplus
extern "C" {
#define GTK_IS_MULTI_VPANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MULTI_VPANED))
#define GTK_MULTI_VPANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MULTI_VPANED, GtkMultiVPanedClass))
-
typedef struct _GtkMultiVPaned GtkMultiVPaned;
typedef struct _GtkMultiVPanedClass GtkMultiVPanedClass;
// GtkWidget * viewport;
GtkWidget * hscrollbar;
GtkAdjustment *hadjust;
- MainWindow * mw;
+ Tab *tab;
};
struct _GtkMultiVPanedClass
#include "interface.h"
#include "support.h"
#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/mainwindow-private.h>
#include "callbacks.h"
#include <ltt/trace.h>
LTTV_POINTER, &value));
g_assert((main_hooks = *(value.v_pointer)) != NULL);
- lttv_hooks_add(main_hooks, window_creation_hook, NULL);
+ lttv_hooks_add(main_hooks, window_creation_hook, NULL, LTTV_PRIO_DEFAULT);
}
void
main_window_destructor(MainWindow * mw)
{
- if(GTK_IS_WIDGET(mw->mwindow)){
- gtk_widget_destroy(mw->mwindow);
- mw = NULL;
- }
-}
-
-
-void main_window_destroy_walk(gpointer data, gpointer user_data)
-{
- main_window_destructor((MainWindow*)data);
+ g_assert(GTK_IS_WIDGET(mw->mwindow));
+ gtk_widget_destroy(mw->mwindow);
}
-
/**
* plugin's destroy function
*
LttvAttributeValue value;
LttvTrace *trace;
-
+ GSList *iter = NULL;
+
lttv_option_remove("trace");
lttv_hooks_remove_data(main_hooks, window_creation_hook, NULL);
g_debug("GUI destroy()");
if(g_main_window_list){
- g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
+ for(iter=g_main_window_list;iter!=NULL;iter=g_slist_next(iter)) {
+ main_window_destructor((MainWindow*)iter->data);
+ }
g_slist_free(g_main_window_list);
}
LTTV_MODULE("lttvwindow", "Viewer main window", \
"Viewer with multiple windows, tabs and panes for graphical modules", \
- init, destroy, "stats")
+ init, destroy, "stats", "option")
#include <lttv/state.h>
#include <lttv/stats.h>
#include <lttv/tracecontext.h>
-#include <lttvwindow/common.h>
#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/mainwindow-private.h>
#include <lttvwindow/lttvwindow.h>
#include <lttvwindow/toolbar.h>
#include <lttvwindow/menu.h>
* 1 : no traceset hooks to update; not an error.
*/
-int SetTraceset(Tab * tab, gpointer traceset)
+int SetTraceset(Tab * tab, LttvTraceset *traceset)
{
LttvHooks * tmp;
LttvAttributeValue value;
void lttvwindow_events_request(Tab *tab,
const EventsRequest *events_request)
{
- EventsRequest *alloc = g_new(sizeof(EventsRequest,1));
+ EventsRequest *alloc = g_new(EventsRequest,1);
*alloc = *events_request;
tab->events_requests = g_slist_append(tab->events_requests, alloc);
gint find_viewer (const EventsRequest *a, gconstpointer b)
{
- return (a->viewer != b);
+ return (a->owner != b);
}
g_slist_find_custom(tab->events_requests, viewer,
(GCompareFunc)find_viewer))
!= NULL) {
- EventRequest *events_request = (EventsRequest *)element->data;
+ EventsRequest *events_request = (EventsRequest *)element->data;
if(events_request->servicing == TRUE) {
lttv_hooks_call(events_request->after_request, NULL);
}
Module Related API
-A viewer plugin is, before anything, a plugin. As a dynamically loadable
+A viewer plugin is, before anything, a plugin. As a dynamically loadable
module, it thus has an init and a destroy function called whenever it is
loaded/initialized and unloaded/destroyed. A graphical module depends on
-lttvwindow for construction of its viewer instances. In order to achieve this,
-it must register its constructor function to the main window along with
-button description or text menu entry description. A module keeps a list of
-every viewer that currently sits in memory so it can destroy them before the
-module gets unloaded/destroyed.
+lttvwindow for construction of its viewer instances. In order to achieve
+this, it must register its constructor function to the main window along
+with button description or text menu entry description. A module keeps
+a list of every viewer that currently sits in memory so it can destroy
+them before the module gets unloaded/destroyed.
-The contructor registration to the main windows adds button and menu entry
-to each main window, thus allowing instanciation of viewers.
+The contructor registration to the main windows adds button and menu
+entry to each main window, thus allowing instanciation of viewers.
Main Window
-The main window is a container that offers menus, buttons and a notebook. Some
-of those menus and buttons are part of the core of the main window, others
-are dynamically added and removed when modules are loaded/unloaded.
+The main window is a container that offers menus, buttons and a
+notebook. Some of those menus and buttons are part of the core of the
+main window, others are dynamically added and removed when modules are
+loaded/unloaded.
-The notebook contains as much tabs as wanted. Each tab is linked with a
-set of traces (traceset). Each trace contains many tracefiles (one per cpu).
-A trace corresponds to a kernel being traced. A traceset corresponds to
-many traces read together. The time span of a traceset goes from the
-earliest start of all the traces to the latest end of all the traces.
+The notebook contains as much tabs as wanted. Each tab is linked with
+a set of traces (traceset). Each trace contains many tracefiles (one
+per cpu). A trace corresponds to a kernel being traced. A traceset
+corresponds to many traces read together. The time span of a traceset
+goes from the earliest start of all the traces to the latest end of all
+the traces.
Inside each tab are added the viewers. When they interact with the main
window through the lttvwindow API, they affect the other viewers located
in the same tab as they are.
The insertion of many viewers in a tab permits a quick look at all the
-information wanted in a glance. The main window does merge the read requests
-from all the viewers in the same tab in a way that every viewer will get exactly
-the events it asked for, while the event reading loop and state update are
-shared. It improves performance of events delivery to the viewers.
+information wanted in a glance. The main window does merge the read
+requests from all the viewers in the same tab in a way that every viewer
+will get exactly the events it asked for, while the event reading loop
+and state update are shared. It improves performance of events delivery
+to the viewers.
Viewer Instance Related API
-The lifetime of a viewer is as follows. The viewer constructor function is
-called each time an instance view is created (one subwindow of this viewer
-type is created by the user either by clicking on the menu item or the button
-corresponding to the viewer). Thereafter, the viewer gets hooks called for
-different purposes by the window containing it. These hooks are detailed
-below. It also has to deal with GTK Events. Finally, it can be destructed by
-having its top level widget unreferenced by the main window or by any
-GTK Event causing a "destroy-event" signal on the its top widget. Another
-possible way for it do be destroyed is if the module gets unloaded. The module
-unload function will have to emit a "destroy" signal on each top level widget
-of all instances of its viewers.
+The lifetime of a viewer is as follows. The viewer constructor function
+is called each time an instance view is created (one subwindow of this
+viewer type is created by the user either by clicking on the menu item
+or the button corresponding to the viewer). Thereafter, the viewer gets
+hooks called for different purposes by the window containing it. These
+hooks are detailed below. It also has to deal with GTK Events. Finally,
+it can be destructed by having its top level widget unreferenced by the
+main window or by any GTK Event causing a "destroy-event" signal on the
+its top widget. Another possible way for it do be destroyed is if the
+module gets unloaded. The module unload function will have to emit a
+"destroy" signal on each top level widget of all instances of its viewers.
Notices from Main Window
Reporting Changes to the Main Window
-In most cases, the enclosing window knows about updates such as described in the
-Notification section higher. There are a few cases, however, where updates are
-caused by actions known by a view instance. For example, clicking in a view may
-update the current time; all viewers within the same window must be told about
-the new current time to change the currently highlighted time point. A viewer
-reports such events by calling lttvwindow_report_current_time on its lttvwindow.
-The lttvwindow will consequently call current_time_notify for each of its
-contained viewers.
+In most cases, the enclosing window knows about updates such as described
+in the Notification section higher. There are a few cases, however, where
+updates are caused by actions known by a view instance. For example,
+clicking in a view may update the current time; all viewers within
+the same window must be told about the new current time to change the
+currently highlighted time point. A viewer reports such events by calling
+lttvwindow_report_current_time on its lttvwindow. The lttvwindow will
+consequently call current_time_notify for each of its contained viewers.
Available report methods are :
Requesting Events to Main Window
-Events can be requested by passing a EventsRequest structure to the main window.
-They will be delivered later when the next g_idle functions will be called.
-Event delivery is done by calling the event hook for this event ID, or the
-main event hooks. A pointer to the EventsRequest structure is passed as
-hook_data to the event hooks of the viewers.
+Events can be requested by passing a EventsRequest structure to the main
+window. They will be delivered later when the next g_idle functions
+will be called. Event delivery is done by calling the event hook for
+this event ID, or the main event hooks. A pointer to the EventsRequest
+structure is passed as hook_data to the event hooks of the viewers.
EventsRequest consists in
- a pointer to the viewer specific data structure
- hook lists to call for traceset/trace/tracefile begin and end, and for each
event (event hooks and event_by_id hooks).
-The main window will deliver events for every EventRequests it has pending
-through an algorithm that guarantee that all events requested, and only them,
-will be delivered to the viewer between the call of the tracefile_begin hooks
-and the call of the tracefile_end hooks.
+The main window will deliver events for every EventRequests it has
+pending through an algorithm that guarantee that all events requested,
+and only them, will be delivered to the viewer between the call of the
+tracefile_begin hooks and the call of the tracefile_end hooks.
-If a viewer wants to stop the event request at a certain point inside the event
-hooks, it has to set the stop_flag to TRUE and return TRUE from the hook
-function. Then return value will stop the process traceset. Then, the main
-window will look for the stop_flag and remove the EventRequests from its lists,
-calling the process_traceset_end for this request (it removes hooks from the
-context and calls the after hooks).
+If a viewer wants to stop the event request at a certain point inside the
+event hooks, it has to set the stop_flag to TRUE and return TRUE from the
+hook function. Then return value will stop the process traceset. Then,
+the main window will look for the stop_flag and remove the EventRequests
+from its lists, calling the process_traceset_end for this request (it
+removes hooks from the context and calls the after hooks).
-It no stop_flag is rose, the end timestamp, end position or number of events to
-read has to be reached to determine the end of the request. Otherwise,
-the end of traceset does determine it.
+It no stop_flag is rose, the end timestamp, end position or number
+of events to read has to be reached to determine the end of the
+request. Otherwise, the end of traceset does determine it.
GTK Events
Events and Signals
-GTK is quite different from the other graphical toolkits around there. The main
-difference resides in that there are many X Windows inside one GtkWindow,
-instead of just one. That means that X events are delivered by the glib main
-loop directly to the widget corresponding to the GdkWindow affected by the X
-event.
+GTK is quite different from the other graphical toolkits around
+there. The main difference resides in that there are many X Windows
+inside one GtkWindow, instead of just one. That means that X events are
+delivered by the glib main loop directly to the widget corresponding to
+the GdkWindow affected by the X event.
-Event delivery to a widget emits a signal on that widget. Then, if a handler
-is connected to this widget's signal, it will be executed. There are default
-handlers for signals, connected at class instantiation time. There is also
-the possibility to connect other handlers to these signals, which is what
-should be done in most cases when a viewer needs to interact with X in any
-way.
+Event delivery to a widget emits a signal on that widget. Then, if a
+handler is connected to this widget's signal, it will be executed. There
+are default handlers for signals, connected at class instantiation
+time. There is also the possibility to connect other handlers to these
+signals, which is what should be done in most cases when a viewer needs
+to interact with X in any way.
Provides the exposed region in the GdkEventExpose structure.
-There are two ways of dealing with exposures. The first one is to directly draw
-on the screen and the second one is to draw in a pixmap buffer, and then to
-update the screen when necessary.
+There are two ways of dealing with exposures. The first one is to directly
+draw on the screen and the second one is to draw in a pixmap buffer,
+and then to update the screen when necessary.
-In the first case, the expose event will be responsible for registering hooks to
-process_traceset and require time intervals to the main window. So, in this
-scenario, if a part of the screen is damaged, the trace has to be read to
-redraw the screen.
+In the first case, the expose event will be responsible for registering
+hooks to process_traceset and require time intervals to the main
+window. So, in this scenario, if a part of the screen is damaged, the
+trace has to be read to redraw the screen.
-In the second case, with a pixmap buffer, the expose handler is only responsible
-of showing the pixmap buffer on the screen. If the pixmap buffer has never
-been filled with a drawing, the expose handler may ask for it to be filled.
+In the second case, with a pixmap buffer, the expose handler is only
+responsible of showing the pixmap buffer on the screen. If the pixmap
+buffer has never been filled with a drawing, the expose handler may ask
+for it to be filled.
-The interest of using events request to the main window instead of reading the
-events directly from the trace comes from the fact that the main window
-does merge requests from the different viewers in the same tab so that the
-read loop and the state update is shared. As viewers will, in the common
-scenario, request the same events, only one pass through the trace that will
-call the right hooks for the right intervals will be done.
+The interest of using events request to the main window instead of reading
+the events directly from the trace comes from the fact that the main
+window does merge requests from the different viewers in the same tab so
+that the read loop and the state update is shared. As viewers will, in
+the common scenario, request the same events, only one pass through the
+trace that will call the right hooks for the right intervals will be done.
-When the traceset read is over for a events request, the traceset_end hook is
-called. It has the responsibility of finishing the drawing if some parts
-still need to be drawn and to show it on the screen (if the viewer uses a pixmap
-buffer).
+When the traceset read is over for a events request, the traceset_end
+hook is called. It has the responsibility of finishing the drawing if
+some parts still need to be drawn and to show it on the screen (if the
+viewer uses a pixmap buffer).
It can add dotted lines and such visual effects to enhance the user's
experience.
#include <lttv/hook.h>
#include <lttv/tracecontext.h>
#include <lttv/stats.h>
-#include <lttvwindow/common.h>
+#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/lttvfilter.h>
//FIXME (not ready yet) #include <lttv/filter.h>
-
/* Module Related API */
/* Structure sent to the events request hook */
/* Value considered as empty */
typedef struct _EventsRequest {
+ gpointer owner; /* Owner of the request */
gpointer viewer_data; /* Unset : NULL */
gboolean servicing; /* service in progress: TRUE */
LttTime start_time;/* Unset : { G_MAXUINT, G_MAXUINT }*/
LttvHooks *after_chunk_trace; /* Unset : NULL */
LttvHooks *after_chunk_traceset; /* Unset : NULL */
LttvHooks *before_request; /* Unset : NULL */
- LttvHooks *after_request /* Unset : NULL */
+ LttvHooks *after_request; /* Unset : NULL */
} EventsRequest;
+/* Maximum number of events to proceed at once in a chunk */
+#define CHUNK_NUM_EVENTS 50000
+
/**
* Function to request data in a specific time interval to the main window. The
--- /dev/null
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu Yang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef _MAIN_WINDOW_PRIVATE_
+#define _MAIN_WINDOW_PRIVATE_
+
+#include <gtk/gtk.h>
+
+#include <ltt/ltt.h>
+#include <lttv/attribute.h>
+#include <lttv/traceset.h>
+#include <lttv/tracecontext.h>
+#include <lttv/hook.h>
+#include <lttv/stats.h>
+#include <lttvwindow/gtkmultivpaned.h>
+#include <lttvwindow/mainwindow.h>
+
+struct _TracesetInfo {
+ //FIXME? TracesetContext and stats in same or different variable ?
+ LttvTracesetStats * traceset_context;
+ LttvTraceset * traceset;
+};
+
+struct _MainWindow{
+ GtkWidget* mwindow; /* Main Window */
+ int window_width;
+
+ /* Status bar information */
+ // guint MainSBarContextID; /* Context ID of main status bar */
+ // guint BegTimeSBarContextID; /* Context ID of BegTime status bar */
+ // guint EndTimeSBarContextID; /* Context ID of EndTime status bar */
+
+ /* Child windows */
+ //openTracesetWindow* OpenTracesetWindow;/* Window to get prof and proc file*/
+ //viewTimeFrameWindow* ViewTimeFrameWindow;/*Window to select time frame */
+ //gotoEventWindow* GotoEventWindow; /*search for event description*/
+ //openFilterWindow* OpenFilterWindow; /* Open a filter selection window */
+ GtkWidget* help_contents;/* Window to display help contents */
+ GtkWidget* about_box; /* Window about information */
+
+ // lttv_trace_filter * filter; /* trace filter associated with the window */
+
+ /* Attributes for trace reading hooks local to the main window */
+ LttvIAttribute * attributes;
+
+ Tab * tab;
+ Tab * current_tab;
+
+};
+
+
+struct _Tab{
+ GtkWidget * label;
+ GtkMultiVPaned * multi_vpaned;
+
+ // startTime is the left of the visible area. Corresponds to the scrollbar
+ // value.
+ // Time_Width is a zoom dependant value (corresponding to page size)
+ TimeWindow time_window;
+
+ // The current time is the time selected in the visible area by the user,
+ // not the scrollbar value.
+ LttTime current_time;
+ LttvIAttribute * attributes;
+
+ struct _Tab * next;
+ MainWindow * mw;
+
+ /* Traceset related information */
+ TracesetInfo * traceset_info;
+
+ /* A list of time requested for the next process trace */
+ GSList *events_requests;
+ gboolean events_request_pending;
+ LttvAttribute *interrupted_state;
+};
+
+#endif /* _MAIN_WINDOW_PRIVATE_ */
+
+
#ifndef _MAIN_WINDOW_
#define _MAIN_WINDOW_
-#include <gtk/gtk.h>
+#include <ltt/time.h>
-#include <ltt/ltt.h>
-#include <lttv/attribute.h>
-#include <lttv/traceset.h>
-#include <lttv/tracecontext.h>
+typedef struct _MainWindow MainWindow;
+typedef struct _TimeWindow TimeWindow;
+typedef struct _Tab Tab;
+typedef struct _TracesetInfo TracesetInfo;
-#include <lttvwindow/common.h>
-#include <lttvwindow/gtkmultivpaned.h>
-#include <lttv/hook.h>
-#include <lttv/stats.h>
+struct _TimeWindow {
+ LttTime start_time;
+ LttTime time_width;
+};
-typedef struct _TracesetInfo {
- //FIXME? TracesetContext and stats in same or different variable ?
- LttvTracesetStats * traceset_context;
- LttvTraceset * traceset;
-} TracesetInfo ;
-struct _MainWindow{
- GtkWidget* mwindow; /* Main Window */
- int window_width;
-
- /* Status bar information */
- // guint MainSBarContextID; /* Context ID of main status bar */
- // guint BegTimeSBarContextID; /* Context ID of BegTime status bar */
- // guint EndTimeSBarContextID; /* Context ID of EndTime status bar */
-
- /* Child windows */
- //openTracesetWindow* OpenTracesetWindow;/* Window to get prof and proc file*/
- //viewTimeFrameWindow* ViewTimeFrameWindow;/*Window to select time frame */
- //gotoEventWindow* GotoEventWindow; /*search for event description*/
- //openFilterWindow* OpenFilterWindow; /* Open a filter selection window */
- GtkWidget* help_contents;/* Window to display help contents */
- GtkWidget* about_box; /* Window about information */
-
- // lttv_trace_filter * filter; /* trace filter associated with the window */
-
- /* Attributes for trace reading hooks local to the main window */
- LttvIAttribute * attributes;
-
- Tab * tab;
- Tab * current_tab;
-
-};
-
-
-struct _Tab{
- GtkWidget * label;
- GtkMultiVPaned * multi_vpaned;
-
- // startTime is the left of the visible area. Corresponds to the scrollbar
- // value.
- // Time_Width is a zoom dependant value (corresponding to page size)
- TimeWindow time_window;
-
- // The current time is the time selected in the visible area by the user,
- // not the scrollbar value.
- LttTime current_time;
- LttvIAttribute * attributes;
-
- struct _Tab * next;
- MainWindow * mw;
-
- /* Traceset related information */
- TracesetInfo * traceset_info;
-
- /* A list of time requested for the next process trace */
- GArray *time_requests;
- gboolean time_request_pending;
-};
-
#endif /* _MAIN_WINDOW_ */
g_array_free(h, TRUE);
}
-inline LttvMenuClosure lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menuPath, char* menuText, GtkWidget *widget)
+inline LttvMenuClosure lttv_menus_add(LttvMenus *h, lttvwindow_viewer_constructor f, char* menu_path, char* menu_text, GtkWidget *widget)
{
LttvMenuClosure c;
if(h == NULL)return;
c.con = f;
- c.menuPath = menuPath;
- c.menuText = menuText;
+ c.menu_path = menu_path;
+ c.menu_text = menu_text;
c.widget = widget;
g_array_append_val(h,c);
#define MENU_H
#include <gtk/gtk.h>
-#include <lttvwindow/common.h>
#include <lttvwindow/lttvwindow.h>
#include <lttv/lttv.h>
#include <lttvwindow/toolbar.h>
-
inline LttvToolbars *lttv_toolbars_new() {
return g_array_new(FALSE, FALSE, sizeof(LttvToolbarClosure));
}
#ifndef TOOLBAR_H
#define TOOLBAR_H
-#include <lttvwindow/common.h>
#include <lttvwindow/lttvwindow.h>
#include <gtk/gtk.h>
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 XangXiu Yang
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License Version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*! \file lttvviewer.c
- * \brief API used by the graphical viewers to interact with their tab.
- *
- * Main window (gui module) is the place to contain and display viewers.
- * Viewers (lttv plugins) interact with tab and main window through this API
- * and events sent by gtk.
- * This header file should be included in each graphic module.
- * This library is used by graphical modules to interact with their tab and
- * main window.
- *
- */
-
-#include <ltt/ltt.h>
-#include <lttv/lttv.h>
-#include <lttv/state.h>
-#include <lttv/stats.h>
-#include <lttv/tracecontext.h>
-#include <lttvwindow/common.h>
-#include <lttvwindow/mainwindow.h>
-#include <lttvwindow/viewer.h>
-#include <lttvwindow/toolbar.h>
-#include <lttvwindow/menu.h>
-#include <lttvwindow/callbacks.h> // for execute_events_requests
-#include <lttvwindow/support.h>
-
-
-/**
- * Internal function parts
- */
-
-extern GSList * g_main_window_list;
-
-/**
- * Function to set/update traceset for the viewers
- * @param tab viewer's tab
- * @param traceset traceset of the main window.
- * return value :
- * -1 : error
- * 0 : traceset updated
- * 1 : no traceset hooks to update; not an error.
- */
-
-int SetTraceset(Tab * tab, gpointer traceset)
-{
- LttvHooks * tmp;
- LttvAttributeValue value;
-
- if( lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetraceset", LTTV_POINTER, &value) != 0)
- return -1;
-
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return 1;
-
-
- lttv_hooks_call(tmp,traceset);
-
- return 0;
-}
-
-
-/**
- * Function to set/update filter for the viewers
- * @param tab viewer's tab
- * @param filter filter of the main window.
- * return value :
- * -1 : error
- * 0 : filters updated
- * 1 : no filter hooks to update; not an error.
- */
-
-int SetFilter(Tab * tab, gpointer filter)
-{
- LttvHooks * tmp;
- LttvAttributeValue value;
-
- if(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatefilter", LTTV_POINTER, &value) != 0)
- return -1;
-
- tmp = (LttvHooks*)*(value.v_pointer);
-
- if(tmp == NULL) return 1;
- lttv_hooks_call(tmp,filter);
-
- return 0;
-}
-
-/**
- * Function to redraw each viewer belonging to the current tab
- * @param tab viewer's tab
- */
-
-void update_traceset(Tab *tab)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetraceset", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_call(tmp, NULL);
-}
-
-void set_time_window_adjustment(Tab *tab, const TimeWindow* new_time_window)
-{
- gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
-}
-
-
-void set_time_window(Tab *tab, const TimeWindow *time_window)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
-
- TimeWindowNotifyData time_window_notify_data;
- TimeWindow old_time_window = tab->time_window;
- time_window_notify_data.old_time_window = &old_time_window;
- tab->time_window = *time_window;
- time_window_notify_data.new_time_window =
- &(tab->time_window);
-
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetimewindow", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_call(tmp, &time_window_notify_data);
-
-
-}
-
-void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c)
-{
- LttvIAttribute *attributes = mw->attributes;
- LttvAttributeValue value;
- LttvToolbars * instance_toolbar;
- lttvwindow_viewer_constructor constructor;
- GtkWidget * tool_menu_title_menu, *new_widget, *pixmap;
- GdkPixbuf *pixbuf;
-
- g_assert(lttv_iattribute_find_by_path(attributes,
- "viewers/toolbar", LTTV_POINTER, &value));
- if(*(value.v_pointer) == NULL)
- *(value.v_pointer) = lttv_toolbars_new();
- instance_toolbar = (LttvToolbars*)*(value.v_pointer);
-
- constructor = toolbar_c->con;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
- pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap);
- pixmap = gtk_image_new_from_pixbuf(pixbuf);
- new_widget =
- gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
- GTK_TOOLBAR_CHILD_BUTTON,
- NULL,
- "",
- toolbar_c->tooltip, NULL,
- pixmap, NULL, NULL);
- gtk_label_set_use_underline(
- GTK_LABEL (((GtkToolbarChild*) (
- g_list_last (GTK_TOOLBAR
- (tool_menu_title_menu)->children)->data))->label),
- TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
- g_signal_connect ((gpointer) new_widget,
- "clicked",
- G_CALLBACK (insert_viewer_wrap),
- constructor);
- gtk_widget_show (new_widget);
-
- lttv_toolbars_add(instance_toolbar, toolbar_c->con,
- toolbar_c->tooltip,
- toolbar_c->pixmap,
- new_widget);
-
-}
-
-void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c)
-{
- LttvIAttribute *attributes = mw->attributes;
- LttvAttributeValue value;
- LttvToolbars * instance_menu;
- lttvwindow_viewer_constructor constructor;
- GtkWidget * tool_menu_title_menu, *new_widget;
-
- g_assert(lttv_iattribute_find_by_path(attributes,
- "viewers/menu", LTTV_POINTER, &value));
- if(*(value.v_pointer) == NULL)
- *(value.v_pointer) = lttv_menus_new();
- instance_menu = (LttvMenus*)*(value.v_pointer);
-
-
- constructor = menu_c->con;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
- new_widget =
- gtk_menu_item_new_with_mnemonic (menu_c->menu_text);
- gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
- new_widget);
- g_signal_connect ((gpointer) new_widget, "activate",
- G_CALLBACK (insert_viewer_wrap),
- constructor);
- gtk_widget_show (new_widget);
- lttv_menus_add(instance_menu, menu_c->con,
- menu_c->menu_path,
- menu_c->menu_text,
- new_widget);
-}
-
-void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
-{
- LttvIAttribute *attributes = mw->attributes;
- LttvAttributeValue value;
- LttvToolbars * instance_toolbar;
- lttvwindow_viewer_constructor constructor;
- GtkWidget * tool_menu_title_menu, *widget;
-
- g_assert(lttv_iattribute_find_by_path(attributes,
- "viewers/toolbar", LTTV_POINTER, &value));
- if(*(value.v_pointer) == NULL)
- *(value.v_pointer) = lttv_toolbars_new();
- instance_toolbar = (LttvToolbars*)*(value.v_pointer);
-
- tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
- widget = lttv_menus_remove(instance_toolbar, viewer_constructor);
- gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
- widget);
-}
-
-
-void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
-{
- LttvIAttribute *attributes = mw->attributes;
- LttvAttributeValue value;
- LttvMenus * instance_menu;
- lttvwindow_viewer_constructor constructor;
- GtkWidget * tool_menu_title_menu, *widget;
- LttvMenuClosure *menu_item_i;
-
- g_assert(lttv_iattribute_find_by_path(attributes,
- "viewers/menu", LTTV_POINTER, &value));
- if(*(value.v_pointer) == NULL)
- *(value.v_pointer) = lttv_menus_new();
- instance_menu = (LttvMenus*)*(value.v_pointer);
-
- widget = lttv_menus_remove(instance_menu, viewer_constructor);
- tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
- gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget);
-}
-
-
-/**
- * API parts
- */
-
-
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item and a toolbar item for the viewer in order to generate a new
- * instance easily. A menu entry and toolbar item will be added to each main
- * window.
- *
- * It should be called by init function of the module.
- *
- * @param menu_path path of the menu item.
- * @param menu_text text of the menu item.
- * @param pixmap Image shown on the toolbar item.
- * @param tooltip tooltip of the toolbar item.
- * @param view_constructor constructor of the viewer.
- */
-
-void lttvwindow_register_constructor
- (char * menu_path,
- char * menu_text,
- char ** pixmap,
- char * tooltip,
- lttvwindow_viewer_constructor view_constructor)
-{
- LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
- LttvToolbars * toolbar;
- LttvMenus * menu;
- LttvToolbarClosure toolbar_c;
- LttvMenuClosure menu_c;
- LttvAttributeValue value;
-
- if(pixmap != NULL) {
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/toolbar", LTTV_POINTER, &value));
- toolbar = (LttvToolbars*)*(value.v_pointer);
-
- if(toolbar == NULL) {
- toolbar = lttv_toolbars_new();
- *(value.v_pointer) = toolbar;
- }
- toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap,
- NULL);
-
- g_slist_foreach(g_main_window_list,
- (gpointer)add_toolbar_constructor,
- &toolbar_c);
- }
-
- if(menu_path != NULL) {
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/menu", LTTV_POINTER, &value));
- menu = (LttvMenus*)*(value.v_pointer);
-
- if(menu == NULL) {
- menu = lttv_menus_new();
- *(value.v_pointer) = menu;
- }
- menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text,NULL);
-
- g_slist_foreach(g_main_window_list,
- (gpointer)add_menu_constructor,
- &menu_c);
- }
-}
-
-
-/**
- * Function to unregister the viewer's constructor, release the space
- * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
- * viewer.
- *
- * It will be called when a module is unloaded.
- *
- * @param view_constructor constructor of the viewer.
- */
-
-
-void lttvwindow_unregister_constructor
- (lttvwindow_viewer_constructor view_constructor)
-{
- LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
- LttvToolbars * toolbar;
- LttvMenus * menu;
- LttvAttributeValue value;
-
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/toolbar", LTTV_POINTER, &value));
- toolbar = (LttvToolbars*)*(value.v_pointer);
-
- if(toolbar != NULL) {
- g_slist_foreach(g_main_window_list,
- (gpointer)remove_toolbar_constructor,
- view_constructor);
- lttv_toolbars_remove(toolbar, view_constructor);
- }
-
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/menu", LTTV_POINTER, &value));
- menu = (LttvMenus*)*(value.v_pointer);
-
- if(menu != NULL) {
- g_slist_foreach(g_main_window_list,
- (gpointer)remove_menu_constructor,
- view_constructor);
- lttv_menus_remove(menu, view_constructor);
- }
-}
-
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * time interval.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-void lttvwindow_register_time_window_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetimewindow", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the time interval of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_time_window_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetimewindow", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * traceset.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_register_traceset_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetraceset", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the traceset of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_traceset_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatetraceset", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * filter.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_register_filter_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatefilter", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the filter of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_filter_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatefilter", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * current time.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_register_current_time_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatecurrenttime", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the current time of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_current_time_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatecurrenttime", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to register a hook function for a viewer to show
- * the content of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_register_show_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/showviewer", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * show the content of the viewer..
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_show_notify(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/showviewer", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-/**
- * Function to register a hook function for a viewer to set/update the
- * dividor of the hpane.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_register_dividor(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/hpanedividor", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL){
- tmp = lttv_hooks_new();
- *(value.v_pointer) = tmp;
- }
- lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update hpane's dividor of the viewer.
- * It will be called by the destructor of the viewer.
- * @param tab viewer's tab
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- */
-
-void lttvwindow_unregister_dividor(Tab *tab,
- LttvHook hook, gpointer hook_data)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/hpanedividor", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Update the status bar whenever something changed in the viewer.
- * @param tab viewer's tab
- * @param info the message which will be shown in the status bar.
- */
-
-void lttvwindow_report_status(Tab *tab, const char *info)
-{
- //FIXME
- g_warning("update_status not implemented in viewer.c");
- // Use tab->mw for status
-}
-
-/**
- * Function to set the time interval of the current tab.
- * It will be called by a viewer's signal handle associated with
- * the move_slider signal
- * @param tab viewer's tab
- * @param time_interval a pointer where time interval is stored.
- */
-
-void lttvwindow_report_time_window(Tab *tab,
- const TimeWindow *time_window)
-{
- set_time_window(tab, time_window);
- set_time_window_adjustment(tab, time_window);
-}
-
-
-/**
- * Function to set the current time/event of the current tab.
- * It will be called by a viewer's signal handle associated with
- * the button-release-event signal
- * @param tab viewer's tab
- * @param time a pointer where time is stored.
- */
-
-void lttvwindow_report_current_time(Tab *tab,
- const LttTime *time)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- tab->current_time = *time;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/updatecurrenttime", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
-
- if(tmp == NULL)return;
- lttv_hooks_call(tmp, &tab->current_time);
-}
-
-/**
- * Function to set the position of the hpane's dividor (viewer).
- * It will be called by a viewer's signal handle associated with
- * the motion_notify_event event/signal
- * @param tab viewer's tab
- * @param position position of the hpane's dividor.
- */
-
-void lttvwindow_report_dividor(Tab *tab, gint position)
-{
- LttvAttributeValue value;
- LttvHooks * tmp;
- g_assert(lttv_iattribute_find_by_path(tab->attributes,
- "hooks/hpanedividor", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_call(tmp, &position);
-}
-
-/**
- * Function to set the focused pane (viewer).
- * It will be called by a viewer's signal handle associated with
- * the grab_focus signal
- * @param tab viewer's tab
- * @param top_widget the top widget containing all the other widgets of the
- * viewer.
- */
-
-void lttvwindow_report_focus(Tab *tab, GtkWidget *top_widget)
-{
- gtk_multi_vpaned_set_focus((GtkWidget*)tab->multi_vpaned,
- GTK_PANED(gtk_widget_get_parent(top_widget)));
-}
-
-
-/**
- * Function to request data in a specific time interval to the main window. The
- * event request servicing is differed until the glib idle functions are
- * called.
- *
- * The viewer has to provide hooks that should be associated with the event
- * request.
- *
- * Either start time or start position must be defined in a EventRequest
- * structure for it to be valid.
- *
- * end_time, end_position and num_events can all be defined. The first one
- * to occur will be used as end criterion.
- *
- * @param tab viewer's tab
- * @param events_requested the structure of request from.
- */
-
-void lttvwindow_events_request(Tab *tab,
- const EventsRequest *events_request)
-{
- EventsRequest *alloc = g_new(sizeof(EventsRequest,1));
- *alloc = *events_request;
-
- tab->events_requests = g_slist_append(tab->events_requests, alloc);
-
- if(!tab->events_request_pending)
- {
- /* Redraw has +20 priority. We want a prio higher than that, so +19 */
- g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19),
- (GSourceFunc)execute_events_requests,
- tab,
- NULL);
- tab->events_request_pending = TRUE;
- }
-}
-
-
-/**
- * Function to remove data requests related to a viewer.
- *
- * The existing requests's viewer gpointer is compared to the pointer
- * given in argument to establish which data request should be removed.
- *
- * @param tab the tab the viewer belongs to.
- * @param viewer a pointer to the viewer data structure
- */
-
-gint find_viewer (const EventsRequest *a, gconstpointer b)
-{
- return (a->viewer != b);
-}
-
-
-void lttvwindow_events_request_remove_all(Tab *tab,
- gconstpointer viewer)
-{
- GSList *element;
-
- while((element =
- g_slist_find_custom(tab->events_requests, viewer,
- (GCompareFunc)find_viewer))
- != NULL) {
- EventRequest *events_request = (EventsRequest *)element->data;
- if(events_request->servicing == TRUE) {
- lttv_hooks_call(events_request->after_request, NULL);
- }
- g_free(events_request);
- tab->events_requests = g_slist_remove_link(tab->events_requests, element);
-
- }
-}
-
-
-
-/**
- * Function to get the current time interval shown on the current tab.
- * It will be called by a viewer's hook function to update the
- * shown time interval of the viewer and also be called by the constructor
- * of the viewer.
- * @param tab viewer's tab
- * @param time_interval a pointer where time interval will be stored.
- */
-
-const TimeWindow *lttvwindow_get_time_window(Tab *tab)
-{
- return &(tab->time_window);
-
-}
-
-
-/**
- * Function to get the current time/event of the current tab.
- * It will be called by a viewer's hook function to update the
- * current time/event of the viewer.
- * @param tab viewer's tab
- * @param time a pointer where time will be stored.
- */
-
-const LttTime *lttvwindow_get_current_time(Tab *tab)
-{
- return &(tab->current_time);
-}
-
-
-/**
- * Function to get the filter of the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its filter.
- * @param tab viewer's tab
- * @param filter, a pointer to a filter.
- */
-const lttv_filter *lttvwindow_get_filter(Tab *tab)
-{
- //FIXME
- g_warning("lttvwindow_get_filter not implemented in viewer.c");
-}
-
-
-/**
- * Function to get the stats of the traceset
- * @param tab viewer's tab
- */
-
-LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab)
-{
- return tab->traceset_info->traceset_context;
-}
-
-
-LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab)
-{
- return (LttvTracesetContext*)tab->traceset_info->traceset_context;
-}
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit Graphic User Interface
- * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License Version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- */
-
-/*
-This file is what every viewer plugin writer should refer to.
-
-
-Module Related API
-
-A viewer plugin is, before anything, a plugin. As a dynamically loadable
-module, it thus has an init and a destroy function called whenever it is
-loaded/initialized and unloaded/destroyed. A graphical module depends on
-lttvwindow for construction of its viewer instances. In order to achieve this,
-it must register its constructor function to the main window along with
-button description or text menu entry description. A module keeps a list of
-every viewer that currently sits in memory so it can destroy them before the
-module gets unloaded/destroyed.
-
-The contructor registration to the main windows adds button and menu entry
-to each main window, thus allowing instanciation of viewers.
-
-
-Main Window
-
-The main window is a container that offers menus, buttons and a notebook. Some
-of those menus and buttons are part of the core of the main window, others
-are dynamically added and removed when modules are loaded/unloaded.
-
-The notebook contains as much tabs as wanted. Each tab is linked with a
-set of traces (traceset). Each trace contains many tracefiles (one per cpu).
-A trace corresponds to a kernel being traced. A traceset corresponds to
-many traces read together. The time span of a traceset goes from the
-earliest start of all the traces to the latest end of all the traces.
-
-Inside each tab are added the viewers. When they interact with the main
-window through the lttvwindow API, they affect the other viewers located
-in the same tab as they are.
-
-The insertion of many viewers in a tab permits a quick look at all the
-information wanted in a glance. The main window does merge the read requests
-from all the viewers in the same tab in a way that every viewer will get exactly
-the events it asked for, while the event reading loop and state update are
-shared. It improves performance of events delivery to the viewers.
-
-
-
-Viewer Instance Related API
-
-The lifetime of a viewer is as follows. The viewer constructor function is
-called each time an instance view is created (one subwindow of this viewer
-type is created by the user either by clicking on the menu item or the button
-corresponding to the viewer). Thereafter, the viewer gets hooks called for
-different purposes by the window containing it. These hooks are detailed
-below. It also has to deal with GTK Events. Finally, it can be destructed by
-having its top level widget unreferenced by the main window or by any
-GTK Event causing a "destroy-event" signal on the its top widget. Another
-possible way for it do be destroyed is if the module gets unloaded. The module
-unload function will have to emit a "destroy" signal on each top level widget
-of all instances of its viewers.
-
-
-Notices from Main Window
-
-time_window : This is the time interval visible on the viewer's tab. Every
- viewer that cares about being synchronised by respect to the
- time with other viewers should register to this notification.
- They should redraw all or part of their display when this occurs.
-
-traceset : This notification is called whenever a trace is added/removed
- from the traceset. As it affects all the data displayed by the
- viewer, it sould redraw itself totally.
-
-filter : FIXME : describe..
-
-current_time: Being able to zoom nearer a specific time or highlight a specific
- time on every viewer in synchronicity implies that the viewer
- has to shown a visual sign over the drawing or select an event
- when it receives this notice. It should also inform the main
- window with the appropriate report API function when a user
- selects a specific time as being the current time.
-
-dividor : This notice links the positions of the horizontal dividors
- between the graphic display zone of every viewer and their Y axis,
- typically showing processes, cpus, ...
-
-
-FIXME : Add background computation explanation here
-background_init: prepare for background computation (comes after show_end).
-process_trace for background: done in small chunks in gtk_idle, hooks called.
-background_end: remove the hooks and perhaps update the window.
-
-
-Reporting Changes to the Main Window
-
-In most cases, the enclosing window knows about updates such as described in the
-Notification section higher. There are a few cases, however, where updates are
-caused by actions known by a view instance. For example, clicking in a view may
-update the current time; all viewers within the same window must be told about
-the new current time to change the currently highlighted time point. A viewer
-reports such events by calling lttvwindow_report_current_time on its lttvwindow.
-The lttvwindow will consequently call current_time_notify for each of its
-contained viewers.
-
-
-Available report methods are :
-
-lttvwindow_report_status : reports the text of the status bar.
-lttvwindow_report_time_window : reports the new time window.
-lttvwindow_report_current_time : reports the new current time.
-lttvwindow_report_dividor : reports the new horizontal dividor's position.
-lttvwindow_report_focus : One on the widgets in the viewer has the keyboard's
- focus from GTK.
-
-
-
-Requesting Events to Main Window
-
-Events can be requested by passing a EventsRequest structure to the main window.
-They will be delivered later when the next g_idle functions will be called.
-Event delivery is done by calling the event hook for this event ID, or the
-main event hooks. A pointer to the EventsRequest structure is passed as
-hook_data to the event hooks of the viewers.
-
-EventsRequest consists in
-- a pointer to the viewer specific data structure
-- a start timestamp or position
-- a stop_flag, ending the read process when set to TRUE
-- a end timestamp and/or position and/or number of events to read
-- hook lists to call for traceset/trace/tracefile begin and end, and for each
- event (event hooks and event_by_id hooks).
-
-The main window will deliver events for every EventRequests it has pending
-through an algorithm that guarantee that all events requested, and only them,
-will be delivered to the viewer between the call of the tracefile_begin hooks
-and the call of the tracefile_end hooks.
-
-If a viewer wants to stop the event request at a certain point inside the event
-hooks, it has to set the stop_flag to TRUE and return TRUE from the hook
-function. Then return value will stop the process traceset. Then, the main
-window will look for the stop_flag and remove the EventRequests from its lists,
-calling the process_traceset_end for this request (it removes hooks from the
-context and calls the after hooks).
-
-It no stop_flag is rose, the end timestamp, end position or number of events to
-read has to be reached to determine the end of the request. Otherwise,
-the end of traceset does determine it.
-
-
-GTK Events
-
-Events and Signals
-
-GTK is quite different from the other graphical toolkits around there. The main
-difference resides in that there are many X Windows inside one GtkWindow,
-instead of just one. That means that X events are delivered by the glib main
-loop directly to the widget corresponding to the GdkWindow affected by the X
-event.
-
-Event delivery to a widget emits a signal on that widget. Then, if a handler
-is connected to this widget's signal, it will be executed. There are default
-handlers for signals, connected at class instantiation time. There is also
-the possibility to connect other handlers to these signals, which is what
-should be done in most cases when a viewer needs to interact with X in any
-way.
-
-
-
-Signal emission and propagation is described there :
-
-http://www.gtk.org/tutorial/sec-signalemissionandpropagation.html
-
-For further information on the GTK main loop (now a wrapper over glib main loop)
-see :
-
-http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html
-http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
-
-
-For documentation on event handling in GTK/GDK, see :
-
-http://developer.gnome.org/doc/API/2.0/gdk/gdk-Events.html
-http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html
-
-
-Signals can be connected to handlers, emitted, propagated, blocked,
-stopped. See :
-
-http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html
-
-
-
-
-The "expose_event"
-
-Provides the exposed region in the GdkEventExpose structure.
-
-There are two ways of dealing with exposures. The first one is to directly draw
-on the screen and the second one is to draw in a pixmap buffer, and then to
-update the screen when necessary.
-
-In the first case, the expose event will be responsible for registering hooks to
-process_traceset and require time intervals to the main window. So, in this
-scenario, if a part of the screen is damaged, the trace has to be read to
-redraw the screen.
-
-In the second case, with a pixmap buffer, the expose handler is only responsible
-of showing the pixmap buffer on the screen. If the pixmap buffer has never
-been filled with a drawing, the expose handler may ask for it to be filled.
-
-The interest of using events request to the main window instead of reading the
-events directly from the trace comes from the fact that the main window
-does merge requests from the different viewers in the same tab so that the
-read loop and the state update is shared. As viewers will, in the common
-scenario, request the same events, only one pass through the trace that will
-call the right hooks for the right intervals will be done.
-
-When the traceset read is over for a events request, the traceset_end hook is
-called. It has the responsibility of finishing the drawing if some parts
-still need to be drawn and to show it on the screen (if the viewer uses a pixmap
-buffer).
-
-It can add dotted lines and such visual effects to enhance the user's
-experience.
-
-
-FIXME : explain other important events
-
-*/
-
-
-#ifndef VIEWER_H
-#define VIEWER_H
-
-/*! \file viewer.h
- * \brief API used by the graphical viewers to interact with their top window.
- *
- * Main window (lttvwindow module) is the place to contain and display viewers.
- * Viewers (lttv plugins) interact with main window through this API.
- * This header file should be included in each graphic module.
- *
- */
-
-#include <gtk/gtk.h>
-#include <ltt/ltt.h>
-#include <ltt/time.h>
-#include <lttv/hook.h>
-#include <lttv/tracecontext.h>
-#include <lttv/stats.h>
-#include <lttvwindow/common.h>
-//FIXME (not ready yet) #include <lttv/filter.h>
-
-
-/* Module Related API */
-
-
-/* constructor a the viewer */
-//FIXME explain LttvTracesetSelector and key
-typedef GtkWidget * (*lttvwindow_viewer_constructor)
- (Tab *tab, LttvTracesetSelector * s, char *key);
-
-
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item and a toolbar item for the viewer in order to generate a new
- * instance easily. A menu entry and toolbar item will be added to each main
- * window.
- *
- * It should be called by init function of the module.
- *
- * @param menu_path path of the menu item. NULL : no menu entry.
- * @param menu_text text of the menu item.
- * @param pixmap Image shown on the toolbar item. NULL : no button.
- * @param tooltip tooltip of the toolbar item.
- * @param view_constructor constructor of the viewer.
- */
-
-void lttvwindow_register_constructor
- (char * menu_path,
- char * menu_text,
- char ** pixmap,
- char * tooltip,
- lttvwindow_viewer_constructor view_constructor);
-
-
-/**
- * Function to unregister the viewer's constructor, release the space
- * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
- * viewer.
- *
- * It will be called when a module is unloaded.
- *
- * @param view_constructor constructor of the viewer.
- */
-
-void lttvwindow_unregister_constructor
- (lttvwindow_viewer_constructor view_constructor);
-
-
-
-
-/* Viewer Instance Related API */
-
-/**
- * Structure used as hook_data for the time_window_notify hook.
- */
-typedef struct _TimeWindowNotifyData {
- TimeWindow *new_time_window;
- TimeWindow *old_time_window;
-} TimeWindowNotifyData;
-
-
-/**
- * Function to register a hook function that will be called by the main window
- * when the time interval needs to be updated.
- *
- * This register function is typically called by the constructor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook that sould be called by the main window when the time
- * interval changes. This hook function takes a
- * TimeWindowNotifyData* as call_data.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_register_time_window_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to unregister the time_window notification hook.
- *
- * This unregister function is typically called by the destructor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook that sould be called by the main window when the time
- * interval changes. This hook function takes a
- * TimeWindowNotifyData* as call_data.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_unregister_time_window_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to register a hook function that will be called by the main window
- * when the traceset is changed. That means that the viewer must redraw
- * itself completely or check if it's affected by the particular change to the
- * traceset.
- *
- * This register function is typically called by the constructor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook that should be called whenever a change to the traceset
- * occurs. The call_data of this hook is a NULL pointer.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_register_traceset_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to unregister the traceset_notify hook.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook that should be called whenever a change to the traceset
- * occurs. The call_data of this hook is a NULL pointer.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_unregister_traceset_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * filter.
- *
- * FIXME : Add information about what a filter is as seen from a viewer and how
- * to use it.
- *
- * This register function is typically called by the constructor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook function called by the main window when a filter change
- * occurs.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_register_filter_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the filter of the viewer.
- *
- * This unregistration is called by the destructor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook function called by the main window when a filter change
- * occurs.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_unregister_filter_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * current time.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook function of the viewer that updates the current time. The
- * call_data is a LttTime* representing the new current time.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_register_current_time_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update the current time of the viewer.
- * @param tab the tab the viewer belongs to.
- * @param hook hook function of the viewer that updates the current time. The
- * call_data is a LttTime* representing the new current time.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_unregister_current_time_notify(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to register a hook function for a viewer to set/update the
- * dividor of the hpane. It provides a way to make the horizontal
- * dividors of all the viewers linked together.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook function of the viewer that will be called whenever a
- * dividor changes in another viewer. The call_data of this hook
- * is a gint*. The value of the integer is the new position of the
- * hpane dividor.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_register_dividor(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to
- * set/update hpane's dividor of the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param hook hook function of the viewer that will be called whenever a
- * dividor changes in another viewer. The call_data of this hook
- * is a gint*. The value of the integer is the new position of the
- * hpane dividor.
- * @param hook_data hook data associated with the hook function. It will
- * be typically a pointer to the viewer's data structure.
- */
-
-void lttvwindow_unregister_dividor(Tab *tab,
- LttvHook hook,
- gpointer hook_data);
-
-
-
-/**
- * This method reports the information to show on the status bar in the
- * main window.
- *
- * @param tab the tab the viewer belongs to.
- * @param info the message which will be shown in the status bar.
- */
-
-void lttvwindow_report_status(Tab *tab, const char *info);
-
-
-/**
- * Function to set the time interval of the current tab.a
- *
- * @param tab the tab the viewer belongs to.
- * @param time_interval pointer to the time interval value.
- */
-
-void lttvwindow_report_time_window(Tab *tab,
- const TimeWindow *time_window);
-
-/**
- * Function to set the current time/event of the current tab.
- * It will be called by a viewer's signal handle associated with
- * the button-release-event signal
- * @param tab the tab the viewer belongs to.
- * @param time a pointer where time is stored.
- */
-
-void lttvwindow_report_current_time(Tab *tab,
- const LttTime *time);
-
-
-/**
- * Function to set the position of the hpane's dividor (viewer).
- * It will typically be called by a viewer's signal handle associated
- * with the motion_notify_event event/signal.
- *
- * @param tab the tab the viewer belongs to.
- * @param position position of the hpane's dividor.
- */
-
-void lttvwindow_report_dividor(Tab *tab, gint position);
-
-/**
- * Function to set the focused viewer of the tab.
- * It will be called by a viewer's signal handle associated with
- * the grab_focus signal of all widgets in the viewer.
- *
- * @param tab the tab the viewer belongs to.
- * @param top_widget the top widget containing all the other widgets of the
- * viewer.
- */
-void lttvwindow_report_focus(Tab *tab,
- GtkWidget *top_widget);
-
-
-/* Structure sent to the events request hook */
- /* Value considered as empty */
-typedef struct _EventsRequest {
- gpointer viewer_data; /* Unset : NULL */
- gboolean servicing; /* service in progress: TRUE */
- LttTime start_time;/* Unset : { G_MAXUINT, G_MAXUINT }*/
- LttvTracesetContextPosition *start_position; /* Unset : NULL */
- gboolean stop_flag; /* Continue:TRUE Stop:FALSE */
- LttTime end_time;/* Unset : { G_MAXUINT, G_MAXUINT } */
- guint num_events; /* Unset : G_MAXUINT */
- LttvTracesetContextPosition *end_position; /* Unset : NULL */
- LttvHooks *before_chunk_traceset; /* Unset : NULL */
- LttvHooks *before_chunk_trace; /* Unset : NULL */
- LttvHooks *before_chunk_tracefile;/* Unset : NULL */
- LttvHooks *event; /* Unset : NULL */
- LttvHooksById *event_by_id; /* Unset : NULL */
- LttvHooks *after_chunk_tracefile; /* Unset : NULL */
- LttvHooks *after_chunk_trace; /* Unset : NULL */
- LttvHooks *after_chunk_traceset; /* Unset : NULL */
- LttvHooks *before_request; /* Unset : NULL */
- LttvHooks *after_request /* Unset : NULL */
-} EventsRequest;
-
-
-/**
- * Function to request data in a specific time interval to the main window. The
- * event request servicing is differed until the glib idle functions are
- * called.
- *
- * The viewer has to provide hooks that should be associated with the event
- * request.
- *
- * Either start time or start position must be defined in a EventRequest
- * structure for it to be valid.
- *
- * end_time, end_position and num_events can all be defined. The first one
- * to occur will be used as end criterion.
- *
- * @param tab the tab the viewer belongs to.
- * @param events_requested Details about the event request.
- */
-
-void lttvwindow_events_request(Tab *tab,
- const EventsRequest *events_request);
-
-/**
- * Function to remove data requests related to a viewer.
- *
- * The existing requests's viewer gpointer is compared to the pointer
- * given in argument to establish which data request should be removed.
- *
- * @param tab the tab the viewer belongs to.
- * @param viewer a pointer to the viewer data structure
- */
-
-void lttvwindow_events_request_remove_all(Tab *tab,
- gconstpointer viewer);
-
-
-typedef struct _BackgroundRequest {
- gchar *hook_path; /* Hook path in global attributes, where all standard hooks
- are : i.e. /TraceState/Statistics/ModuleName */
- gchar *trace_path; /* path_to_trace */
-} BackgroundRequest;
-
-typedef struct _BackgroundNotify {
- gchar *trace_path; /* path_to_trace */
- LttTime notify_time;
- LttvTracesetContextPosition *notify_position;
- LttvHooks *notify; /* Hook to call when the notify is
- passed, or at the end of trace */
-} BackgroundNotify;
-
-/**
- * Function to request data from a specific trace
- *
- * @param bg_request Request specification
- */
-
-void lttvwindow_background_request_queue(const BackgroundRequest *bg_request);
-
-/**
- * Register a callback to be called when requested data is passed in the next
- * queued background processing.
- *
- * @param bg_request Request specification
- */
-
-void lttvwindow_background_notify_queue(const BackgroundNotify *bg_notify);
-
-
-/**
- * Register a callback to be called when requested data is passed in the current
- * background processing.
- *
- * @param bg_request Request specification
- */
-
-void lttvwindow_background_notify_current(const BackgroundNotify *bg_notify);
-
-
-/**
- * Function to get the current time window of the current tab.
- *
- * @param tab the tab the viewer belongs to.
- * @return a pointer to the current tab's time interval.
- */
-
-const TimeWindow *lttvwindow_get_time_window(Tab *tab);
-
-
-/**
- * Function to get the current time of the current tab.
- *
- * @param tab the tab the viewer belongs to.
- * @return a pointer to the current tab's current time.
- */
-
-const LttTime *lttvwindow_get_current_time(Tab *tab);
-
-
-/**
- * Function to get the filter of the current tab.
- * @param main_win, the main window the viewer belongs to.
- * @param filter, a pointer to a filter.
- */
-
-//FIXME
-typedef void lttv_filter;
-//FIXME
-const lttv_filter *lttvwindow_get_filter(Tab *tab);
-
-
-/**
- * Function to get the stats of the traceset
- * It must be non const so the viewer can modify it.
- * FIXME : a set/get pair of functions would be more appropriate here.
- * @param tab the tab the viewer belongs to.
- * @return A pointer to Traceset statistics.
- */
-
-LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab);
-
-/**
- * Function to get the context of the traceset
- * It must be non const so the viewer can add and remove hooks from it.
- * @param tab the tab the viewer belongs to.
- * @return Context of the current tab.
- */
-
-
-LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab);
-
-
-#endif //VIEWER_H