X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Ftracecontrol%2Ftracecontrol.c;h=768095cd387124fa6093e9b7c2d9d74771d302da;hb=37b0f1ed7982a8995d29da17a5b1b6b8127eb162;hp=0617174f047deb0fe6cd765a122d84d9a8e71b85;hpb=e6542e856d40b763fd1b7e6ae72e689318148fcc;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c index 0617174f..768095cd 100644 --- a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c +++ b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c @@ -21,6 +21,7 @@ #endif #include +#include #include #include #include @@ -32,6 +33,8 @@ #include #include +#include +#include #include "hTraceControlInsert.xpm" #include "TraceControlStart.xpm" @@ -46,6 +49,8 @@ #include #include #include +#include +#include #define MAX_ARGS_LEN PATH_MAX * 10 @@ -65,9 +70,9 @@ typedef struct _ControlData ControlData; * Prototypes */ GtkWidget *guicontrol_get_widget(ControlData *tcd); -ControlData *gui_control(Tab *tab); +ControlData *gui_control(LttvPluginTab *ptab); void gui_control_destructor(ControlData *tcd); -GtkWidget* h_guicontrol(Tab *tab); +GtkWidget* h_guicontrol(LttvPlugin *plugin); void control_destroy_walk(gpointer data, gpointer user_data); /* @@ -148,8 +153,9 @@ guicontrol_get_widget(ControlData *tcd) * @return The Filter viewer data created. */ ControlData* -gui_control(Tab *tab) +gui_control(LttvPluginTab *ptab) { + Tab *tab = ptab->tab; g_debug("filter::gui_control()"); unsigned i; @@ -243,7 +249,7 @@ gui_control(Tab *tab) tcd->channel_dir_label = gtk_label_new("Channel directory:"); gtk_widget_show (tcd->channel_dir_label); tcd->channel_dir_entry = gtk_entry_new(); - gtk_entry_set_text(GTK_ENTRY(tcd->channel_dir_entry),"/mnt/relayfs/ltt"); + gtk_entry_set_text(GTK_ENTRY(tcd->channel_dir_entry),"/mnt/debugfs/ltt"); gtk_widget_show (tcd->channel_dir_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->channel_dir_label,0,2,2,3,GTK_FILL,GTK_FILL,2,2); 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); @@ -340,7 +346,7 @@ gui_control(Tab *tab) tcd->fac_path_label = gtk_label_new("path to facilities:"); gtk_widget_show (tcd->fac_path_label); tcd->fac_path_entry = gtk_entry_new(); - gtk_entry_set_text(GTK_ENTRY(tcd->fac_path_entry),PACKAGE_DATA_DIR "/" PACKAGE "/facilities"); + gtk_entry_set_text(GTK_ENTRY(tcd->fac_path_entry),PACKAGE_DATA_DIR "/" "ltt-control" "/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,14,15,GTK_FILL,GTK_FILL,2,2); @@ -447,26 +453,29 @@ static int execute_command(const gchar *command, const gchar *username, struct pollfd pollfd; int num_rdy; int num_hup = 0; + enum read_state { GET_LINE, GET_SEMI, GET_SPACE } read_state = GET_LINE; + retval = fcntl(fdpty, F_SETFL, O_WRONLY); + if(retval == -1) { + perror("Error in fcntl"); + goto wait_child; + } /* Read the output from the child terminal before the prompt. If no data in * 200 ms, we stop reading to give the password */ g_info("Reading from child console..."); - sleep(1); /* make sure the child is ready */ while(1) { pollfd.fd = fdpty; pollfd.events = POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL; - num_rdy = poll(&pollfd, 1, 200); -#if 0 + num_rdy = poll(&pollfd, 1, -1); if(num_rdy == -1) { perror("Poll error"); goto wait_child; } -#endif //0 - /* Timeout : stop waiting for chars */ - if(num_rdy == 0) break; + /* Timeout : Stop waiting for chars */ + if(num_rdy == 0) goto wait_child; switch(pollfd.revents) { case POLLERR: @@ -485,8 +494,31 @@ static int execute_command(const gchar *command, const gchar *username, case POLLIN: count = read (fdpty, buf, 256); if(count > 0) { + unsigned int i; buf[count] = '\0'; - printf("%s", buf); + g_printf("%s", buf); + for(i=0; i 0) { + buf[count] = '\0'; + printf("%s", buf); + } else if(count == -1) { + perror("Error in read"); + goto wait_child; + } + } + + if(pollfd.revents & POLLHUP) { + g_info("Polling FD : hung up."); + num_hup++; + } - switch(pollfd.revents) { - case POLLERR: - g_warning("Error returned in polling fd\n"); - num_hup++; - break; - case POLLHUP: - g_info("Polling FD : hung up."); - num_hup++; - break; - case POLLNVAL: - g_warning("Polling fd tells it is not open"); - num_hup++; - break; - case POLLPRI: - case POLLIN: - count = read (fdpty, buf, 256); - if(count > 0) { - buf[count] = '\0'; - printf("%s", buf); - } else if(count == -1) { - perror("Error in read"); - goto wait_child; - } - break; - } if(num_hup > 0) goto wait_child; } wait_child: @@ -577,7 +613,8 @@ wait_child: if(strcmp(fac_path, "") != 0) setenv("LTT_FACILITIES", fac_path, 1); - g_message("Executing (as %s) : %s\n", username, command); + /* One comment line (must be only one) */ + g_printf("Executing (as %s) : %s\n", username, command); execlp("su", "su", "-p", "-c", command, username, NULL); exit(-1); /* not supposed to happen! */ @@ -947,7 +984,10 @@ void stop_clicked (GtkButton *button, gpointer user_data) const gchar *lttctl_path = gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry)); - const gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry)); + gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry)); + GSList * trace_list = NULL; + + trace_list = g_slist_append(trace_list, trace_dir); /* Setup arguments to su */ /* child */ @@ -1031,7 +1071,7 @@ void stop_clicked (GtkButton *button, gpointer user_data) switch(id){ case GTK_RESPONSE_ACCEPT: { - create_main_window_with_trace(trace_dir); + create_main_window_with_trace_list(trace_list); } break; case GTK_RESPONSE_REJECT: @@ -1039,7 +1079,7 @@ void stop_clicked (GtkButton *button, gpointer user_data) break; } gtk_widget_destroy(dialogue); - + g_slist_free(trace_list); } @@ -1054,9 +1094,10 @@ void stop_clicked (GtkButton *button, gpointer user_data) * @return The widget created. */ GtkWidget * -h_guicontrol(Tab *tab) +h_guicontrol(LttvPlugin *plugin) { - ControlData* f = gui_control(tab) ; + LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); + ControlData* f = gui_control(ptab); return NULL; }