cc81b74c9e6ad70c603c9b363d11d17ea6ad9544
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; only version 2
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>
28 #include "../command.h"
30 static char *opt_channels
;
31 static int opt_kernel
;
32 static char *opt_session_name
;
33 static int opt_userspace
;
35 /* Not implemented yet */
36 static char *opt_cmd_name
;
45 static struct lttng_handle
*handle
;
47 static struct poptOption long_options
[] = {
48 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
49 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
50 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
51 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
53 /* Not implemented yet */
54 {"userspace", 'u', POPT_ARG_STRING
| POPT_ARGFLAG_OPTIONAL
, &opt_cmd_name
, OPT_USERSPACE
, 0, 0},
55 {"pid", 'p', POPT_ARG_INT
, &opt_pid
, 0, 0, 0},
57 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
65 static void usage(FILE *ofp
)
67 fprintf(ofp
, "usage: lttng disable-channel NAME[,NAME2,...] [options]\n");
69 fprintf(ofp
, " -h, --help Show this help\n");
70 fprintf(ofp
, " -s, --session Apply on session name\n");
71 fprintf(ofp
, " -k, --kernel Apply for the kernel tracer\n");
73 fprintf(ofp
, " -u, --userspace [CMD] Apply for the user-space tracer\n");
74 fprintf(ofp
, " If no CMD, the domain used is UST global\n");
75 fprintf(ofp
, " or else the domain is UST EXEC_NAME\n");
76 fprintf(ofp
, " -p, --pid PID If -u, apply to specific PID (domain: UST PID)\n");
78 fprintf(ofp
, " -u, --userspace Apply for the user-space tracer\n");
84 * Disabling channel using the lttng API.
86 static int disable_channels(char *session_name
)
88 int ret
= CMD_SUCCESS
;
90 struct lttng_domain dom
;
92 /* Create lttng domain */
94 dom
.type
= LTTNG_DOMAIN_KERNEL
;
95 } else if (opt_userspace
) {
96 dom
.type
= LTTNG_DOMAIN_UST
;
98 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
99 ret
= CMD_NOT_IMPLEMENTED
;
103 handle
= lttng_create_handle(session_name
, &dom
);
104 if (handle
== NULL
) {
109 /* Strip channel list */
110 channel_name
= strtok(opt_channels
, ",");
111 while (channel_name
!= NULL
) {
112 DBG("Disabling channel %s", channel_name
);
114 ret
= lttng_disable_channel(handle
, channel_name
);
118 MSG("%s channel %s disabled for session %s",
119 opt_kernel
? "Kernel" : "UST", channel_name
,
124 channel_name
= strtok(NULL
, ",");
128 lttng_destroy_handle(handle
);
134 * cmd_disable_channels
136 * Disable channel to trace session
138 int cmd_disable_channels(int argc
, const char **argv
)
141 static poptContext pc
;
142 char *session_name
= NULL
;
144 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
145 poptReadDefaultConfig(pc
, 0);
147 while ((opt
= poptGetNextOpt(pc
)) != -1) {
163 opt_channels
= (char*) poptGetArg(pc
);
164 if (opt_channels
== NULL
) {
165 ERR("Missing channel name(s).\n");
171 if (!opt_session_name
) {
172 session_name
= get_session_name();
173 if (session_name
== NULL
) {
178 session_name
= opt_session_name
;
181 ret
= disable_channels(session_name
);
This page took 0.033887 seconds and 4 git commands to generate.