X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttctl%2Flttctl.c;h=e77b7f38d6833f8abc2cc8dd0fba8b19b9a9c146;hb=635683d75350f395da23354a7524dfd0a1363d48;hp=e08280aab2e066cd19f3b8479df1e6ae8ad9397a;hpb=5e1fd42a8d1bbbe1e1283e4c652994ff738dd6a7;p=ltt-control.git diff --git a/lttctl/lttctl.c b/lttctl/lttctl.c index e08280a..e77b7f3 100644 --- a/lttctl/lttctl.c +++ b/lttctl/lttctl.c @@ -2,14 +2,26 @@ * * Linux Trace Toolkit Control * - * Small program that controls LTT through libltt. - * - * Copyright 2005 - - * Mathieu Desnoyers + * Small program that controls LTTng through liblttctl. * * Copyright 2008 FUJITSU * Zhao Lei * Gui Jianfeng + * Copyright 2009-2010 - Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifdef HAVE_CONFIG_H @@ -41,6 +53,7 @@ struct channel_option { int overwrite; int bufnum; int bufsize; + int switch_timer; }; struct lttctl_option { @@ -124,6 +137,8 @@ static void show_arguments(void) printf(" channel..bufsize= (in bytes, rounded to " "next power of 2)\n"); printf(" can be set to all for all channels\n"); + printf(" channel..switch_timer= (timer interval in " + "ms)\n"); printf("\n"); printf(" Integration options:\n"); printf(" -C, --create_start\n"); @@ -141,6 +156,11 @@ static void show_arguments(void) printf(" Set channels root path, For -w option." " (ex. /mnt/debugfs/ltt)\n"); printf("\n"); + printf(" Environment variables:\n"); + printf(" LTT_DAEMON\n"); + printf(" Complete path to the lttd binary (needs to be\n"); + printf(" specified if different than package build prefix).\n"); + printf("\n"); } /* @@ -205,6 +225,7 @@ static void init_channel_opt(struct channel_option *opt, char *opt_name) opt->overwrite = -1; opt->bufnum = -1; opt->bufsize = -1; + opt->switch_timer = -1; strcpy(opt->chan_name, opt_name); } } @@ -291,6 +312,14 @@ int set_channel_opt(struct channel_option *opt, char *opt_name, char *opt_valstr opt->bufsize = opt_val; return 0; + } else if (!strcmp("switch_timer", opt_name)) { + ret = sscanf(opt_valstr, "%d", &opt_val); + if (ret != 1 || opt_val < 0) { + return -EINVAL; + } + + opt->switch_timer = opt_val; + return 0; } else { return -EINVAL; } @@ -622,6 +651,11 @@ static int lttctl_channel_setup(struct channel_option *opt) opt->bufsize)) != 0) return ret; } + if (opt->switch_timer != -1) { + if ((ret = lttctl_set_channel_switch_timer(opt_tracename, + opt->chan_name, opt->switch_timer)) != 0) + return ret; + } return 0; } @@ -662,10 +696,13 @@ setup_trace_fail: } /* - * Start a lttd daemon to write trace datas + * Start a lttd daemon to write trace data * Dump overwrite channels on overwrite!=0 * Dump normal(non-overwrite) channels on overwrite=0 * + * When called for overwrite mode, wait for lttd to return, so we are sure that + * trace session teardown is not executed before lttd can grab the buffer data. + * * ret: 0 on success * !0 on fail */ @@ -760,6 +797,16 @@ static int lttctl_daemon(int overwrite) if (WEXITSTATUS(status)) fprintf(stderr, "lttd process running failed\n"); + /* + * FIXME + * This is a temporary hack to ensure that the lttd daemon grabs + * handles on the debugfs buffer files before we destroy the trace + * session. Properly handling this will imply separating the "flush" + * from the "destroy" operation at kernel-level in LTTng. + */ + if (overwrite) + sleep(2); + return WEXITSTATUS(status); }