03d7fdf3 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 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 | |
21 | /*! \defgroup guiEvents libguiControlFlow: The GUI ControlFlow display plugin */ |
22 | /*\@{*/ |
23 | |
24 | /*! \file guiControlFlow.c |
25 | * \brief Graphical plugin for showing control flow of a trace. |
26 | * |
27 | * This plugin adds a Control Flow Viewer functionnality to Linux TraceToolkit |
28 | * GUI when this plugin is loaded. The init and destroy functions add the |
29 | * viewer's insertion menu item and toolbar icon by calling viewer.h's |
30 | * API functions. Then, when a viewer's object is created, the constructor |
31 | * creates ans register through API functions what is needed to interact |
32 | * with the TraceSet window. |
33 | * |
34 | * This plugin uses the gdk library to draw the events and gtk to interact |
35 | * with the user. |
36 | * |
37 | * Author : Mathieu Desnoyers, June 2003 |
38 | */ |
39 | |
40 | #ifdef HAVE_CONFIG_H |
41 | #include <config.h> |
42 | #endif |
43 | |
44 | #include <glib.h> |
45 | #include <lttv/lttv.h> |
46 | #include <lttv/module.h> |
47 | #include <lttvwindow/lttvwindow.h> |
48 | |
49 | #include "xfv.h" |
50 | #include "lttv_plugin_xfv.h" |
51 | #include "xenoltt_eventhooks.h" |
52 | |
53 | #include "hGuiControlFlowInsert.xpm" |
54 | #include "hLegendInsert.xpm" |
55 | #include "hGuiSimulationInsert.xpm" |
56 | |
57 | GQuark LTT_NAME_CPU; |
58 | |
59 | /** Array containing instanced objects. Used when module is unloaded */ |
60 | GSList *g_xenoltt_data_list = NULL ; |
61 | |
62 | GSList *g_legend_list = NULL ; |
63 | |
64 | /***************************************************************************** |
65 | * Functions for module loading/unloading * |
66 | *****************************************************************************/ |
67 | /** |
68 | * plugin's init function |
69 | * |
70 | * This function initializes the Control Flow Viewer functionnality through the |
71 | * gtkTraceSet API. |
72 | */ |
73 | static void init() { |
74 | |
75 | g_info("GUI Xenomai Event Viewer init()"); |
76 | |
77 | /* Register the toolbar insert button and menu entry*/ |
78 | lttvwindow_register_constructor("guixenoltt", |
79 | "/", |
80 | "Insert Xenomai Event Viewer", |
81 | hGuiXenoLTTInsert_xpm, |
82 | "Insert Xenomai Event Viewer", |
83 | h_guixenoltt); |
84 | |
85 | lttvwindow_register_constructor("guixenolttlegend", |
86 | "/", |
87 | "Popup Xenomai Event Viewer Legend", |
88 | hLegendInsert_xpm, |
89 | "Popup Xenomai Event Viewer Legend", |
90 | h_xenolttlegend); |
91 | |
92 | lttvwindow_register_constructor("guixenolttsimulation", |
93 | "/", |
94 | "Popup Xenomai Simulation Window", |
95 | hGuiSimulationInsert_xpm, |
96 | "Popup Xenomai Simulation Window", |
97 | h_xenolttsimulation); |
98 | |
99 | LTT_NAME_CPU = g_quark_from_string("/cpu"); |
100 | |
101 | } |
102 | |
103 | void destroy_walk(gpointer data, gpointer user_data) |
104 | { |
105 | g_info("Walk destroy GUI Xenomai Event Viewer"); |
106 | guixenoltt_destructor_full((LttvPluginXFV*)data); |
107 | } |
108 | |
109 | void destroy_legend_walk(gpointer data, gpointer user_data) |
110 | { |
111 | g_info("Walk destroy GUI Xenomai Event Viewer"); |
112 | xenolttlegend_destructor((GtkWindow*)data); |
113 | } |
114 | |
115 | void destroy_simulation_walk(gpointer data, gpointer user_data) |
116 | { |
117 | g_info("Walk destroy GUI Xenomai Simulation Window"); |
118 | xenolttlegend_destructor((GtkWindow*)data); |
119 | } |
120 | /** |
121 | * plugin's destroy function |
122 | * |
123 | * This function releases the memory reserved by the module and unregisters |
124 | * everything that has been registered in the gtkTraceSet API. |
125 | */ |
126 | static void destroy() { |
127 | g_info("GUI Xenomai Event Viewer destroy()"); |
128 | |
129 | g_slist_foreach(g_xenoltt_data_list, destroy_walk, NULL ); |
130 | |
131 | g_slist_free(g_xenoltt_data_list); |
132 | |
133 | g_slist_foreach(g_legend_list, destroy_legend_walk, NULL ); |
134 | |
135 | g_slist_free(g_xenoltt_data_list); |
136 | |
137 | /* Unregister the toolbar insert button and menu entry */ |
138 | lttvwindow_unregister_constructor(h_guixenoltt); |
139 | lttvwindow_unregister_constructor(h_xenolttlegend); |
140 | lttvwindow_unregister_constructor(h_xenolttsimulation); |
141 | } |
142 | |
143 | |
144 | LTTV_MODULE("guixenoltt", "Xenomai Event viewer", \ |
145 | "Graphical module to view Xenomai Task state and control flow", \ |
146 | init, destroy, "lttvwindow", "xenoltt_sim") |