2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <sys/types.h>
32 static char *opt_channels
;
33 static char *opt_kernel
;
34 static char *opt_session_name
;
35 static int opt_pid_all
;
36 static int opt_userspace
;
44 static struct poptOption long_options
[] = {
45 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
46 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
47 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
48 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
49 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
50 {"all", 0, POPT_ARG_VAL
, &opt_pid_all
, 1, 0, 0},
51 {"pid", 'p', POPT_ARG_INT
, &opt_pid
, 0, 0, 0},
58 static void usage(FILE *ofp
)
60 fprintf(ofp
, "usage: lttng enable-channel NAME[,NAME2,...] [options]\n");
62 fprintf(ofp
, " -h, --help Show this help\n");
63 fprintf(ofp
, " -s, --session Apply on session name\n");
64 fprintf(ofp
, " -k, --kernel Apply for the kernel tracer\n");
65 fprintf(ofp
, " -u, --userspace Apply for the user-space tracer\n");
66 fprintf(ofp
, " --all If -u, apply on all traceable apps\n");
67 fprintf(ofp
, " -p, --pid PID If -u, apply on a specific PID\n");
74 * Enabling channel using the lttng API.
76 static int enable_channels(void)
78 int ret
= CMD_SUCCESS
;
81 if (set_session_name(opt_session_name
) < 0) {
86 /* Strip event list */
87 channel_name
= strtok(opt_channels
, ",");
88 while (channel_name
!= NULL
) {
89 /* Kernel tracer action */
91 DBG("Enabling kernel channel %s", channel_name
);
92 ret
= lttng_kernel_enable_channel(channel_name
);
96 MSG("Kernel channel enabled %s", channel_name
);
98 } else if (opt_userspace
) { /* User-space tracer action */
100 * TODO: Waiting on lttng UST 2.0
103 } else if (opt_pid
!= 0) {
105 ret
= CMD_NOT_IMPLEMENTED
;
108 ERR("Please specify a tracer (kernel or user-space)");
113 channel_name
= strtok(NULL
, ",");
121 * cmd_enable_channels
123 * Enable channel to trace session
125 int cmd_enable_channels(int argc
, const char **argv
)
128 static poptContext pc
;
130 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
131 poptReadDefaultConfig(pc
, 0);
133 while ((opt
= poptGetNextOpt(pc
)) != -1) {
149 opt_channels
= (char*) poptGetArg(pc
);
150 if (opt_channels
== NULL
) {
151 ERR("Missing channel name(s).\n");
157 ret
= enable_channels();
This page took 0.035435 seconds and 6 git commands to generate.