1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Mathieu Desnoyers
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;
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.
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,
27 #include <gdk/gdkkeysyms.h>
29 #include <lttv/lttv.h>
30 #include <lttv/module.h>
31 #include <lttv/hook.h>
33 #include <lttvwindow/lttvwindow.h>
34 #include <lttvwindow/lttvwindowtraces.h>
36 #include "hTraceControlInsert.xpm"
37 #include "TraceControlStart.xpm"
38 #include "TraceControlPause.xpm"
39 #include "TraceControlStop.xpm"
41 #include <sys/types.h>
47 #include <sys/select.h>
49 #define MAX_ARGS_LEN PATH_MAX * 10
51 GSList
*g_control_list
= NULL
;
53 /*! \file lttv/modules/gui/tracecontrol/tracecontrol.c
54 * \brief Graphic trace start/stop control interface.
56 * This plugin interacts with lttctl to start/stop tracing. It needs to take the
57 * root password to be able to interact with lttctl.
61 typedef struct _ControlData ControlData
;
66 GtkWidget
*guicontrol_get_widget(ControlData
*tcd
);
67 ControlData
*gui_control(Tab
*tab
);
68 void gui_control_destructor(ControlData
*tcd
);
69 GtkWidget
* h_guicontrol(Tab
*tab
);
70 void control_destroy_walk(gpointer data
, gpointer user_data
);
76 static void start_clicked (GtkButton
*button
, gpointer user_data
);
77 static void pause_clicked (GtkButton
*button
, gpointer user_data
);
78 static void stop_clicked (GtkButton
*button
, gpointer user_data
);
82 * @struct _ControlData
84 * @brief Main structure of gui control
87 Tab
*tab
; /**< current tab of module */
89 GtkWidget
*window
; /**< window */
91 GtkWidget
*main_box
; /**< main container */
92 GtkWidget
*start_button
;
93 GtkWidget
*pause_button
;
94 GtkWidget
*stop_button
;
95 GtkWidget
*username_label
;
96 GtkWidget
*username_entry
;
97 GtkWidget
*password_label
;
98 GtkWidget
*password_entry
;
99 GtkWidget
*channel_dir_label
;
100 GtkWidget
*channel_dir_entry
;
101 GtkWidget
*trace_dir_label
;
102 GtkWidget
*trace_dir_entry
;
103 GtkWidget
*trace_name_label
;
104 GtkWidget
*trace_name_entry
;
105 GtkWidget
*trace_mode_label
;
106 GtkWidget
*trace_mode_combo
;
107 GtkWidget
*start_daemon_label
;
108 GtkWidget
*start_daemon_check
;
109 GtkWidget
*optional_label
;
110 GtkWidget
*subbuf_size_label
;
111 GtkWidget
*subbuf_size_entry
;
112 GtkWidget
*subbuf_num_label
;
113 GtkWidget
*subbuf_num_entry
;
114 GtkWidget
*lttctl_path_label
;
115 GtkWidget
*lttctl_path_entry
;
116 GtkWidget
*lttd_path_label
;
117 GtkWidget
*lttd_path_entry
;
118 GtkWidget
*fac_path_label
;
119 GtkWidget
*fac_path_entry
;
123 * @fn GtkWidget* guicontrol_get_widget(ControlData*)
125 * This function returns the current main widget
126 * used by this module
127 * @param tcd the module struct
128 * @return The main widget
131 guicontrol_get_widget(ControlData
*tcd
)
137 * @fn ControlData* gui_control(Tab*)
139 * Constructor is used to create ControlData data structure.
140 * @param tab The tab structure used by the widget
141 * @return The Filter viewer data created.
144 gui_control(Tab
*tab
)
146 g_debug("filter::gui_control()");
149 GtkCellRenderer
*renderer
;
150 GtkTreeViewColumn
*column
;
152 ControlData
* tcd
= g_new(ControlData
,1);
156 tcd
->window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
157 gtk_window_set_title(GTK_WINDOW(tcd
->window
), "LTTng Trace Control");
159 * Initiating GtkTable layout
160 * starts with 2 rows and 5 columns and
161 * expands when expressions added
163 tcd
->main_box
= gtk_table_new(14,7,FALSE
);
164 gtk_table_set_row_spacings(GTK_TABLE(tcd
->main_box
),5);
165 gtk_table_set_col_spacings(GTK_TABLE(tcd
->main_box
),5);
167 gtk_container_add(GTK_CONTAINER(tcd
->window
), GTK_WIDGET(tcd
->main_box
));
169 GList
*focus_chain
= NULL
;
172 * start/pause/stop buttons
176 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm
);
177 image
= gtk_image_new_from_pixbuf(pixbuf
);
178 tcd
->start_button
= gtk_button_new_with_label("start");
179 gtk_button_set_image(GTK_BUTTON(tcd
->start_button
), image
);
180 gtk_button_set_alignment(GTK_BUTTON(tcd
->start_button
), 0.0, 0.0);
181 gtk_widget_show (tcd
->start_button
);
182 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->start_button
,6,7,0,1,GTK_FILL
,GTK_FILL
,2,2);
184 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm
);
185 image
= gtk_image_new_from_pixbuf(pixbuf
);
186 tcd
->pause_button
= gtk_button_new_with_label("pause");
187 gtk_button_set_image(GTK_BUTTON(tcd
->pause_button
), image
);
188 gtk_button_set_alignment(GTK_BUTTON(tcd
->pause_button
), 0.0, 0.0);
189 gtk_widget_show (tcd
->pause_button
);
190 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->pause_button
,6,7,1,2,GTK_FILL
,GTK_FILL
,2,2);
192 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm
);
193 image
= gtk_image_new_from_pixbuf(pixbuf
);
194 tcd
->stop_button
= gtk_button_new_with_label("stop");
195 gtk_button_set_image(GTK_BUTTON(tcd
->stop_button
), image
);
196 gtk_button_set_alignment(GTK_BUTTON(tcd
->stop_button
), 0.0, 0.0);
197 gtk_widget_show (tcd
->stop_button
);
198 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->stop_button
,6,7,2,3,GTK_FILL
,GTK_FILL
,2,2);
201 * First half of the filter window
202 * - textual entry of filter expression
203 * - processing button
205 tcd
->username_label
= gtk_label_new("Username:");
206 gtk_widget_show (tcd
->username_label
);
207 tcd
->username_entry
= gtk_entry_new();
208 gtk_entry_set_text(GTK_ENTRY(tcd
->username_entry
),"root");
209 gtk_widget_show (tcd
->username_entry
);
210 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->username_label
,0,2,0,1,GTK_FILL
,GTK_FILL
,2,2);
211 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->username_entry
,2,6,0,1,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
215 tcd
->password_label
= gtk_label_new("Password:");
216 gtk_widget_show (tcd
->password_label
);
217 tcd
->password_entry
= gtk_entry_new();
218 gtk_entry_set_visibility(GTK_ENTRY(tcd
->password_entry
), FALSE
);
219 gtk_widget_show (tcd
->password_entry
);
220 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->password_label
,0,2,1,2,GTK_FILL
,GTK_FILL
,2,2);
221 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->password_entry
,2,6,1,2,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
224 tcd
->channel_dir_label
= gtk_label_new("Channel directory:");
225 gtk_widget_show (tcd
->channel_dir_label
);
226 tcd
->channel_dir_entry
= gtk_entry_new();
227 gtk_entry_set_text(GTK_ENTRY(tcd
->channel_dir_entry
),"/mnt/relayfs/ltt");
228 gtk_widget_show (tcd
->channel_dir_entry
);
229 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->channel_dir_label
,0,2,2,3,GTK_FILL
,GTK_FILL
,2,2);
230 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->channel_dir_entry
,2,6,2,3,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
232 tcd
->trace_dir_label
= gtk_label_new("Trace directory:");
233 gtk_widget_show (tcd
->trace_dir_label
);
234 tcd
->trace_dir_entry
= gtk_entry_new();
235 gtk_entry_set_text(GTK_ENTRY(tcd
->trace_dir_entry
),"/tmp/trace1");
236 gtk_widget_show (tcd
->trace_dir_entry
);
237 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_dir_label
,0,2,3,4,GTK_FILL
,GTK_FILL
,2,2);
238 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_dir_entry
,2,6,3,4,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
240 tcd
->trace_name_label
= gtk_label_new("Trace name:");
241 gtk_widget_show (tcd
->trace_name_label
);
242 tcd
->trace_name_entry
= gtk_entry_new();
243 gtk_entry_set_text(GTK_ENTRY(tcd
->trace_name_entry
),"trace");
244 gtk_widget_show (tcd
->trace_name_entry
);
245 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_name_label
,0,2,4,5,GTK_FILL
,GTK_FILL
,2,2);
246 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_name_entry
,2,6,4,5,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
248 tcd
->trace_mode_label
= gtk_label_new("Trace mode ");
249 gtk_widget_show (tcd
->trace_mode_label
);
250 tcd
->trace_mode_combo
= gtk_combo_box_new_text();
251 gtk_combo_box_append_text(GTK_COMBO_BOX(tcd
->trace_mode_combo
),
253 gtk_combo_box_append_text(GTK_COMBO_BOX(tcd
->trace_mode_combo
),
255 gtk_combo_box_set_active(GTK_COMBO_BOX(tcd
->trace_mode_combo
), 0);
256 gtk_widget_show (tcd
->trace_mode_combo
);
257 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_mode_label
,0,2,5,6,GTK_FILL
,GTK_FILL
,2,2);
258 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->trace_mode_combo
,2,6,5,6,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
260 tcd
->start_daemon_label
= gtk_label_new("Start daemon ");
261 gtk_widget_show (tcd
->start_daemon_label
);
262 tcd
->start_daemon_check
= gtk_check_button_new();
263 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tcd
->start_daemon_check
), TRUE
);
264 gtk_widget_show (tcd
->start_daemon_check
);
265 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->start_daemon_label
,0,2,6,7,GTK_FILL
,GTK_FILL
,2,2);
266 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->start_daemon_check
,2,6,6,7,GTK_FILL
,GTK_FILL
,0,0);
268 tcd
->optional_label
= gtk_label_new("Optional fields ");
269 gtk_widget_show (tcd
->optional_label
);
270 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->optional_label
,0,6,7,8,GTK_FILL
,GTK_FILL
,2,2);
272 tcd
->subbuf_size_label
= gtk_label_new("Subbuffer size:");
273 gtk_widget_show (tcd
->subbuf_size_label
);
274 tcd
->subbuf_size_entry
= gtk_entry_new();
275 gtk_widget_show (tcd
->subbuf_size_entry
);
276 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->subbuf_size_label
,0,2,8,9,GTK_FILL
,GTK_FILL
,2,2);
277 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->subbuf_size_entry
,2,6,8,9,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
279 tcd
->subbuf_num_label
= gtk_label_new("Number of subbuffers:");
280 gtk_widget_show (tcd
->subbuf_num_label
);
281 tcd
->subbuf_num_entry
= gtk_entry_new();
282 gtk_widget_show (tcd
->subbuf_num_entry
);
283 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->subbuf_num_label
,0,2,9,10,GTK_FILL
,GTK_FILL
,2,2);
284 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->subbuf_num_entry
,2,6,9,10,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
286 tcd
->lttctl_path_label
= gtk_label_new("path to lttctl:");
287 gtk_widget_show (tcd
->lttctl_path_label
);
288 tcd
->lttctl_path_entry
= gtk_entry_new();
289 gtk_entry_set_text(GTK_ENTRY(tcd
->lttctl_path_entry
),PACKAGE_BIN_DIR
"/lttctl");
290 gtk_widget_show (tcd
->lttctl_path_entry
);
291 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->lttctl_path_label
,0,2,10,11,GTK_FILL
,GTK_FILL
,2,2);
292 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->lttctl_path_entry
,2,6,10,11,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
295 tcd
->lttd_path_label
= gtk_label_new("path to lttd:");
296 gtk_widget_show (tcd
->lttd_path_label
);
297 tcd
->lttd_path_entry
= gtk_entry_new();
298 gtk_entry_set_text(GTK_ENTRY(tcd
->lttd_path_entry
),PACKAGE_BIN_DIR
"/lttd");
299 gtk_widget_show (tcd
->lttd_path_entry
);
300 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->lttd_path_label
,0,2,11,12,GTK_FILL
,GTK_FILL
,2,2);
301 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->lttd_path_entry
,2,6,11,12,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
304 tcd
->fac_path_label
= gtk_label_new("path to facilities:");
305 gtk_widget_show (tcd
->fac_path_label
);
306 tcd
->fac_path_entry
= gtk_entry_new();
307 gtk_entry_set_text(GTK_ENTRY(tcd
->fac_path_entry
),PACKAGE_DATA_DIR
"/facilities");
308 gtk_widget_set_size_request(tcd
->fac_path_entry
, 250, -1);
309 gtk_widget_show (tcd
->fac_path_entry
);
310 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->fac_path_label
,0,2,12,13,GTK_FILL
,GTK_FILL
,2,2);
311 gtk_table_attach( GTK_TABLE(tcd
->main_box
),tcd
->fac_path_entry
,2,6,12,13,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
314 GtkWidget
*start_button
;
315 GtkWidget
*pause_button
;
316 GtkWidget
*stop_button
;
318 GtkWidget
*username_entry
;
319 GtkWidget
*password_entry
;
320 GtkWidget
*channel_dir_entry
;
321 GtkWidget
*trace_dir_entry
;
322 GtkWidget
*trace_name_entry
;
323 GtkWidget
*trace_mode_combo
;
324 GtkWidget
*start_daemon_check
;
325 GtkWidget
*subbuf_size_entry
;
326 GtkWidget
*subbuf_num_entry
;
327 GtkWidget
*lttctl_path_entry
;
328 GtkWidget
*lttd_path_entry
;
329 GtkWidget
*fac_path_entry
;
331 focus_chain
= g_list_append (focus_chain
, tcd
->username_entry
);
332 focus_chain
= g_list_append (focus_chain
, tcd
->password_entry
);
333 focus_chain
= g_list_append (focus_chain
, tcd
->start_button
);
334 focus_chain
= g_list_append (focus_chain
, tcd
->pause_button
);
335 focus_chain
= g_list_append (focus_chain
, tcd
->stop_button
);
336 focus_chain
= g_list_append (focus_chain
, tcd
->channel_dir_entry
);
337 focus_chain
= g_list_append (focus_chain
, tcd
->trace_dir_entry
);
338 focus_chain
= g_list_append (focus_chain
, tcd
->trace_name_entry
);
339 focus_chain
= g_list_append (focus_chain
, tcd
->trace_mode_combo
);
340 focus_chain
= g_list_append (focus_chain
, tcd
->start_daemon_check
);
341 focus_chain
= g_list_append (focus_chain
, tcd
->subbuf_size_entry
);
342 focus_chain
= g_list_append (focus_chain
, tcd
->subbuf_num_entry
);
343 focus_chain
= g_list_append (focus_chain
, tcd
->lttctl_path_entry
);
344 focus_chain
= g_list_append (focus_chain
, tcd
->lttd_path_entry
);
345 focus_chain
= g_list_append (focus_chain
, tcd
->fac_path_entry
);
347 gtk_container_set_focus_chain(GTK_CONTAINER(tcd
->main_box
), focus_chain
);
349 g_signal_connect(G_OBJECT(tcd
->start_button
), "clicked",
350 (GCallback
)start_clicked
, tcd
);
351 g_signal_connect(G_OBJECT(tcd
->pause_button
), "clicked",
352 (GCallback
)pause_clicked
, tcd
);
353 g_signal_connect(G_OBJECT(tcd
->stop_button
), "clicked",
354 (GCallback
)stop_clicked
, tcd
);
357 * show main container
359 gtk_widget_show(tcd
->main_box
);
360 gtk_widget_show(tcd
->window
);
363 g_object_set_data_full(
364 G_OBJECT(guicontrol_get_widget(tcd
)),
365 "control_viewer_data",
367 (GDestroyNotify
)gui_control_destructor
);
369 g_control_list
= g_slist_append(
378 * @fn void gui_control_destructor(ControlData*)
380 * Destructor for the filter gui module
381 * @param tcd The module structure
384 gui_control_destructor(ControlData
*tcd
)
388 /* May already been done by GTK window closing */
389 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd
))){
390 g_info("widget still exists");
393 // lttvwindow_unregister_traceset_notify(tcd->tab,
394 // filter_traceset_changed,
395 // filter_viewer_data);
397 lttvwindowtraces_background_notify_remove(tcd
);
399 g_control_list
= g_slist_remove(g_control_list
, tcd
);
406 void start_clicked (GtkButton
*button
, gpointer user_data
)
408 ControlData
*tcd
= (ControlData
*)user_data
;
410 const gchar
*username
= gtk_entry_get_text(GTK_ENTRY(tcd
->username_entry
));
411 const gchar
*password
= gtk_entry_get_text(GTK_ENTRY(tcd
->password_entry
));
412 const gchar
*channel_dir
=
413 gtk_entry_get_text(GTK_ENTRY(tcd
->channel_dir_entry
));
414 const gchar
*trace_dir
= gtk_entry_get_text(GTK_ENTRY(tcd
->trace_dir_entry
));
415 const gchar
*trace_name
=
416 gtk_entry_get_text(GTK_ENTRY(tcd
->trace_name_entry
));
418 const gchar
*trace_mode_sel
=
419 gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd
->trace_mode_combo
));
420 const gchar
*trace_mode
;
421 if(strcmp(trace_mode_sel
, "normal") == 0)
422 trace_mode
= "normal";
424 trace_mode
= "flight";
426 gboolean start_daemon
=
427 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcd
->start_daemon_check
));
429 const gchar
*subbuf_size
=
430 gtk_entry_get_text(GTK_ENTRY(tcd
->subbuf_size_entry
));
431 const gchar
*subbuf_num
=
432 gtk_entry_get_text(GTK_ENTRY(tcd
->subbuf_num_entry
));
433 const gchar
*lttctl_path
=
434 gtk_entry_get_text(GTK_ENTRY(tcd
->lttctl_path_entry
));
435 const gchar
*lttd_path
= gtk_entry_get_text(GTK_ENTRY(tcd
->lttd_path_entry
));
436 const gchar
*fac_path
= gtk_entry_get_text(GTK_ENTRY(tcd
->fac_path_entry
));
438 //pid_t pid = fork();
441 pid
= forkpty(&fdpty
, NULL
, NULL
, NULL
);
448 /* discuss with su */
449 struct timeval timeout
;
455 FD_SET(fdpty
, &readfds
);
457 nbdes
= select(fdpty
+1, &readfds
, NULL
, NULL
, &timeout
);
461 count
= read (fdpty
, buf
, 256);
466 } while(select(fdpty
+1, &readfds
, NULL
, NULL
, &timeout
) > 0);
468 } else if(nbdes
== -1) {
469 perror("Timeout occured when waiting for su password prompt");
472 g_warning("No data within 2 seconds when waiting for su prompt");
476 g_info("Got su prompt, now writing password...");
479 ret
= write(fdpty
, password
, strlen(password
));
480 if(ret
< 0) perror("Error in write");
481 ret
= write(fdpty
, "\n", 1);
482 if(ret
< 0) perror("Error in write");
486 FD_SET(fdpty
, &readfds
);
488 if (select(fdpty
+1, &readfds
, NULL
, NULL
, &timeout
) < 0) {
489 g_warning("Cannot read from child pipe");
492 if(FD_ISSET(fdpty
, &readfds
)) {
493 count
= read(fdpty
, buf
, 256);
496 } else FD_SET(fdpty
, &readfds
);
498 } while(!(ret
= waitpid(pid
, &status
, WNOHANG
)));
501 if(WEXITSTATUS(ret
) != 0)
502 g_warning("An error occured in the su command, exit code : %hhu",
506 } else if(pid
== 0) {
508 gchar args
[MAX_ARGS_LEN
];
509 gint args_left
= MAX_ARGS_LEN
- 1; /* for \0 */
511 /* Setup environment variables */
512 if(strcmp(lttd_path
, "") != 0)
513 setenv("LTT_DAEMON", lttd_path
, 1);
514 if(strcmp(fac_path
, "") != 0)
515 setenv("LTT_FACILITIES", fac_path
, 1);
517 /* Setup arguments to su */
518 strncpy(args
, "\"", args_left
);
519 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
521 if(strcmp(lttctl_path
, "") == 0)
522 lttctl_path
= "lttctl";
525 strncat(args
, "-l ", args_left
);
526 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
527 strncat(args
, channel_dir
, args_left
);
528 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
531 strncat(args
, " ", args_left
);
532 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
535 strncat(args
, "-t ", args_left
);
536 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
537 strncat(args
, trace_dir
, args_left
);
538 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
541 strncat(args
, " ", args_left
);
542 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
545 strncat(args
, "-n ", args_left
);
546 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
547 strncat(args
, trace_name
, args_left
);
548 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
551 strncat(args
, " ", args_left
);
552 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
555 strncat(args
, "-m ", args_left
);
556 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
557 strncat(args
, trace_mode
, args_left
);
558 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
561 strncat(args
, " ", args_left
);
562 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
566 strncat(args
, "-d", args_left
);
567 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
569 /* Simply create the channel and then start tracing */
570 strncat(args
, "-b", args_left
);
571 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
574 /* optional arguments */
576 if(strcmp(subbuf_size
, "") != 0) {
578 strncat(args
, " ", args_left
);
579 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
581 strncat(args
, "-z ", args_left
);
582 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
583 strncat(args
, subbuf_size
, args_left
);
584 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
587 /* number of subbuffers */
588 if(strcmp(subbuf_num
, "") != 0) {
590 strncat(args
, " ", args_left
);
591 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
593 strncat(args
, "-x ", args_left
);
594 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
595 strncat(args
, subbuf_num
, args_left
);
596 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
599 strncat(args
, "\"", args_left
);
600 args_left
= MAX_ARGS_LEN
- strlen(args
) - 1;
602 //printf("Executing (as %s) : %s %s\n", username, lttctl_path, args);
604 execlp("su", "su", "-p", "-c", lttctl_path
, username
, args
, NULL
);
605 exit(-1); /* not supposed to happen! */
607 //system("echo blah");
610 //gint ret = execvp();
614 g_warning("Error happened when forking for su");
620 void pause_clicked (GtkButton
*button
, gpointer user_data
)
622 ControlData
*tcd
= (ControlData
*)user_data
;
627 void stop_clicked (GtkButton
*button
, gpointer user_data
)
629 ControlData
*tcd
= (ControlData
*)user_data
;
636 * @fn GtkWidget* h_guicontrol(Tab*)
638 * Control Module's constructor hook
640 * This constructor is given as a parameter to the menuitem and toolbar button
641 * registration. It creates the list.
642 * @param tab A pointer to the parent window.
643 * @return The widget created.
646 h_guicontrol(Tab
*tab
)
648 ControlData
* f
= gui_control(tab
) ;
654 * @fn static void init()
656 * This function initializes the Filter Viewer functionnality through the
661 lttvwindow_register_constructor("guicontrol",
663 "Insert Tracing Control Module",
664 hTraceControlInsert_xpm
,
665 "Insert Tracing Control Module",
670 * @fn void control_destroy_walk(gpointer,gpointer)
672 * Initiate the destruction of the current gui module
673 * on the GTK Interface
676 control_destroy_walk(gpointer data
, gpointer user_data
)
678 ControlData
*tcd
= (ControlData
*)data
;
680 g_debug("traceontrol.c : control_destroy_walk, %p", tcd
);
682 /* May already have been done by GTK window closing */
683 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd
)))
684 gtk_widget_destroy(guicontrol_get_widget(tcd
));
688 * @fn static void destroy()
689 * @brief plugin's destroy function
691 * This function releases the memory reserved by the module and unregisters
692 * everything that has been registered in the gtkTraceSet API.
694 static void destroy() {
696 g_slist_foreach(g_control_list
, control_destroy_walk
, NULL
);
698 lttvwindow_unregister_constructor(h_guicontrol
);
703 LTTV_MODULE("guitracecontrol", "Trace Control Window", \
704 "Graphical module that let user control kernel tracing", \
705 init
, destroy
, "lttvwindow")
This page took 0.046144 seconds and 4 git commands to generate.