f8ad58d54ccb6cb2d9dd37b95661abc353306657
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 int opt_pid_all
;
35 static int opt_userspace
;
43 static struct poptOption long_options
[] = {
44 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
45 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
46 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
47 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
48 {"all", 0, POPT_ARG_VAL
, &opt_pid_all
, 1, 0, 0},
49 {"pid", 'p', POPT_ARG_INT
, &opt_pid
, 0, 0, 0},
56 static void usage(FILE *ofp
)
58 fprintf(ofp
, "usage: lttng enable-channel NAME[,NAME2,...] [options]\n");
60 fprintf(ofp
, " -h, --help Show this help\n");
61 fprintf(ofp
, " -k, --kernel Apply for the kernel tracer\n");
62 fprintf(ofp
, " -u, --userspace Apply for the user-space tracer\n");
63 fprintf(ofp
, " --all If -u, apply on all traceable apps\n");
64 fprintf(ofp
, " -p, --pid PID If -u, apply on a specific PID\n");
71 * Enabling channel using the lttng API.
73 static int enable_channels(void)
75 int ret
= CMD_SUCCESS
;
78 if (set_session_name() < 0) {
83 /* Strip event list */
84 channel_name
= strtok(opt_channels
, ",");
85 while (channel_name
!= NULL
) {
86 /* Kernel tracer action */
88 DBG("Enabling kernel channel %s", channel_name
);
89 ret
= lttng_kernel_enable_channel(channel_name
);
93 MSG("Kernel channel enabled %s", channel_name
);
95 } else if (opt_userspace
) { /* User-space tracer action */
97 * TODO: Waiting on lttng UST 2.0
100 } else if (opt_pid
!= 0) {
102 ret
= CMD_NOT_IMPLEMENTED
;
105 ERR("Please specify a tracer (kernel or user-space)");
110 channel_name
= strtok(NULL
, ",");
118 * cmd_enable_channels
120 * Enable channel to trace session
122 int cmd_enable_channels(int argc
, const char **argv
)
125 static poptContext pc
;
127 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
128 poptReadDefaultConfig(pc
, 0);
130 while ((opt
= poptGetNextOpt(pc
)) != -1) {
146 opt_channels
= (char*) poptGetArg(pc
);
147 if (opt_channels
== NULL
) {
148 ERR("Missing channel name(s).\n");
154 ret
= enable_channels();
This page took 0.034455 seconds and 3 git commands to generate.