ABI update: only send loglevel value to UST: fixed loglevels
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
CommitLineData
f3ed775e
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
82a3637f
DG
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
f3ed775e
DG
8 *
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.
13 *
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.
17 */
18
19#define _GNU_SOURCE
20#include <popt.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <sys/stat.h>
25#include <sys/types.h>
26#include <unistd.h>
5a0de755 27#include <inttypes.h>
8f0d098b 28#include <ctype.h>
f3ed775e 29
c399183f 30#include "../command.h"
f3ed775e
DG
31
32static char *opt_event_list;
33static int opt_event_type;
0cda4f28
MD
34static const char *opt_loglevel;
35static int opt_loglevel_type;
6181537c 36static int opt_kernel;
5440dc42 37static char *opt_session_name;
f3ed775e
DG
38static int opt_userspace;
39static int opt_enable_all;
cf0e5467 40static char *opt_probe;
8f0d098b
MD
41static char *opt_function;
42static char *opt_function_entry_symbol;
f3ed775e 43static char *opt_channel_name;
d78d6610
DG
44#if 0
45/* Not implemented yet */
46static char *opt_cmd_name;
47static pid_t opt_pid;
48#endif
f3ed775e
DG
49
50enum {
51 OPT_HELP = 1,
f3ed775e 52 OPT_TRACEPOINT,
cf0e5467 53 OPT_PROBE,
f3ed775e 54 OPT_FUNCTION,
8f0d098b 55 OPT_FUNCTION_ENTRY,
a54bd42d 56 OPT_SYSCALL,
eeac7d46 57 OPT_USERSPACE,
0cda4f28
MD
58 OPT_LOGLEVEL,
59 OPT_LOGLEVEL_ONLY,
679b4943 60 OPT_LIST_OPTIONS,
f3ed775e
DG
61};
62
cd80958d
DG
63static struct lttng_handle *handle;
64
f3ed775e
DG
65static struct poptOption long_options[] = {
66 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
67 {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
5440dc42 68 {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
e14f64a8 69 {"all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0},
f3ed775e
DG
70 {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
71 {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
d78d6610
DG
72#if 0
73 /* Not implemented yet */
40e9d5d3 74 {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
f3ed775e 75 {"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
d78d6610
DG
76#else
77 {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
78#endif
f3ed775e 79 {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
7ebae521 80 {"probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0},
40e9d5d3 81 {"function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0},
b213d387
MD
82#if 0
83 /*
84 * Currently removed from lttng kernel tracer. Removed from
85 * lttng UI to discourage its use.
86 */
40e9d5d3 87 {"function:entry", 0, POPT_ARG_STRING, &opt_function_entry_symbol, OPT_FUNCTION_ENTRY, 0, 0},
b213d387 88#endif
7ebae521 89 {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0},
0cda4f28
MD
90 {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0},
91 {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0},
679b4943 92 {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
f3ed775e
DG
93 {0, 0, 0, 0, 0, 0, 0}
94};
95
96/*
97 * usage
98 */
99static void usage(FILE *ofp)
100{
101 fprintf(ofp, "usage: lttng enable-event NAME[,NAME2,...] [options] [event_options]\n");
102 fprintf(ofp, "\n");
103 fprintf(ofp, " -h, --help Show this help\n");
679b4943 104 fprintf(ofp, " --list-options Simple listing of options\n");
27221701
DG
105 fprintf(ofp, " -s, --session Apply to session name\n");
106 fprintf(ofp, " -c, --channel Apply to this channel\n");
e14f64a8 107 fprintf(ofp, " -a, --all Enable all tracepoints\n");
f3ed775e 108 fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n");
d78d6610 109#if 0
27221701 110 fprintf(ofp, " -u, --userspace [CMD] Apply to the user-space tracer\n");
e14f64a8
DG
111 fprintf(ofp, " If no CMD, the domain used is UST global\n");
112 fprintf(ofp, " or else the domain is UST EXEC_NAME\n");
113 fprintf(ofp, " -p, --pid PID If -u, apply to specific PID (domain: UST PID)\n");
d78d6610 114#else
27221701 115 fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
d78d6610 116#endif
f3ed775e
DG
117 fprintf(ofp, "\n");
118 fprintf(ofp, "Event options:\n");
119 fprintf(ofp, " --tracepoint Tracepoint event (default)\n");
be49af1e
MD
120 fprintf(ofp, " - userspace tracer supports wildcards at end of string.\n");
121 fprintf(ofp, " Don't forget to quote to deal with bash expansion.\n");
122 fprintf(ofp, " e.g.:\n");
123 fprintf(ofp, " \"*\"\n");
124 fprintf(ofp, " \"app_component:na*\"\n");
0cda4f28
MD
125 fprintf(ofp, " --loglevel name\n");
126 fprintf(ofp, " Tracepoint loglevel (range: 0 to loglevel)\n");
127 fprintf(ofp, " --loglevel-only name\n");
128 fprintf(ofp, " Tracepoint loglevel (only this loglevel)\n");
8f0d098b 129 fprintf(ofp, " --probe [addr | symbol | symbol+offset]\n");
cf0e5467
MD
130 fprintf(ofp, " Dynamic probe.\n");
131 fprintf(ofp, " Addr and offset can be octal (0NNN...),\n");
132 fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
8f0d098b
MD
133 fprintf(ofp, " --function [addr | symbol | symbol+offset]\n");
134 fprintf(ofp, " Dynamic function entry/return probe.\n");
135 fprintf(ofp, " Addr and offset can be octal (0NNN...),\n");
136 fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
b213d387 137#if 0
8f0d098b
MD
138 fprintf(ofp, " --function:entry symbol\n");
139 fprintf(ofp, " Function tracer event\n");
b213d387 140#endif
a54bd42d 141 fprintf(ofp, " --syscall System call event\n");
f3ed775e
DG
142 fprintf(ofp, "\n");
143}
144
0d63dd19 145/*
6181537c 146 * Parse probe options.
0d63dd19 147 */
cf0e5467 148static int parse_probe_opts(struct lttng_event *ev, char *opt)
0d63dd19
DG
149{
150 int ret;
8ff0bbd0 151 char s_hex[19];
0d63dd19
DG
152 char name[LTTNG_SYMBOL_NAME_LEN];
153
154 if (opt == NULL) {
155 ret = -1;
8f0d098b 156 goto end;
0d63dd19
DG
157 }
158
159 /* Check for symbol+offset */
8ff0bbd0 160 ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
0d63dd19 161 if (ret == 2) {
7d29a247 162 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
99497cd0 163 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
cf0e5467 164 DBG("probe symbol %s", ev->attr.probe.symbol_name);
8ff0bbd0
DG
165 if (strlen(s_hex) == 0) {
166 ERR("Invalid probe offset %s", s_hex);
0d63dd19 167 ret = -1;
8f0d098b 168 goto end;
0d63dd19 169 }
8ff0bbd0 170 ev->attr.probe.offset = strtoul(s_hex, NULL, 0);
cf0e5467 171 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
3000dc78 172 ev->attr.probe.addr = 0;
8f0d098b
MD
173 goto end;
174 }
175
176 /* Check for symbol */
177 if (isalpha(name[0])) {
178 ret = sscanf(opt, "%s", name);
179 if (ret == 1) {
180 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
99497cd0 181 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
8f0d098b
MD
182 DBG("probe symbol %s", ev->attr.probe.symbol_name);
183 ev->attr.probe.offset = 0;
184 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
185 ev->attr.probe.addr = 0;
186 goto end;
187 }
0d63dd19
DG
188 }
189
190 /* Check for address */
8ff0bbd0 191 ret = sscanf(opt, "%s", s_hex);
0d63dd19 192 if (ret > 0) {
8ff0bbd0
DG
193 if (strlen(s_hex) == 0) {
194 ERR("Invalid probe address %s", s_hex);
0d63dd19 195 ret = -1;
8f0d098b 196 goto end;
0d63dd19 197 }
8ff0bbd0 198 ev->attr.probe.addr = strtoul(s_hex, NULL, 0);
cf0e5467 199 DBG("probe addr %" PRIu64, ev->attr.probe.addr);
3000dc78
DG
200 ev->attr.probe.offset = 0;
201 memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
8f0d098b 202 goto end;
0d63dd19
DG
203 }
204
205 /* No match */
206 ret = -1;
207
8f0d098b 208end:
0d63dd19
DG
209 return ret;
210}
211
8005f29a
MD
212/*
213 * Maps this from string to value
214 *
215 * TRACE_EMERG = 0,
216 * TRACE_ALERT = 1,
217 * TRACE_CRIT = 2,
218 * TRACE_ERR = 3,
219 * TRACE_WARNING = 4,
220 * TRACE_NOTICE = 5,
221 * TRACE_INFO = 6,
222 * TRACE_SYSTEM = 7,
223 * TRACE_PROCESS = 8,
224 * TRACE_MODULE = 9,
225 * TRACE_UNIT = 10,
226 * TRACE_CLASS = 11,
227 * TRACE_OBJECT = 12,
228 * TRACE_FUNCTION = 13,
229 * TRACE_PRINTF = 14,
230 * TRACE_DEBUG = 15,
231 */
232static
233int loglevel_str_to_value(const char *str)
234{
235 if (!strcmp(str, "TRACE_EMERG")) {
236 return 0;
237 } else if (!strcmp(str, "TRACE_ALERT")) {
238 return 1;
239 } else if (!strcmp(str, "TRACE_CRIT")) {
240 return 2;
241 } else if (!strcmp(str, "TRACE_ERR")) {
242 return 3;
243 } else if (!strcmp(str, "TRACE_WARNING")) {
244 return 4;
245 } else if (!strcmp(str, "TRACE_NOTICE")) {
246 return 5;
247 } else if (!strcmp(str, "TRACE_INFO")) {
248 return 6;
249 } else if (!strcmp(str, "TRACE_SYSTEM")) {
250 return 7;
251 } else if (!strcmp(str, "TRACE_PROCESS")) {
252 return 8;
253 } else if (!strcmp(str, "TRACE_MODULE")) {
254 return 9;
255 } else if (!strcmp(str, "TRACE_UNIT")) {
256 return 10;
257 } else if (!strcmp(str, "TRACE_CLASS")) {
258 return 11;
259 } else if (!strcmp(str, "TRACE_OBJECT")) {
260 return 12;
261 } else if (!strcmp(str, "TRACE_FUNCTION")) {
262 return 13;
263 } else if (!strcmp(str, "TRACE_PRINTF")) {
264 return 14;
265 } else if (!strcmp(str, "TRACE_DEBUG")) {
266 return 15;
267 } else {
268 return -1;
269 }
270}
271
f3ed775e 272/*
6181537c 273 * Enabling event using the lttng API.
f3ed775e 274 */
cd80958d 275static int enable_events(char *session_name)
f3ed775e 276{
ae856491 277 int err, ret = CMD_SUCCESS, warn = 0;
b73d0b29 278 char *event_name, *channel_name = NULL;
f3ed775e 279 struct lttng_event ev;
7d29a247 280 struct lttng_domain dom;
f3ed775e 281
7d29a247
DG
282 /* Create lttng domain */
283 if (opt_kernel) {
284 dom.type = LTTNG_DOMAIN_KERNEL;
d78d6610 285 } else if (opt_userspace) {
2bdd86d4 286 dom.type = LTTNG_DOMAIN_UST;
6181537c 287 } else {
e14f64a8 288 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
d16c1a4c 289 ret = CMD_ERROR;
6181537c 290 goto error;
2bdd86d4 291 }
7d29a247 292
ae856491
DG
293 if (opt_channel_name == NULL) {
294 err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME);
295 if (err < 0) {
296 ret = CMD_FATAL;
297 goto error;
298 }
299 } else {
300 channel_name = opt_channel_name;
301 }
302
cd80958d
DG
303 handle = lttng_create_handle(session_name, &dom);
304 if (handle == NULL) {
305 ret = -1;
306 goto error;
307 }
1aef21b6 308
cd80958d 309 if (opt_enable_all) {
8c9ae521 310 /* Default setup for enable all */
75e8c5ab
MD
311 if (opt_kernel) {
312 ev.type = opt_event_type;
313 ev.name[0] = '\0';
314 } else {
315 ev.type = LTTNG_EVENT_TRACEPOINT;
316 strcpy(ev.name, "*");
317 }
8c9ae521
DG
318
319 ret = lttng_enable_event(handle, &ev, channel_name);
320 if (ret < 0) {
321 goto error;
322 }
323
0133c199
MD
324 switch (opt_event_type) {
325 case LTTNG_EVENT_TRACEPOINT:
2bdd86d4
MD
326 MSG("All %s tracepoints are enabled in channel %s",
327 opt_kernel ? "kernel" : "UST", channel_name);
0133c199 328 break;
a54bd42d 329 case LTTNG_EVENT_SYSCALL:
0133c199 330 if (opt_kernel) {
8c9ae521
DG
331 MSG("All kernel system calls are enabled in channel %s",
332 channel_name);
c93d9daf 333 }
0133c199 334 break;
7a3d1328 335 case LTTNG_EVENT_ALL:
2bdd86d4
MD
336 MSG("All %s events are enabled in channel %s",
337 opt_kernel ? "kernel" : "UST", channel_name);
7a3d1328 338 break;
0133c199 339 default:
8c9ae521 340 /*
6181537c
DG
341 * We should not be here since lttng_enable_event should have
342 * failed on the event type.
8c9ae521 343 */
f3ed775e
DG
344 goto error;
345 }
8c9ae521 346 goto end;
f3ed775e
DG
347 }
348
349 /* Strip event list */
350 event_name = strtok(opt_event_list, ",");
351 while (event_name != NULL) {
6181537c
DG
352 /* Copy name and type of the event */
353 strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
354 ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
355 ev.type = opt_event_type;
356
f3ed775e
DG
357 /* Kernel tracer action */
358 if (opt_kernel) {
359 DBG("Enabling kernel event %s for channel %s",
360 event_name, channel_name);
f3ed775e
DG
361
362 switch (opt_event_type) {
7a3d1328
MD
363 case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
364 ev.type = LTTNG_EVENT_TRACEPOINT;
365 /* Fall-through */
e6ddca71 366 case LTTNG_EVENT_TRACEPOINT:
f3ed775e 367 break;
7d29a247 368 case LTTNG_EVENT_PROBE:
cf0e5467 369 ret = parse_probe_opts(&ev, opt_probe);
0d63dd19 370 if (ret < 0) {
cf0e5467 371 ERR("Unable to parse probe options");
0d63dd19
DG
372 ret = 0;
373 goto error;
374 }
f3ed775e
DG
375 break;
376 case LTTNG_EVENT_FUNCTION:
8f0d098b
MD
377 ret = parse_probe_opts(&ev, opt_function);
378 if (ret < 0) {
379 ERR("Unable to parse function probe options");
380 ret = 0;
381 goto error;
382 }
383 break;
384 case LTTNG_EVENT_FUNCTION_ENTRY:
6181537c
DG
385 strncpy(ev.attr.ftrace.symbol_name, opt_function_entry_symbol,
386 LTTNG_SYMBOL_NAME_LEN);
99497cd0 387 ev.attr.ftrace.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
f3ed775e 388 break;
a54bd42d 389 case LTTNG_EVENT_SYSCALL:
6181537c
DG
390 MSG("per-syscall selection not supported yet. Use \"-a\" "
391 "for all syscalls.");
f3ed775e 392 default:
1ab1ea0b 393 ret = CMD_UNDEFINED;
f3ed775e
DG
394 goto error;
395 }
0cda4f28 396
ed7f4083 397 if (opt_loglevel) {
0cda4f28
MD
398 MSG("Kernel loglevels are not supported.");
399 ret = CMD_UNDEFINED;
400 goto error;
401 }
402
403 /* kernel loglevels not implemented */
8005f29a 404 ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
f3ed775e 405 } else if (opt_userspace) { /* User-space tracer action */
d78d6610 406#if 0
e14f64a8
DG
407 if (opt_cmd_name != NULL || opt_pid) {
408 MSG("Only supporting tracing all UST processes (-u) for now.");
1ab1ea0b 409 ret = CMD_UNDEFINED;
2bdd86d4
MD
410 goto error;
411 }
d78d6610 412#endif
6181537c
DG
413
414 DBG("Enabling UST event %s for channel %s", event_name,
415 channel_name);
2bdd86d4
MD
416
417 switch (opt_event_type) {
418 case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
2bdd86d4
MD
419 /* Fall-through */
420 case LTTNG_EVENT_TRACEPOINT:
e4baff1e
MD
421 /* Copy name and type of the event */
422 ev.type = LTTNG_EVENT_TRACEPOINT;
423 strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
424 ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
2bdd86d4
MD
425 break;
426 case LTTNG_EVENT_PROBE:
427 case LTTNG_EVENT_FUNCTION:
428 case LTTNG_EVENT_FUNCTION_ENTRY:
429 case LTTNG_EVENT_SYSCALL:
430 default:
cc62c0c0 431 ERR("Event type not available for user-space tracing");
1ab1ea0b 432 ret = CMD_UNDEFINED;
2bdd86d4
MD
433 goto error;
434 }
0cda4f28
MD
435
436 ev.loglevel_type = opt_loglevel_type;
ed7f4083 437 if (opt_loglevel) {
8005f29a
MD
438 ev.loglevel = loglevel_str_to_value(opt_loglevel);
439 if (ev.loglevel == -1) {
440 ERR("Unknown loglevel %s", opt_loglevel);
441 goto error;
442 }
ed7f4083 443 }
f3ed775e 444 } else {
e14f64a8 445 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
f3ed775e
DG
446 goto error;
447 }
448
6181537c 449 ret = lttng_enable_event(handle, &ev, channel_name);
ae856491
DG
450 if (ret < 0) {
451 ERR("Event %s: %s (channel %s, session %s)", event_name,
452 lttng_strerror(ret), channel_name, session_name);
453 warn = 1;
454 } else {
6181537c
DG
455 MSG("%s event %s created in channel %s",
456 opt_kernel ? "kernel": "UST", event_name, channel_name);
457 }
458
f3ed775e
DG
459 /* Next event */
460 event_name = strtok(NULL, ",");
461 }
462
8c9ae521 463end:
f3ed775e 464error:
ae856491
DG
465 if (warn) {
466 ret = CMD_WARNING;
467 }
b73d0b29
MD
468 if (opt_channel_name == NULL) {
469 free(channel_name);
470 }
cd80958d
DG
471 lttng_destroy_handle(handle);
472
f3ed775e
DG
473 return ret;
474}
475
476/*
6181537c 477 * Add event to trace session
f3ed775e
DG
478 */
479int cmd_enable_events(int argc, const char **argv)
480{
ca1c3607 481 int opt, ret = CMD_SUCCESS;
f3ed775e 482 static poptContext pc;
cd80958d 483 char *session_name = NULL;
f3ed775e
DG
484
485 pc = poptGetContext(NULL, argc, argv, long_options, 0);
486 poptReadDefaultConfig(pc, 0);
487
488 /* Default event type */
7a3d1328 489 opt_event_type = LTTNG_EVENT_ALL;
f3ed775e
DG
490
491 while ((opt = poptGetNextOpt(pc)) != -1) {
492 switch (opt) {
493 case OPT_HELP:
ca1c3607 494 usage(stdout);
f3ed775e 495 goto end;
f3ed775e 496 case OPT_TRACEPOINT:
e6ddca71 497 opt_event_type = LTTNG_EVENT_TRACEPOINT;
f3ed775e 498 break;
cf0e5467 499 case OPT_PROBE:
7d29a247 500 opt_event_type = LTTNG_EVENT_PROBE;
f3ed775e
DG
501 break;
502 case OPT_FUNCTION:
503 opt_event_type = LTTNG_EVENT_FUNCTION;
8f0d098b
MD
504 break;
505 case OPT_FUNCTION_ENTRY:
506 opt_event_type = LTTNG_EVENT_FUNCTION_ENTRY;
f3ed775e 507 break;
a54bd42d
MD
508 case OPT_SYSCALL:
509 opt_event_type = LTTNG_EVENT_SYSCALL;
0133c199 510 break;
eeac7d46
MD
511 case OPT_USERSPACE:
512 opt_userspace = 1;
eeac7d46 513 break;
0cda4f28 514 case OPT_LOGLEVEL:
8005f29a 515 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
0cda4f28
MD
516 opt_loglevel = poptGetOptArg(pc);
517 break;
518 case OPT_LOGLEVEL_ONLY:
8005f29a 519 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
0cda4f28 520 opt_loglevel = poptGetOptArg(pc);
13dce3b7 521 break;
679b4943
SM
522 case OPT_LIST_OPTIONS:
523 list_cmd_options(stdout, long_options);
679b4943 524 goto end;
f3ed775e
DG
525 default:
526 usage(stderr);
527 ret = CMD_UNDEFINED;
528 goto end;
529 }
530 }
531
532 opt_event_list = (char*) poptGetArg(pc);
533 if (opt_event_list == NULL && opt_enable_all == 0) {
534 ERR("Missing event name(s).\n");
535 usage(stderr);
ca1c3607 536 ret = CMD_ERROR;
f3ed775e
DG
537 goto end;
538 }
539
cd80958d
DG
540 if (!opt_session_name) {
541 session_name = get_session_name();
542 if (session_name == NULL) {
ca1c3607 543 ret = CMD_ERROR;
cd80958d
DG
544 goto end;
545 }
546 } else {
547 session_name = opt_session_name;
548 }
549
550 ret = enable_events(session_name);
f3ed775e
DG
551
552end:
cd80958d
DG
553 if (opt_session_name == NULL) {
554 free(session_name);
555 }
556
ca1c3607 557 poptFreeContext(pc);
f3ed775e
DG
558 return ret;
559}
This page took 0.086408 seconds and 4 git commands to generate.