From: compudj Date: Thu, 15 Sep 2005 17:11:36 +0000 (+0000) Subject: trace control finished X-Git-Tag: v0.12.20~2292 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=45653836d75635b5b841d0d03f1f0789348adc56;p=lttv.git trace control finished git-svn-id: http://ltt.polymtl.ca/svn@1197 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttctl/lttctl.c b/ltt/branches/poly/lttctl/lttctl.c index 19605c2e..679936c1 100644 --- a/ltt/branches/poly/lttctl/lttctl.c +++ b/ltt/branches/poly/lttctl/lttctl.c @@ -43,6 +43,7 @@ static char *trace_name = NULL; static char *mode_name = NULL; static unsigned subbuf_size = 0; static unsigned n_subbufs = 0; +static unsigned append_trace = 0; static enum trace_mode mode = LTT_TRACE_NORMAL; static enum trace_ctl_op op = CTL_OP_NONE; static char *channel_root = NULL; @@ -83,6 +84,7 @@ void show_arguments(void) printf("-z Size of the subbuffers (will be rounded to next page size)\n"); printf("-x Number of subbuffers\n"); printf("-e Get XML facilities description\n"); + printf("-a Append to trace\n"); printf("\n"); } @@ -203,6 +205,9 @@ int parse_arguments(int argc, char **argv) ret = -1; } break; + case 'a': + append_trace = 1; + break; default: printf("Invalid argument '%s'.\n", argv[argn]); printf("\n"); @@ -288,7 +293,7 @@ int create_eventdefs(void) strncat(eventdefs_path, "/eventdefs/", PATH_MAX - trace_root_len); size_t eventdefs_path_len = strlen(eventdefs_path); ret = mkdir(eventdefs_path, S_IRWXU|S_IRWXG|S_IRWXO); - if(ret == -1 && errno != EEXIST) { + if(ret == -1 && (!append_trace || errno != EEXIST)) { perror("Cannot create eventdefs directory"); goto error; } @@ -398,9 +403,13 @@ int lttctl_daemon(struct lttctl_handle *handle, char *trace_name) } else if(pid == 0) { /* child */ - - int ret = execlp(lttd_path, lttd_path, "-t", trace_root, "-c", - channel_path, "-d", NULL); + int ret; + if(append_trace) + ret = execlp(lttd_path, lttd_path, "-t", trace_root, "-c", + channel_path, "-d", "-a", NULL); + else + ret = execlp(lttd_path, lttd_path, "-t", trace_root, "-c", + channel_path, "-d", NULL); if(ret) { perror("Error in executing the lttd daemon"); exit(-1); diff --git a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c index 75921a45..e852ee71 100644 --- a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c +++ b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c @@ -75,6 +75,7 @@ void control_destroy_walk(gpointer data, gpointer user_data); static void start_clicked (GtkButton *button, gpointer user_data); static void pause_clicked (GtkButton *button, gpointer user_data); +static void unpause_clicked (GtkButton *button, gpointer user_data); static void stop_clicked (GtkButton *button, gpointer user_data); @@ -91,6 +92,7 @@ struct _ControlData { GtkWidget *main_box; /**< main container */ GtkWidget *start_button; GtkWidget *pause_button; + GtkWidget *unpause_button; GtkWidget *stop_button; GtkWidget *username_label; GtkWidget *username_entry; @@ -106,6 +108,8 @@ struct _ControlData { GtkWidget *trace_mode_combo; GtkWidget *start_daemon_label; GtkWidget *start_daemon_check; + GtkWidget *append_label; + GtkWidget *append_check; GtkWidget *optional_label; GtkWidget *subbuf_size_label; GtkWidget *subbuf_size_entry; @@ -189,13 +193,21 @@ gui_control(Tab *tab) gtk_widget_show (tcd->pause_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->pause_button,6,7,1,2,GTK_FILL,GTK_FILL,2,2); + pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm); + image = gtk_image_new_from_pixbuf(pixbuf); + tcd->unpause_button = gtk_button_new_with_label("unpause"); + gtk_button_set_image(GTK_BUTTON(tcd->unpause_button), image); + gtk_button_set_alignment(GTK_BUTTON(tcd->unpause_button), 0.0, 0.0); + gtk_widget_show (tcd->unpause_button); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->unpause_button,6,7,2,3,GTK_FILL,GTK_FILL,2,2); + pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->stop_button = gtk_button_new_with_label("stop"); gtk_button_set_image(GTK_BUTTON(tcd->stop_button), image); gtk_button_set_alignment(GTK_BUTTON(tcd->stop_button), 0.0, 0.0); gtk_widget_show (tcd->stop_button); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->stop_button,6,7,2,3,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->stop_button,6,7,3,4,GTK_FILL,GTK_FILL,2,2); /* * First half of the filter window @@ -264,32 +276,41 @@ gui_control(Tab *tab) gtk_widget_show (tcd->start_daemon_check); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_label,0,2,6,7,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_check,2,6,6,7,GTK_FILL,GTK_FILL,0,0); + + tcd->append_label = gtk_label_new("Append to trace "); + gtk_widget_show (tcd->append_label); + tcd->append_check = gtk_check_button_new(); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tcd->append_check), FALSE); + gtk_widget_show (tcd->append_check); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->append_label,0,2,7,8,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->append_check,2,6,7,8,GTK_FILL,GTK_FILL,0,0); + tcd->optional_label = gtk_label_new("Optional fields "); gtk_widget_show (tcd->optional_label); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->optional_label,0,6,7,8,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->optional_label,0,6,8,9,GTK_FILL,GTK_FILL,2,2); tcd->subbuf_size_label = gtk_label_new("Subbuffer size:"); gtk_widget_show (tcd->subbuf_size_label); tcd->subbuf_size_entry = gtk_entry_new(); gtk_widget_show (tcd->subbuf_size_entry); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_label,0,2,8,9,GTK_FILL,GTK_FILL,2,2); - 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); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_label,0,2,9,10,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_entry,2,6,9,10,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->subbuf_num_label = gtk_label_new("Number of subbuffers:"); gtk_widget_show (tcd->subbuf_num_label); tcd->subbuf_num_entry = gtk_entry_new(); gtk_widget_show (tcd->subbuf_num_entry); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_label,0,2,9,10,GTK_FILL,GTK_FILL,2,2); - 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); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_label,0,2,10,11,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_entry,2,6,10,11,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->lttctl_path_label = gtk_label_new("path to lttctl:"); gtk_widget_show (tcd->lttctl_path_label); tcd->lttctl_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->lttctl_path_entry),PACKAGE_BIN_DIR "/lttctl"); gtk_widget_show (tcd->lttctl_path_entry); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_label,0,2,10,11,GTK_FILL,GTK_FILL,2,2); - 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); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_label,0,2,11,12,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_entry,2,6,11,12,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->lttd_path_label = gtk_label_new("path to lttd:"); @@ -297,8 +318,8 @@ gui_control(Tab *tab) tcd->lttd_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->lttd_path_entry),PACKAGE_BIN_DIR "/lttd"); gtk_widget_show (tcd->lttd_path_entry); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_label,0,2,11,12,GTK_FILL,GTK_FILL,2,2); - 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); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_label,0,2,12,13,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_entry,2,6,12,13,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->fac_path_label = gtk_label_new("path to facilities:"); @@ -307,37 +328,21 @@ gui_control(Tab *tab) gtk_entry_set_text(GTK_ENTRY(tcd->fac_path_entry),PACKAGE_DATA_DIR "/" PACKAGE "/facilities"); gtk_widget_set_size_request(tcd->fac_path_entry, 250, -1); gtk_widget_show (tcd->fac_path_entry); - gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->fac_path_label,0,2,12,13,GTK_FILL,GTK_FILL,2,2); - 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); - - - GtkWidget *start_button; - GtkWidget *pause_button; - GtkWidget *stop_button; - - GtkWidget *username_entry; - GtkWidget *password_entry; - GtkWidget *channel_dir_entry; - GtkWidget *trace_dir_entry; - GtkWidget *trace_name_entry; - GtkWidget *trace_mode_combo; - GtkWidget *start_daemon_check; - GtkWidget *subbuf_size_entry; - GtkWidget *subbuf_num_entry; - GtkWidget *lttctl_path_entry; - GtkWidget *lttd_path_entry; - GtkWidget *fac_path_entry; + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->fac_path_label,0,2,13,14,GTK_FILL,GTK_FILL,2,2); + gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->fac_path_entry,2,6,13,14,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); focus_chain = g_list_append (focus_chain, tcd->username_entry); focus_chain = g_list_append (focus_chain, tcd->password_entry); focus_chain = g_list_append (focus_chain, tcd->start_button); focus_chain = g_list_append (focus_chain, tcd->pause_button); + focus_chain = g_list_append (focus_chain, tcd->unpause_button); focus_chain = g_list_append (focus_chain, tcd->stop_button); focus_chain = g_list_append (focus_chain, tcd->channel_dir_entry); focus_chain = g_list_append (focus_chain, tcd->trace_dir_entry); focus_chain = g_list_append (focus_chain, tcd->trace_name_entry); focus_chain = g_list_append (focus_chain, tcd->trace_mode_combo); focus_chain = g_list_append (focus_chain, tcd->start_daemon_check); + focus_chain = g_list_append (focus_chain, tcd->append_check); focus_chain = g_list_append (focus_chain, tcd->subbuf_size_entry); focus_chain = g_list_append (focus_chain, tcd->subbuf_num_entry); focus_chain = g_list_append (focus_chain, tcd->lttctl_path_entry); @@ -350,6 +355,8 @@ gui_control(Tab *tab) (GCallback)start_clicked, tcd); g_signal_connect(G_OBJECT(tcd->pause_button), "clicked", (GCallback)pause_clicked, tcd); + g_signal_connect(G_OBJECT(tcd->unpause_button), "clicked", + (GCallback)unpause_clicked, tcd); g_signal_connect(G_OBJECT(tcd->stop_button), "clicked", (GCallback)stop_clicked, tcd); @@ -401,41 +408,9 @@ gui_control_destructor(ControlData *tcd) g_free(tcd); } -/* Callbacks */ - -void start_clicked (GtkButton *button, gpointer user_data) +static void execute_command(const gchar *command, const gchar *username, + const gchar *password, const gchar *lttd_path, const gchar *fac_path) { - ControlData *tcd = (ControlData*)user_data; - - const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry)); - const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry)); - const gchar *channel_dir = - gtk_entry_get_text(GTK_ENTRY(tcd->channel_dir_entry)); - const gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry)); - const gchar *trace_name = - gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry)); - - const gchar *trace_mode_sel = - gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd->trace_mode_combo)); - const gchar *trace_mode; - if(strcmp(trace_mode_sel, "normal") == 0) - trace_mode = "normal"; - else - trace_mode = "flight"; - - gboolean start_daemon = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcd->start_daemon_check)); - - const gchar *subbuf_size = - gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_size_entry)); - const gchar *subbuf_num = - gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_num_entry)); - const gchar *lttctl_path = - gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); - const gchar *lttd_path = gtk_entry_get_text(GTK_ENTRY(tcd->lttd_path_entry)); - const gchar *fac_path = gtk_entry_get_text(GTK_ENTRY(tcd->fac_path_entry)); - - //pid_t pid = fork(); pid_t pid; int fdpty; pid = forkpty(&fdpty, NULL, NULL, NULL); @@ -569,130 +544,178 @@ wait_child: g_info("Child exited."); } else if(pid == 0) { - /* child */ - gchar args[MAX_ARGS_LEN]; - gint args_left = MAX_ARGS_LEN - 1; /* for \0 */ - /* Setup environment variables */ if(strcmp(lttd_path, "") != 0) setenv("LTT_DAEMON", lttd_path, 1); if(strcmp(fac_path, "") != 0) setenv("LTT_FACILITIES", fac_path, 1); - /* Setup arguments to su */ - //strncpy(args, "\'", args_left); - //args_left = MAX_ARGS_LEN - strlen(args) - 1; + g_message("Executing (as %s) : %s\n", username, command); - /* Command */ - strncat(args, "exec", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; + execlp("su", "su", "-p", "-c", command, username, NULL); + exit(-1); /* not supposed to happen! */ + + //gint ret = execvp(); + + } else { + /* error */ + g_warning("Error happened when forking for su"); + } - /* space */ - strncat(args, " ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; +} - if(strcmp(lttctl_path, "") == 0) - strncat(args, "lttctl", args_left); - else - strncat(args, lttctl_path, args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - /* space */ - strncat(args, " ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; +/* Callbacks */ - /* channel dir */ - strncat(args, "-l ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, channel_dir, args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; +void start_clicked (GtkButton *button, gpointer user_data) +{ + ControlData *tcd = (ControlData*)user_data; - /* space */ - strncat(args, " ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; + const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry)); + const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry)); + const gchar *channel_dir = + gtk_entry_get_text(GTK_ENTRY(tcd->channel_dir_entry)); + const gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry)); + const gchar *trace_name = + gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry)); + + const gchar *trace_mode_sel = + gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd->trace_mode_combo)); + const gchar *trace_mode; + if(strcmp(trace_mode_sel, "normal") == 0) + trace_mode = "normal"; + else + trace_mode = "flight"; + + gboolean start_daemon = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcd->start_daemon_check)); - /* trace dir */ - strncat(args, "-t ", args_left); + gboolean append = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcd->append_check)); + + const gchar *subbuf_size = + gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_size_entry)); + const gchar *subbuf_num = + gtk_entry_get_text(GTK_ENTRY(tcd->subbuf_num_entry)); + const gchar *lttctl_path = + gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); + const gchar *lttd_path = gtk_entry_get_text(GTK_ENTRY(tcd->lttd_path_entry)); + const gchar *fac_path = gtk_entry_get_text(GTK_ENTRY(tcd->fac_path_entry)); + + + /* Setup arguments to su */ + /* child */ + gchar args[MAX_ARGS_LEN]; + gint args_left = MAX_ARGS_LEN - 1; /* for \0 */ + + args[0] = '\0'; + + /* Command */ + strncat(args, "exec", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + if(strcmp(lttctl_path, "") == 0) + strncat(args, "lttctl", args_left); + else + strncat(args, lttctl_path, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* channel dir */ + strncat(args, "-l ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, channel_dir, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* trace dir */ + strncat(args, "-t ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_dir, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* name */ + strncat(args, "-n ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_name, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* trace mode */ + strncat(args, "-m ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_mode, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* Start daemon ? */ + if(start_daemon) { + strncat(args, "-d", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, trace_dir, args_left); + } else { + /* Simply create the channel and then start tracing */ + strncat(args, "-b", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; + } + + /* Append to trace ? */ + if(append) { /* space */ strncat(args, " ", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - - /* name */ - strncat(args, "-n ", args_left); + strncat(args, "-a", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, trace_name, args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - + } + + /* optional arguments */ + /* subbuffer size */ + if(strcmp(subbuf_size, "") != 0) { /* space */ strncat(args, " ", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - /* trace mode */ - strncat(args, "-m ", args_left); + strncat(args, "-z ", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, trace_mode, args_left); + strncat(args, subbuf_size, args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; + } + /* number of subbuffers */ + if(strcmp(subbuf_num, "") != 0) { /* space */ strncat(args, " ", args_left); args_left = MAX_ARGS_LEN - strlen(args) - 1; - /* Start daemon ? */ - if(start_daemon) { - strncat(args, "-d", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - } else { - /* Simply create the channel and then start tracing */ - strncat(args, "-b", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - } - - /* optional arguments */ - /* subbuffer size */ - if(strcmp(subbuf_size, "") != 0) { - /* space */ - strncat(args, " ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - - strncat(args, "-z ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, subbuf_size, args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - } - - /* number of subbuffers */ - if(strcmp(subbuf_num, "") != 0) { - /* space */ - strncat(args, " ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, "-x ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, subbuf_num, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + } - strncat(args, "-x ", args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - strncat(args, subbuf_num, args_left); - args_left = MAX_ARGS_LEN - strlen(args) - 1; - } - - //strncat(args, "\'", args_left); - //args_left = MAX_ARGS_LEN - strlen(args) - 1; - - g_message("Executing (as %s) : %s\n", username, args); - - execlp("su", "su", "-p", "-c", args, username, NULL); - exit(-1); /* not supposed to happen! */ - //system(args); - //system("echo blah"); - //exit(0); - - //gint ret = execvp(); - } else { - /* error */ - g_warning("Error happened when forking for su"); - } + execute_command(args, username, password, lttd_path, fac_path); + } @@ -701,13 +724,170 @@ void pause_clicked (GtkButton *button, gpointer user_data) { ControlData *tcd = (ControlData*)user_data; + const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry)); + const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry)); + const gchar *trace_name = + gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry)); + const gchar *lttd_path = ""; + const gchar *fac_path = ""; + + const gchar *lttctl_path = + gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); + /* Setup arguments to su */ + /* child */ + gchar args[MAX_ARGS_LEN]; + gint args_left = MAX_ARGS_LEN - 1; /* for \0 */ + + args[0] = '\0'; + + /* Command */ + strncat(args, "exec", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + if(strcmp(lttctl_path, "") == 0) + strncat(args, "lttctl", args_left); + else + strncat(args, lttctl_path, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* name */ + strncat(args, "-n ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_name, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* Simply pause tracing */ + strncat(args, "-q", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + execute_command(args, username, password, lttd_path, fac_path); + +} + +void unpause_clicked (GtkButton *button, gpointer user_data) +{ + ControlData *tcd = (ControlData*)user_data; + + const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry)); + const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry)); + const gchar *trace_name = + gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry)); + const gchar *lttd_path = ""; + const gchar *fac_path = ""; + + const gchar *lttctl_path = + gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); + + /* Setup arguments to su */ + /* child */ + gchar args[MAX_ARGS_LEN]; + gint args_left = MAX_ARGS_LEN - 1; /* for \0 */ + + args[0] = '\0'; + + /* Command */ + strncat(args, "exec", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + if(strcmp(lttctl_path, "") == 0) + strncat(args, "lttctl", args_left); + else + strncat(args, lttctl_path, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* name */ + strncat(args, "-n ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_name, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* Simply unpause tracing */ + strncat(args, "-s", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + execute_command(args, username, password, lttd_path, fac_path); } void stop_clicked (GtkButton *button, gpointer user_data) { ControlData *tcd = (ControlData*)user_data; + const gchar *username = gtk_entry_get_text(GTK_ENTRY(tcd->username_entry)); + const gchar *password = gtk_entry_get_text(GTK_ENTRY(tcd->password_entry)); + const gchar *trace_name = + gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry)); + const gchar *lttd_path = ""; + const gchar *fac_path = ""; + + const gchar *lttctl_path = + gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); + + /* Setup arguments to su */ + /* child */ + gchar args[MAX_ARGS_LEN]; + gint args_left = MAX_ARGS_LEN - 1; /* for \0 */ + + args[0] = '\0'; + + /* Command */ + strncat(args, "exec", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + if(strcmp(lttctl_path, "") == 0) + strncat(args, "lttctl", args_left); + else + strncat(args, lttctl_path, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* name */ + strncat(args, "-n ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + strncat(args, trace_name, args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* space */ + strncat(args, " ", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + /* Simply stop tracing and destroy channel */ + strncat(args, "-R", args_left); + args_left = MAX_ARGS_LEN - strlen(args) - 1; + + execute_command(args, username, password, lttd_path, fac_path); + }