-/* This file is part of the Linux Trace Toolkit viewer
+/* 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
Module Related API
-A viewer plugin is, before anything, a plugin. It thus has an init and
-a destroy function called whenever it is loaded/initialized and
-unloaded/destroyed. A viewer depends on lttvwindow and thus uses its init and
-destroy functions to register module related hooks defined in this file.
+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 window 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
of all instances of its viewers.
-Notices from Main Window :
+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
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 thereafter call update for each of its contained viewers.
+The lttvwindow will consequently call current_time_notify for each of its
+contained viewers.
Available report methods are :
lttvwindow_report_focus : One on the widgets in the viewer has the keyboard's
focus from GTK.
-Requiring Time Interval
-FIXME : explain
+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
-FIXME: explain GTK Events distribution and signals propagation in details
-(useful!)
+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"
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.
#include <gtk/gtk.h>
#include <ltt/ltt.h>
+#include <ltt/time.h>
#include <lttv/hook.h>
-#include <lttvwindow/common.h>
+#include <lttv/tracecontext.h>
#include <lttv/stats.h>
+#include <lttvwindow/common.h>
//FIXME (not ready yet) #include <lttv/filter.h>
/**
* Function to register a view constructor so that main window can generate
- * a toolbar item for the viewer in order to generate a new instance easily.
+ * 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 pixmap Image shown on the toolbar item.
+ * @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_toolbar
- (char ** pixmap,
+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 pixmap, tooltip and constructor of the viewer.
+ * 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_toolbar
+void lttvwindow_unregister_constructor
(lttvwindow_viewer_constructor view_constructor);
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item for the viewer in order to generate a new instance easily.
- *
- * It will 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 view_constructor constructor of the viewer.
- */
-
-void lttvwindow_register_menu(char *menu_path,
- char *menu_text,
- lttvwindow_viewer_constructor view_constructor);
-
-
-/**
- * Function to unregister the viewer's constructor, release the space
- * occupied by menu_path, menu_text and constructor of the viewer.
- *
- * It will be called when a module is unloaded.
- *
- * @param view_constructor constructor of the viewer.
- */
-
-void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor);
-
/* Viewer Instance Related API */
void lttvwindow_report_focus(MainWindow *main_win,
GtkWidget *top_widget);
-
-
/* Structure sent to the time request hook */
-typedef struct _TimeRequest {
- TimeWindow time_window;
- guint num_events;
- LttvHook after_hook;
- gpointer after_hook_data;
-} TimeRequest;
+ /* Value considered as empty */
+typedef struct _EventsRequest {
+ LttTime start_time; /* Unset : { 0, 0 } */
+ LttvTracesetContextPosition *start_position; /* Unset : num_traces = 0 */
+ gboolean stop_flag; /* Continue:TRUE Stop:FALSE */
+ LttTime end_time; /* Unset : { 0, 0 } */
+ guint num_events; /* Unset : G_MAXUINT */
+ LttvTracesetContextPosition *end_position; /* Unset : num_traces = 0 */
+ LttvHooks *before_traceset; /* Unset : NULL */
+ LttvHooks *before_trace; /* Unset : NULL */
+ LttvHooks *before_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 */
+} EventsRequest;
+
/**
* Function to request data in a specific time interval to the main window. The
* time request servicing is differed until the glib idle functions are
* called.
*
- * The viewer has to make sure that it has registered hooks in the main window's
- * traceset context before the glib idle's function gets called to ensure that
- * it will be called for the events it has asked for.
+ * The viewer has to provide hooks that should be associated with the event
+ * request.
*
- * @param main_win the main window the viewer belongs to.
- * @param time_requested the time requested by the viewer.
- * @param num_events the quantity of events to get (can be a little more if many
- * events have the same timestamp than the last one)
- * @param after_process_traceset hook called after the process traceset. It will
- * typically unregister the hooks in the context.
- * The call_data of this hook is a
- * const TimeRequest*, corresponding to the
- * original time request. It's there for
- * information purpose only and should not be
- * freed.
- * @param after_process_traceset_data hook data associated with the hook
- * function. It will be typically a pointer
- * to the viewer's data structure.
- */
-
-void lttvwindow_time_interval_request(MainWindow *main_win,
- TimeWindow time_requested,
- guint num_events,
- LttvHook after_process_traceset,
- gpointer after_process_traceset_data);
-
-/**
- * Function to get the life span of the traceset
+ * 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 main_win the main window the viewer belongs to.
- * @return pointer to a time interval : the life span of the traceset.
+ * @param events_requested the structure of request from.
*/
-const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win);
+void lttvwindow_events_request(MainWindow *main_win,
+ EventsRequest events_request);
/**
* Function to get the current time window of the current tab.