| 1 | /* This file is part of the Linux Trace Toolkit Graphic User Interface |
| 2 | * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation; |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 16 | * MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | /* |
| 20 | This file is what every viewer plugin writer should refer to. |
| 21 | |
| 22 | |
| 23 | Module Related API |
| 24 | |
| 25 | A viewer plugin is, before anything, a plugin. As a dynamically loadable |
| 26 | module, it thus has an init and a destroy function called whenever it is |
| 27 | loaded/initialized and unloaded/destroyed. A graphical module depends on |
| 28 | lttvwindow for construction of its viewer instances. In order to achieve |
| 29 | this, it must register its constructor function to the main window along |
| 30 | with button description or text menu entry description. A module keeps |
| 31 | a list of every viewer that currently sits in memory so it can destroy |
| 32 | them before the module gets unloaded/destroyed. |
| 33 | |
| 34 | The contructor registration to the main windows adds button and menu |
| 35 | entry to each main window, thus allowing instanciation of viewers. |
| 36 | |
| 37 | |
| 38 | Main Window |
| 39 | |
| 40 | The main window is a container that offers menus, buttons and a |
| 41 | notebook. Some of those menus and buttons are part of the core of the |
| 42 | main window, others are dynamically added and removed when modules are |
| 43 | loaded/unloaded. |
| 44 | |
| 45 | The notebook contains as much tabs as wanted. Each tab is linked with |
| 46 | a set of traces (traceset). Each trace contains many tracefiles (one |
| 47 | per cpu). A trace corresponds to a kernel being traced. A traceset |
| 48 | corresponds to many traces read together. The time span of a traceset |
| 49 | goes from the earliest start of all the traces to the latest end of all |
| 50 | the traces. |
| 51 | |
| 52 | Inside each tab are added the viewers. When they interact with the main |
| 53 | window through the lttvwindow API, they affect the other viewers located |
| 54 | in the same tab as they are. |
| 55 | |
| 56 | The insertion of many viewers in a tab permits a quick look at all the |
| 57 | information wanted in a glance. The main window does merge the read |
| 58 | requests from all the viewers in the same tab in a way that every viewer |
| 59 | will get exactly the events it asked for, while the event reading loop |
| 60 | and state update are shared. It improves performance of events delivery |
| 61 | to the viewers. |
| 62 | |
| 63 | |
| 64 | |
| 65 | Viewer Instance Related API |
| 66 | |
| 67 | The lifetime of a viewer is as follows. The viewer constructor function |
| 68 | is called each time an instance view is created (one subwindow of this |
| 69 | viewer type is created by the user either by clicking on the menu item |
| 70 | or the button corresponding to the viewer). Thereafter, the viewer gets |
| 71 | hooks called for different purposes by the window containing it. These |
| 72 | hooks are detailed below. It also has to deal with GTK Events. Finally, |
| 73 | it can be destructed by having its top level widget unreferenced by the |
| 74 | main window or by any GTK Event causing a "destroy-event" signal on the |
| 75 | its top widget. Another possible way for it do be destroyed is if the |
| 76 | module gets unloaded. The module unload function will have to emit a |
| 77 | "destroy" signal on each top level widget of all instances of its viewers. |
| 78 | |
| 79 | |
| 80 | Notices from Main Window |
| 81 | |
| 82 | time_window : This is the time interval visible on the viewer's tab. Every |
| 83 | viewer that cares about being synchronised by respect to the |
| 84 | time with other viewers should register to this notification. |
| 85 | They should redraw all or part of their display when this occurs. |
| 86 | |
| 87 | traceset : This notification is called whenever a trace is added/removed |
| 88 | from the traceset. As it affects all the data displayed by the |
| 89 | viewer, it sould redraw itself totally. |
| 90 | |
| 91 | filter : FIXME : describe.. |
| 92 | |
| 93 | current_time: Being able to zoom nearer a specific time or highlight a specific |
| 94 | time on every viewer in synchronicity implies that the viewer |
| 95 | has to shown a visual sign over the drawing or select an event |
| 96 | when it receives this notice. It should also inform the main |
| 97 | window with the appropriate report API function when a user |
| 98 | selects a specific time as being the current time. |
| 99 | |
| 100 | dividor : This notice links the positions of the horizontal dividors |
| 101 | between the graphic display zone of every viewer and their Y axis, |
| 102 | typically showing processes, cpus, ... |
| 103 | |
| 104 | |
| 105 | Reporting Changes to the Main Window |
| 106 | |
| 107 | In most cases, the enclosing window knows about updates such as described |
| 108 | in the Notification section higher. There are a few cases, however, where |
| 109 | updates are caused by actions known by a view instance. For example, |
| 110 | clicking in a view may update the current time; all viewers within |
| 111 | the same window must be told about the new current time to change the |
| 112 | currently highlighted time point. A viewer reports such events by calling |
| 113 | lttvwindow_report_current_time on its lttvwindow. The lttvwindow will |
| 114 | consequently call current_time_notify for each of its contained viewers. |
| 115 | |
| 116 | |
| 117 | Available report methods are : |
| 118 | |
| 119 | lttvwindow_report_time_window : reports the new time window. |
| 120 | lttvwindow_report_current_time : reports the new current time. |
| 121 | lttvwindow_report_dividor : reports the new horizontal dividor's position. |
| 122 | lttvwindow_report_filter : reports the new filter object |
| 123 | |
| 124 | |
| 125 | |
| 126 | Requesting Events to Main Window |
| 127 | |
| 128 | Events can be requested by passing a EventsRequest structure to the main |
| 129 | window. They will be delivered later when the next g_idle functions |
| 130 | will be called. Event delivery is done by calling the event hook for |
| 131 | this event ID, or the main event hooks. A pointer to the EventsRequest |
| 132 | structure is passed as hook_data to the event hooks of the viewers. |
| 133 | |
| 134 | EventsRequest consists in |
| 135 | - a pointer to the viewer specific data structure |
| 136 | - a start timestamp or position |
| 137 | - a stop_flag, ending the read process when set to TRUE |
| 138 | - a end timestamp and/or position and/or number of events to read |
| 139 | - hook lists to call for traceset/trace/tracefile begin and end, and for each |
| 140 | event (event hooks and event_by_id hooks). |
| 141 | |
| 142 | The main window will deliver events for every EventRequests it has |
| 143 | pending through an algorithm that guarantee that all events requested, |
| 144 | and only them, will be delivered to the viewer between the call of the |
| 145 | tracefile_begin hooks and the call of the tracefile_end hooks. |
| 146 | |
| 147 | If a viewer wants to stop the event request at a certain point inside the |
| 148 | event hooks, it has to set the stop_flag to TRUE and return TRUE from the |
| 149 | hook function. Then return value will stop the process traceset. Then, |
| 150 | the main window will look for the stop_flag and remove the EventRequests |
| 151 | from its lists, calling the process_traceset_end for this request (it |
| 152 | removes hooks from the context and calls the after hooks). |
| 153 | |
| 154 | It no stop_flag is risen, the end timestamp, end position or number |
| 155 | of events to read has to be reached to determine the end of the |
| 156 | request. Otherwise, the end of traceset does determine it. |
| 157 | |
| 158 | |
| 159 | GTK Events |
| 160 | |
| 161 | Events and Signals |
| 162 | |
| 163 | GTK is quite different from the other graphical toolkits around |
| 164 | there. The main difference resides in that there are many X Windows |
| 165 | inside one GtkWindow, instead of just one. That means that X events are |
| 166 | delivered by the glib main loop directly to the widget corresponding to |
| 167 | the GdkWindow affected by the X event. |
| 168 | |
| 169 | Event delivery to a widget emits a signal on that widget. Then, if a |
| 170 | handler is connected to this widget's signal, it will be executed. There |
| 171 | are default handlers for signals, connected at class instantiation |
| 172 | time. There is also the possibility to connect other handlers to these |
| 173 | signals, which is what should be done in most cases when a viewer needs |
| 174 | to interact with X in any way. |
| 175 | |
| 176 | |
| 177 | |
| 178 | Signal emission and propagation is described there : |
| 179 | |
| 180 | http://www.gtk.org/tutorial/sec-signalemissionandpropagation.html |
| 181 | |
| 182 | For further information on the GTK main loop (now a wrapper over glib main loop) |
| 183 | see : |
| 184 | |
| 185 | http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html |
| 186 | http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html |
| 187 | |
| 188 | |
| 189 | For documentation on event handling in GTK/GDK, see : |
| 190 | |
| 191 | http://developer.gnome.org/doc/API/2.0/gdk/gdk-Events.html |
| 192 | http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html |
| 193 | |
| 194 | |
| 195 | Signals can be connected to handlers, emitted, propagated, blocked, |
| 196 | stopped. See : |
| 197 | |
| 198 | http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | The "expose_event" |
| 204 | |
| 205 | Provides the exposed region in the GdkEventExpose structure. |
| 206 | |
| 207 | There are two ways of dealing with exposures. The first one is to directly |
| 208 | draw on the screen and the second one is to draw in a pixmap buffer, |
| 209 | and then to update the screen when necessary. |
| 210 | |
| 211 | In the first case, the expose event will be responsible for registering |
| 212 | hooks to process_traceset and require time intervals to the main |
| 213 | window. So, in this scenario, if a part of the screen is damaged, the |
| 214 | trace has to be read to redraw the screen. |
| 215 | |
| 216 | In the second case, with a pixmap buffer, the expose handler is only |
| 217 | responsible of showing the pixmap buffer on the screen. If the pixmap |
| 218 | buffer has never been filled with a drawing, the expose handler may ask |
| 219 | for it to be filled. |
| 220 | |
| 221 | The interest of using events request to the main window instead of reading |
| 222 | the events directly from the trace comes from the fact that the main |
| 223 | window does merge requests from the different viewers in the same tab so |
| 224 | that the read loop and the state update is shared. As viewers will, in |
| 225 | the common scenario, request the same events, only one pass through the |
| 226 | trace that will call the right hooks for the right intervals will be done. |
| 227 | |
| 228 | When the traceset read is over for a events request, the traceset_end |
| 229 | hook is called. It has the responsibility of finishing the drawing if |
| 230 | some parts still need to be drawn and to show it on the screen (if the |
| 231 | viewer uses a pixmap buffer). |
| 232 | |
| 233 | It can add dotted lines and such visual effects to enhance the user's |
| 234 | experience. |
| 235 | |
| 236 | |
| 237 | FIXME : explain other important events |
| 238 | |
| 239 | */ |
| 240 | |
| 241 | |
| 242 | #ifndef LTTVWINDOW_H |
| 243 | #define LTTVWINDOW_H |
| 244 | |
| 245 | /*! \file lttvwindow.h |
| 246 | * \brief API used by the graphical viewers to interact with their top window. |
| 247 | * |
| 248 | * Main window (lttvwindow module) is the place to contain and display viewers. |
| 249 | * Viewers (lttv plugins) interact with main window through this API. |
| 250 | * This header file should be included in each graphic module. |
| 251 | * |
| 252 | */ |
| 253 | |
| 254 | #include <gtk/gtk.h> |
| 255 | #include <ltt/ltt.h> |
| 256 | #include <ltt/time.h> |
| 257 | #include <lttv/hook.h> |
| 258 | #include <lttv/tracecontext.h> |
| 259 | #include <lttv/stats.h> |
| 260 | #include <lttv/filter.h> |
| 261 | #include <lttvwindow/mainwindow.h> |
| 262 | #include <lttvwindow/lttv_plugin.h> |
| 263 | |
| 264 | /* Module Related API */ |
| 265 | |
| 266 | /* GQuark containing constructors of viewers in global attributes */ |
| 267 | extern GQuark LTTV_VIEWER_CONSTRUCTORS; |
| 268 | |
| 269 | /* constructor a the viewer */ |
| 270 | typedef GtkWidget* (*lttvwindow_viewer_constructor)(LttvPlugin *plugin); |
| 271 | |
| 272 | extern gint lttvwindow_preempt_count; |
| 273 | |
| 274 | #define CHECK_GDK_INTERVAL 50000 |
| 275 | |
| 276 | /** |
| 277 | * Function to register a view constructor so that main window can generate |
| 278 | * a menu item and a toolbar item for the viewer in order to generate a new |
| 279 | * instance easily. A menu entry and toolbar item will be added to each main |
| 280 | * window. |
| 281 | * |
| 282 | * It should be called by init function of the module. |
| 283 | * |
| 284 | * @param name name of the viewer : mainly used as tag for constructor |
| 285 | * @param menu_path path of the menu item. NULL : no menu entry. |
| 286 | * @param menu_text text of the menu item. |
| 287 | * @param pixmap Image shown on the toolbar item. NULL : no button. |
| 288 | * @param tooltip tooltip of the toolbar item. |
| 289 | * @param view_constructor constructor of the viewer. |
| 290 | */ |
| 291 | |
| 292 | void lttvwindow_register_constructor |
| 293 | (char * name, |
| 294 | char * menu_path, |
| 295 | char * menu_text, |
| 296 | char ** pixmap, |
| 297 | char * tooltip, |
| 298 | lttvwindow_viewer_constructor view_constructor); |
| 299 | |
| 300 | |
| 301 | /** |
| 302 | * Function to unregister the viewer's constructor, release the space |
| 303 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the |
| 304 | * viewer. |
| 305 | * |
| 306 | * It will be called when a module is unloaded. |
| 307 | * |
| 308 | * @param view_constructor constructor of the viewer. |
| 309 | */ |
| 310 | |
| 311 | void lttvwindow_unregister_constructor |
| 312 | (lttvwindow_viewer_constructor view_constructor); |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | /* Viewer Instance Related API */ |
| 318 | |
| 319 | /** |
| 320 | * Structure used as hook_data for the time_window_notify hook. |
| 321 | */ |
| 322 | typedef struct _TimeWindowNotifyData { |
| 323 | TimeWindow *new_time_window; |
| 324 | TimeWindow *old_time_window; |
| 325 | } TimeWindowNotifyData; |
| 326 | |
| 327 | |
| 328 | /** |
| 329 | * Function to register a hook function that will be called by the main window |
| 330 | * when the time interval needs to be updated. |
| 331 | * |
| 332 | * This register function is typically called by the constructor of the viewer. |
| 333 | * |
| 334 | * @param tab the tab the viewer belongs to. |
| 335 | * @param hook hook that sould be called by the main window when the time |
| 336 | * interval changes. This hook function takes a |
| 337 | * TimeWindowNotifyData* as call_data. |
| 338 | * @param hook_data hook data associated with the hook function. It will |
| 339 | * be typically a pointer to the viewer's data structure. |
| 340 | */ |
| 341 | |
| 342 | void lttvwindow_register_time_window_notify(Tab *tab, |
| 343 | LttvHook hook, |
| 344 | gpointer hook_data); |
| 345 | |
| 346 | |
| 347 | /** |
| 348 | * Function to unregister the time_window notification hook. |
| 349 | * |
| 350 | * This unregister function is typically called by the destructor of the viewer. |
| 351 | * |
| 352 | * @param tab the tab the viewer belongs to. |
| 353 | * @param hook hook that sould be called by the main window when the time |
| 354 | * interval changes. This hook function takes a |
| 355 | * TimeWindowNotifyData* as call_data. |
| 356 | * @param hook_data hook data associated with the hook function. It will |
| 357 | * be typically a pointer to the viewer's data structure. |
| 358 | */ |
| 359 | |
| 360 | void lttvwindow_unregister_time_window_notify(Tab *tab, |
| 361 | LttvHook hook, |
| 362 | gpointer hook_data); |
| 363 | |
| 364 | |
| 365 | /** |
| 366 | * Function to register a hook function that will be called by the main window |
| 367 | * when the traceset is changed. That means that the viewer must redraw |
| 368 | * itself completely or check if it's affected by the particular change to the |
| 369 | * traceset. |
| 370 | * |
| 371 | * This register function is typically called by the constructor of the viewer. |
| 372 | * |
| 373 | * @param tab the tab the viewer belongs to. |
| 374 | * @param hook hook that should be called whenever a change to the traceset |
| 375 | * occurs. The call_data of this hook is a NULL pointer. |
| 376 | * @param hook_data hook data associated with the hook function. It will |
| 377 | * be typically a pointer to the viewer's data structure. |
| 378 | */ |
| 379 | |
| 380 | void lttvwindow_register_traceset_notify(Tab *tab, |
| 381 | LttvHook hook, |
| 382 | gpointer hook_data); |
| 383 | |
| 384 | |
| 385 | /** |
| 386 | * Function to unregister the traceset_notify hook. |
| 387 | * |
| 388 | * @param tab the tab the viewer belongs to. |
| 389 | * @param hook hook that should be called whenever a change to the traceset |
| 390 | * occurs. The call_data of this hook is a NULL pointer. |
| 391 | * @param hook_data hook data associated with the hook function. It will |
| 392 | * be typically a pointer to the viewer's data structure. |
| 393 | */ |
| 394 | |
| 395 | void lttvwindow_unregister_traceset_notify(Tab *tab, |
| 396 | LttvHook hook, |
| 397 | gpointer hook_data); |
| 398 | |
| 399 | |
| 400 | /** |
| 401 | * Function to register a hook function for a viewer be completely redrawn. |
| 402 | * |
| 403 | * @param tab viewer's tab |
| 404 | * @param hook hook function of the viewer. |
| 405 | * @param hook_data hook data associated with the hook function. |
| 406 | */ |
| 407 | |
| 408 | void lttvwindow_register_redraw_notify(Tab *tab, |
| 409 | LttvHook hook, gpointer hook_data); |
| 410 | |
| 411 | /** |
| 412 | * Function to unregister a hook function for a viewer be completely redrawn. |
| 413 | * |
| 414 | * @param tab viewer's tab |
| 415 | * @param hook hook function of the viewer. |
| 416 | * @param hook_data hook data associated with the hook function. |
| 417 | */ |
| 418 | |
| 419 | void lttvwindow_unregister_redraw_notify(Tab *tab, |
| 420 | LttvHook hook, gpointer hook_data); |
| 421 | |
| 422 | |
| 423 | /** |
| 424 | * Function to register a hook function for a viewer to re-do the events |
| 425 | * requests for the needed interval. |
| 426 | * |
| 427 | * This action is typically done after a "stop". |
| 428 | * |
| 429 | * The typical hook will remove all current requests for the viewer |
| 430 | * and make requests for missing information. |
| 431 | * |
| 432 | * @param tab viewer's tab |
| 433 | * @param hook hook function of the viewer. |
| 434 | * @param hook_data hook data associated with the hook function. |
| 435 | */ |
| 436 | |
| 437 | void lttvwindow_register_continue_notify(Tab *tab, |
| 438 | LttvHook hook, gpointer hook_data); |
| 439 | |
| 440 | |
| 441 | /** |
| 442 | * Function to unregister a hook function for a viewer to re-do the events |
| 443 | * requests for the needed interval. |
| 444 | * |
| 445 | * @param tab viewer's tab |
| 446 | * @param hook hook function of the viewer. |
| 447 | * @param hook_data hook data associated with the hook function. |
| 448 | */ |
| 449 | |
| 450 | void lttvwindow_unregister_continue_notify(Tab *tab, |
| 451 | LttvHook hook, gpointer hook_data); |
| 452 | |
| 453 | |
| 454 | /** |
| 455 | * Function to register a hook function for a viewer to set/update its |
| 456 | * filter. |
| 457 | * |
| 458 | * FIXME : Add information about what a filter is as seen from a viewer and how |
| 459 | * to use it. |
| 460 | * |
| 461 | * This register function is typically called by the constructor of the viewer. |
| 462 | * |
| 463 | * @param tab the tab the viewer belongs to. |
| 464 | * @param hook hook function called by the main window when a filter change |
| 465 | * occurs. |
| 466 | * @param hook_data hook data associated with the hook function. It will |
| 467 | * be typically a pointer to the viewer's data structure. |
| 468 | */ |
| 469 | |
| 470 | void lttvwindow_register_filter_notify(Tab *tab, |
| 471 | LttvHook hook, |
| 472 | gpointer hook_data); |
| 473 | |
| 474 | |
| 475 | /** |
| 476 | * Function to unregister a viewer's hook function which is used to |
| 477 | * set/update the filter of the viewer. |
| 478 | * |
| 479 | * This unregistration is called by the destructor of the viewer. |
| 480 | * |
| 481 | * @param tab the tab the viewer belongs to. |
| 482 | * @param hook hook function called by the main window when a filter change |
| 483 | * occurs. |
| 484 | * @param hook_data hook data associated with the hook function. It will |
| 485 | * be typically a pointer to the viewer's data structure. |
| 486 | */ |
| 487 | |
| 488 | void lttvwindow_unregister_filter_notify(Tab *tab, |
| 489 | LttvHook hook, |
| 490 | gpointer hook_data); |
| 491 | |
| 492 | |
| 493 | /** |
| 494 | * Function to get the current filter of the main window : useful at viewer |
| 495 | * instanciation. |
| 496 | * |
| 497 | * @param tab the tab the viewer belongs to. |
| 498 | * |
| 499 | * returns : the current filter. |
| 500 | */ |
| 501 | |
| 502 | |
| 503 | LttvFilter *lttvwindow_get_filter(Tab *tab); |
| 504 | |
| 505 | /** |
| 506 | * Function to register a hook function for a viewer to set/update its |
| 507 | * current time. |
| 508 | * |
| 509 | * @param tab the tab the viewer belongs to. |
| 510 | * @param hook hook function of the viewer that updates the current time. The |
| 511 | * call_data is a LttTime* representing the new current time. |
| 512 | * @param hook_data hook data associated with the hook function. It will |
| 513 | * be typically a pointer to the viewer's data structure. |
| 514 | */ |
| 515 | |
| 516 | void lttvwindow_register_current_time_notify(Tab *tab, |
| 517 | LttvHook hook, |
| 518 | gpointer hook_data); |
| 519 | |
| 520 | |
| 521 | /** |
| 522 | * Function to unregister a viewer's hook function which is used to |
| 523 | * set/update the current time of the viewer. |
| 524 | * @param tab the tab the viewer belongs to. |
| 525 | * @param hook hook function of the viewer that updates the current time. The |
| 526 | * call_data is a LttTime* representing the new current time. |
| 527 | * @param hook_data hook data associated with the hook function. It will |
| 528 | * be typically a pointer to the viewer's data structure. |
| 529 | */ |
| 530 | |
| 531 | void lttvwindow_unregister_current_time_notify(Tab *tab, |
| 532 | LttvHook hook, |
| 533 | gpointer hook_data); |
| 534 | |
| 535 | /** |
| 536 | * Function to register a hook function for a viewer to set/update its |
| 537 | * current position. |
| 538 | * |
| 539 | * @param tab the tab the viewer belongs to. |
| 540 | * @param hook hook function of the viewer that updates the current time. The |
| 541 | * call_data is a LttTime* representing the new current time. |
| 542 | * @param hook_data hook data associated with the hook function. It will |
| 543 | * be typically a pointer to the viewer's data structure. |
| 544 | */ |
| 545 | |
| 546 | void lttvwindow_register_current_position_notify(Tab *tab, |
| 547 | LttvHook hook, |
| 548 | gpointer hook_data); |
| 549 | |
| 550 | |
| 551 | /** |
| 552 | * Function to unregister a viewer's hook function which is used to |
| 553 | * set/update the current position of the viewer. |
| 554 | * @param tab the tab the viewer belongs to. |
| 555 | * @param hook hook function of the viewer that updates the current time. The |
| 556 | * call_data is a LttTime* representing the new current time. |
| 557 | * @param hook_data hook data associated with the hook function. It will |
| 558 | * be typically a pointer to the viewer's data structure. |
| 559 | */ |
| 560 | |
| 561 | void lttvwindow_unregister_current_position_notify(Tab *tab, |
| 562 | LttvHook hook, |
| 563 | gpointer hook_data); |
| 564 | |
| 565 | |
| 566 | |
| 567 | /** |
| 568 | * Function to register a hook function for a viewer to set/update the |
| 569 | * dividor of the hpane. It provides a way to make the horizontal |
| 570 | * dividors of all the viewers linked together. |
| 571 | * |
| 572 | * @param tab the tab the viewer belongs to. |
| 573 | * @param hook hook function of the viewer that will be called whenever a |
| 574 | * dividor changes in another viewer. The call_data of this hook |
| 575 | * is a gint*. The value of the integer is the new position of the |
| 576 | * hpane dividor. |
| 577 | * @param hook_data hook data associated with the hook function. It will |
| 578 | * be typically a pointer to the viewer's data structure. |
| 579 | */ |
| 580 | |
| 581 | void lttvwindow_register_dividor(Tab *tab, |
| 582 | LttvHook hook, |
| 583 | gpointer hook_data); |
| 584 | |
| 585 | |
| 586 | /** |
| 587 | * Function to unregister a viewer's hook function which is used to |
| 588 | * set/update hpane's dividor of the viewer. |
| 589 | * |
| 590 | * @param tab the tab the viewer belongs to. |
| 591 | * @param hook hook function of the viewer that will be called whenever a |
| 592 | * dividor changes in another viewer. The call_data of this hook |
| 593 | * is a gint*. The value of the integer is the new position of the |
| 594 | * hpane dividor. |
| 595 | * @param hook_data hook data associated with the hook function. It will |
| 596 | * be typically a pointer to the viewer's data structure. |
| 597 | */ |
| 598 | |
| 599 | void lttvwindow_unregister_dividor(Tab *tab, |
| 600 | LttvHook hook, |
| 601 | gpointer hook_data); |
| 602 | |
| 603 | |
| 604 | |
| 605 | /** |
| 606 | * Function to set the time interval of the current tab.a |
| 607 | * |
| 608 | * @param tab the tab the viewer belongs to. |
| 609 | * @param time_interval new time window. |
| 610 | */ |
| 611 | |
| 612 | void lttvwindow_report_time_window(Tab *tab, |
| 613 | TimeWindow time_window); |
| 614 | |
| 615 | /** |
| 616 | * Function to set the current time of the current tab. |
| 617 | * It will be called by a viewer's signal handle associated with |
| 618 | * the button-release-event signal |
| 619 | * @param tab the tab the viewer belongs to. |
| 620 | * @param time current time. |
| 621 | */ |
| 622 | |
| 623 | void lttvwindow_report_current_time(Tab *tab, |
| 624 | LttTime time); |
| 625 | |
| 626 | |
| 627 | /** |
| 628 | * Function to set the current event of the current tab. |
| 629 | * It will be called by a viewer's signal handle associated with |
| 630 | * the button-release-event signal |
| 631 | * @param tab the tab the viewer belongs to. |
| 632 | * @param pos the current position. |
| 633 | */ |
| 634 | |
| 635 | void lttvwindow_report_current_position(Tab *tab, |
| 636 | LttvTracesetContextPosition *pos); |
| 637 | |
| 638 | /** |
| 639 | * Function to set the position of the hpane's dividor (viewer). |
| 640 | * It will typically be called by a viewer's signal handle associated |
| 641 | * with the motion_notify_event event/signal. |
| 642 | * |
| 643 | * @param tab the tab the viewer belongs to. |
| 644 | * @param position position of the hpane's dividor. |
| 645 | */ |
| 646 | |
| 647 | void lttvwindow_report_dividor(Tab *tab, gint position); |
| 648 | |
| 649 | |
| 650 | /* Structure sent to the events request hook */ |
| 651 | /* Value considered as empty*/ |
| 652 | typedef struct _EventsRequest { |
| 653 | gpointer owner; /* Owner of the request */ |
| 654 | gpointer viewer_data; /* Unset : NULL */ |
| 655 | gboolean servicing; /* service in progress: TRUE*/ |
| 656 | LttTime start_time; /* Unset : ltt_time_infinite*/ |
| 657 | LttvTracesetContextPosition *start_position; /* Unset : NULL */ |
| 658 | gboolean stop_flag; /* Continue:TRUE Stop:FALSE */ |
| 659 | LttTime end_time; /* Unset : ltt_time_infinite*/ |
| 660 | guint num_events; /* Unset : G_MAXUINT */ |
| 661 | LttvTracesetContextPosition *end_position; /* Unset : NULL */ |
| 662 | gint trace; /* unset : -1 */ |
| 663 | GArray *hooks; /* Unset : NULL */ |
| 664 | LttvHooks *before_chunk_traceset; /* Unset : NULL */ |
| 665 | LttvHooks *before_chunk_trace; /* Unset : NULL */ |
| 666 | LttvHooks *before_chunk_tracefile;/* Unset : NULL */ |
| 667 | LttvHooks *event; /* Unset : NULL */ |
| 668 | LttvHooksById *event_by_id; /* Unset : NULL */ |
| 669 | LttvHooks *after_chunk_tracefile; /* Unset : NULL */ |
| 670 | LttvHooks *after_chunk_trace; /* Unset : NULL */ |
| 671 | LttvHooks *after_chunk_traceset; /* Unset : NULL */ |
| 672 | LttvHooks *before_request; /* Unset : NULL */ |
| 673 | LttvHooks *after_request; /* Unset : NULL */ |
| 674 | } EventsRequest; |
| 675 | |
| 676 | /* Maximum number of events to proceed at once in a chunk */ |
| 677 | #define CHUNK_NUM_EVENTS 6000 |
| 678 | |
| 679 | |
| 680 | /** |
| 681 | * Function to request data in a specific time interval to the main window. The |
| 682 | * event request servicing is differed until the glib idle functions are |
| 683 | * called. |
| 684 | * |
| 685 | * The viewer has to provide hooks that should be associated with the event |
| 686 | * request. |
| 687 | * |
| 688 | * Either start time or start position must be defined in a EventRequest |
| 689 | * structure for it to be valid. |
| 690 | * |
| 691 | * end_time, end_position and num_events can all be defined. The first one |
| 692 | * to occur will be used as end criterion. |
| 693 | * |
| 694 | * The events_request memory will be managed by the main window once its |
| 695 | * pointer is passed by this function. |
| 696 | * |
| 697 | * @param tab the tab the viewer belongs to. |
| 698 | * @param events_requested Details about the event request. |
| 699 | */ |
| 700 | |
| 701 | void lttvwindow_events_request(Tab *tab, |
| 702 | EventsRequest *events_request); |
| 703 | |
| 704 | /** |
| 705 | * Function to remove data requests related to a viewer. |
| 706 | * |
| 707 | * The existing requests's viewer gpointer is compared to the pointer |
| 708 | * given in argument to establish which data request should be removed. |
| 709 | * |
| 710 | * @param tab the tab the viewer belongs to. |
| 711 | * @param viewer a pointer to the viewer data structure |
| 712 | */ |
| 713 | |
| 714 | void lttvwindow_events_request_remove_all(Tab *tab, |
| 715 | gconstpointer viewer); |
| 716 | |
| 717 | |
| 718 | /** |
| 719 | * Function to see if there are events request pending. |
| 720 | * |
| 721 | * It tells if events requests are pending. Useful for checks in some events, |
| 722 | * i.e. detailed event list scrolling. |
| 723 | * |
| 724 | * @param tab the tab the viewer belongs to. |
| 725 | * @param viewer a pointer to the viewer data structure |
| 726 | * @return : TRUE is events requests are pending, else FALSE. |
| 727 | */ |
| 728 | |
| 729 | gboolean lttvwindow_events_request_pending(Tab *tab); |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | /** |
| 735 | * Function to get the current time interval shown on the current tab. |
| 736 | * It will be called by a viewer's hook function to update the |
| 737 | * shown time interval of the viewer and also be called by the constructor |
| 738 | * of the viewer. |
| 739 | * @param tab viewer's tab |
| 740 | * @return time window. |
| 741 | */ |
| 742 | |
| 743 | TimeWindow lttvwindow_get_time_window(Tab *tab); |
| 744 | |
| 745 | |
| 746 | /** |
| 747 | * Function to get the current time of the current tab. |
| 748 | * |
| 749 | * @param tab the tab the viewer belongs to. |
| 750 | * @return the current tab's current time. |
| 751 | */ |
| 752 | |
| 753 | LttTime lttvwindow_get_current_time(Tab *tab); |
| 754 | |
| 755 | |
| 756 | /** |
| 757 | * Function to get the filter of the current tab. |
| 758 | * @param main_win, the main window the viewer belongs to. |
| 759 | * @param filter, a pointer to a filter. |
| 760 | */ |
| 761 | |
| 762 | //LttvFilter *lttvwindow_get_filter(Tab *tab); |
| 763 | |
| 764 | /** |
| 765 | * Function to set the filter of the current tab. |
| 766 | * It should be called by the filter GUI to tell the |
| 767 | * main window to update the filter tab's lttv_filter. |
| 768 | * |
| 769 | * Notice : the lttv_filter object will be owned by the |
| 770 | * main window after the return of this function. |
| 771 | * Do NOT desallocate it. |
| 772 | * |
| 773 | * @param main_win, the main window the viewer belongs to. |
| 774 | * @param filter, a pointer to a filter. |
| 775 | */ |
| 776 | |
| 777 | void lttvwindow_report_filter(Tab *tab, LttvFilter *filter); |
| 778 | |
| 779 | |
| 780 | |
| 781 | /** |
| 782 | * Function to get the stats of the traceset |
| 783 | * It must be non const so the viewer can modify it. |
| 784 | * FIXME : a set/get pair of functions would be more appropriate here. |
| 785 | * @param tab the tab the viewer belongs to. |
| 786 | * @return A pointer to Traceset statistics. |
| 787 | */ |
| 788 | |
| 789 | LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab); |
| 790 | |
| 791 | /** |
| 792 | * Function to get the context of the traceset |
| 793 | * It must be non const so the viewer can add and remove hooks from it. |
| 794 | * @param tab the tab the viewer belongs to. |
| 795 | * @return Context of the current tab. |
| 796 | */ |
| 797 | |
| 798 | |
| 799 | LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab); |
| 800 | |
| 801 | |
| 802 | /* set_time_window |
| 803 | * |
| 804 | * It updates the time window of the tab, then calls the updatetimewindow |
| 805 | * hooks of each viewer. |
| 806 | * |
| 807 | * This is called whenever the scrollbar value changes. |
| 808 | * |
| 809 | * This is mostly an internal function. |
| 810 | */ |
| 811 | |
| 812 | void set_time_window(Tab *tab, const TimeWindow *time_window); |
| 813 | |
| 814 | |
| 815 | /* set_current_time |
| 816 | * |
| 817 | * It updates the current time of the tab, then calls the updatetimewindow |
| 818 | * hooks of each viewer. |
| 819 | * |
| 820 | * This is called whenever the current time value changes. |
| 821 | * |
| 822 | * This is mostly an internal function. |
| 823 | */ |
| 824 | |
| 825 | void set_current_time(Tab *tab, const LttTime *current_time); |
| 826 | |
| 827 | void events_request_free(EventsRequest *events_request); |
| 828 | |
| 829 | GtkWidget *main_window_get_widget(Tab *tab); |
| 830 | |
| 831 | void set_current_position(Tab *tab, const LttvTracesetContextPosition *pos); |
| 832 | |
| 833 | |
| 834 | /** |
| 835 | * Function to disable the EventsRequests scheduler, nestable. |
| 836 | * |
| 837 | */ |
| 838 | static inline void lttvwindow_events_request_disable(void) |
| 839 | { |
| 840 | lttvwindow_preempt_count++; |
| 841 | } |
| 842 | |
| 843 | /** |
| 844 | * Function to restore the EventsRequests scheduler, nestable. |
| 845 | * |
| 846 | */ |
| 847 | static inline void lttvwindow_events_request_enable(void) |
| 848 | { |
| 849 | lttvwindow_preempt_count--; |
| 850 | } |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | #endif //LTTVWINDOW_H |