b5b46fb36f373fdbd3b8bcc611d0583e68522c4d
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
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
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
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>
27 #include <inttypes.h>
28 #include <ctype.h>
29
30 #include "../command.h"
31
32 static char *opt_event_list;
33 static int opt_event_type;
34 static const char *opt_loglevel;
35 static int opt_loglevel_type;
36 static int opt_kernel;
37 static char *opt_session_name;
38 static int opt_userspace;
39 static int opt_enable_all;
40 static char *opt_probe;
41 static char *opt_function;
42 static char *opt_function_entry_symbol;
43 static char *opt_channel_name;
44 #if 0
45 /* Not implemented yet */
46 static char *opt_cmd_name;
47 static pid_t opt_pid;
48 #endif
49
50 enum {
51 OPT_HELP = 1,
52 OPT_TRACEPOINT,
53 OPT_PROBE,
54 OPT_FUNCTION,
55 OPT_FUNCTION_ENTRY,
56 OPT_SYSCALL,
57 OPT_USERSPACE,
58 OPT_LOGLEVEL,
59 OPT_LOGLEVEL_ONLY,
60 OPT_LIST_OPTIONS,
61 };
62
63 static struct lttng_handle *handle;
64
65 static struct poptOption long_options[] = {
66 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
67 {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
68 {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
69 {"all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0},
70 {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
71 {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
72 #if 0
73 /* Not implemented yet */
74 {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
75 {"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
76 #else
77 {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
78 #endif
79 {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
80 {"probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0},
81 {"function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0},
82 #if 0
83 /*
84 * Currently removed from lttng kernel tracer. Removed from
85 * lttng UI to discourage its use.
86 */
87 {"function:entry", 0, POPT_ARG_STRING, &opt_function_entry_symbol, OPT_FUNCTION_ENTRY, 0, 0},
88 #endif
89 {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0},
90 {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0},
91 {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0},
92 {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
93 {0, 0, 0, 0, 0, 0, 0}
94 };
95
96 /*
97 * usage
98 */
99 static 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");
104 fprintf(ofp, " --list-options Simple listing of options\n");
105 fprintf(ofp, " -s, --session Apply to session name\n");
106 fprintf(ofp, " -c, --channel Apply to this channel\n");
107 fprintf(ofp, " -a, --all Enable all tracepoints and syscalls\n");
108 fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n");
109 #if 0
110 fprintf(ofp, " -u, --userspace [CMD] Apply to the user-space tracer\n");
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");
114 #else
115 fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
116 #endif
117 fprintf(ofp, "\n");
118 fprintf(ofp, "Event options:\n");
119 fprintf(ofp, " --tracepoint Tracepoint event (default)\n");
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");
125 fprintf(ofp, " --probe [addr | symbol | symbol+offset]\n");
126 fprintf(ofp, " Dynamic probe.\n");
127 fprintf(ofp, " Addr and offset can be octal (0NNN...),\n");
128 fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
129 fprintf(ofp, " --function [addr | symbol | symbol+offset]\n");
130 fprintf(ofp, " Dynamic function entry/return probe.\n");
131 fprintf(ofp, " Addr and offset can be octal (0NNN...),\n");
132 fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
133 #if 0
134 fprintf(ofp, " --function:entry symbol\n");
135 fprintf(ofp, " Function tracer event\n");
136 #endif
137 fprintf(ofp, " --syscall System call event\n");
138 fprintf(ofp, "\n");
139 fprintf(ofp, " --loglevel name\n");
140 fprintf(ofp, " Tracepoint loglevel range from 0 to loglevel\n");
141 fprintf(ofp, " --loglevel-only name\n");
142 fprintf(ofp, " Tracepoint loglevel (only this loglevel)\n");
143 fprintf(ofp, "\n");
144 fprintf(ofp, " The loglevel or loglevel-only options should be\n");
145 fprintf(ofp, " combined with a tracepoint name or tracepoint\n");
146 fprintf(ofp, " wildcard.\n");
147 fprintf(ofp, " Available loglevels:\n");
148 fprintf(ofp, " (higher value is more verbose)\n");
149 fprintf(ofp, " TRACE_EMERG = 0\n");
150 fprintf(ofp, " TRACE_ALERT = 1\n");
151 fprintf(ofp, " TRACE_CRIT = 2\n");
152 fprintf(ofp, " TRACE_ERR = 3\n");
153 fprintf(ofp, " TRACE_WARNING = 4\n");
154 fprintf(ofp, " TRACE_NOTICE = 5\n");
155 fprintf(ofp, " TRACE_INFO = 6\n");
156 fprintf(ofp, " TRACE_DEBUG_SYSTEM = 7\n");
157 fprintf(ofp, " TRACE_DEBUG_PROGRAM = 8\n");
158 fprintf(ofp, " TRACE_DEBUG_PROCESS = 9\n");
159 fprintf(ofp, " TRACE_DEBUG_MODULE = 10\n");
160 fprintf(ofp, " TRACE_DEBUG_UNIT = 11\n");
161 fprintf(ofp, " TRACE_DEBUG_FUNCTION = 12\n");
162 fprintf(ofp, " TRACE_DEBUG_LINE = 13\n");
163 fprintf(ofp, " TRACE_DEBUG = 14\n");
164 fprintf(ofp, " (shortcuts such as \"system\" are allowed)\n");
165 fprintf(ofp, "\n");
166 }
167
168 /*
169 * Parse probe options.
170 */
171 static int parse_probe_opts(struct lttng_event *ev, char *opt)
172 {
173 int ret;
174 char s_hex[19];
175 char name[LTTNG_SYMBOL_NAME_LEN];
176
177 if (opt == NULL) {
178 ret = -1;
179 goto end;
180 }
181
182 /* Check for symbol+offset */
183 ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
184 if (ret == 2) {
185 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
186 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
187 DBG("probe symbol %s", ev->attr.probe.symbol_name);
188 if (strlen(s_hex) == 0) {
189 ERR("Invalid probe offset %s", s_hex);
190 ret = -1;
191 goto end;
192 }
193 ev->attr.probe.offset = strtoul(s_hex, NULL, 0);
194 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
195 ev->attr.probe.addr = 0;
196 goto end;
197 }
198
199 /* Check for symbol */
200 if (isalpha(name[0])) {
201 ret = sscanf(opt, "%s", name);
202 if (ret == 1) {
203 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
204 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
205 DBG("probe symbol %s", ev->attr.probe.symbol_name);
206 ev->attr.probe.offset = 0;
207 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
208 ev->attr.probe.addr = 0;
209 goto end;
210 }
211 }
212
213 /* Check for address */
214 ret = sscanf(opt, "%s", s_hex);
215 if (ret > 0) {
216 if (strlen(s_hex) == 0) {
217 ERR("Invalid probe address %s", s_hex);
218 ret = -1;
219 goto end;
220 }
221 ev->attr.probe.addr = strtoul(s_hex, NULL, 0);
222 DBG("probe addr %" PRIu64, ev->attr.probe.addr);
223 ev->attr.probe.offset = 0;
224 memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
225 goto end;
226 }
227
228 /* No match */
229 ret = -1;
230
231 end:
232 return ret;
233 }
234
235 /*
236 * Maps loglevel from string to value
237 */
238 static
239 int loglevel_str_to_value(const char *inputstr)
240 {
241 int i = 0;
242 char str[LTTNG_SYMBOL_NAME_LEN];
243
244 while (inputstr[i] != '\0' && i < LTTNG_SYMBOL_NAME_LEN) {
245 str[i] = toupper(inputstr[i]);
246 i++;
247 }
248 str[i] = '\0';
249 if (!strcmp(str, "TRACE_EMERG") || !strcmp(str, "EMERG")) {
250 return LTTNG_LOGLEVEL_EMERG;
251 } else if (!strcmp(str, "TRACE_ALERT") || !strcmp(str, "ALERT")) {
252 return LTTNG_LOGLEVEL_ALERT;
253 } else if (!strcmp(str, "TRACE_CRIT") || !strcmp(str, "CRIT")) {
254 return LTTNG_LOGLEVEL_CRIT;
255 } else if (!strcmp(str, "TRACE_ERR") || !strcmp(str, "ERR")) {
256 return LTTNG_LOGLEVEL_ERR;
257 } else if (!strcmp(str, "TRACE_WARNING") || !strcmp(str, "WARNING")) {
258 return LTTNG_LOGLEVEL_WARNING;
259 } else if (!strcmp(str, "TRACE_NOTICE") || !strcmp(str, "NOTICE")) {
260 return LTTNG_LOGLEVEL_NOTICE;
261 } else if (!strcmp(str, "TRACE_INFO") || !strcmp(str, "INFO")) {
262 return LTTNG_LOGLEVEL_INFO;
263 } else if (!strcmp(str, "TRACE_DEBUG_SYSTEM") || !strcmp(str, "DEBUG_SYSTEM") || !strcmp(str, "SYSTEM")) {
264 return LTTNG_LOGLEVEL_DEBUG_SYSTEM;
265 } else if (!strcmp(str, "TRACE_DEBUG_PROGRAM") || !strcmp(str, "DEBUG_PROGRAM") || !strcmp(str, "PROGRAM")) {
266 return LTTNG_LOGLEVEL_DEBUG_PROGRAM;
267 } else if (!strcmp(str, "TRACE_DEBUG_PROCESS") || !strcmp(str, "DEBUG_PROCESS") || !strcmp(str, "PROCESS")) {
268 return LTTNG_LOGLEVEL_DEBUG_PROCESS;
269 } else if (!strcmp(str, "TRACE_DEBUG_MODULE") || !strcmp(str, "DEBUG_MODULE") || !strcmp(str, "MODULE")) {
270 return LTTNG_LOGLEVEL_DEBUG_MODULE;
271 } else if (!strcmp(str, "TRACE_DEBUG_UNIT") || !strcmp(str, "DEBUG_UNIT") || !strcmp(str, "UNIT")) {
272 return LTTNG_LOGLEVEL_DEBUG_UNIT;
273 } else if (!strcmp(str, "TRACE_DEBUG_FUNCTION") || !strcmp(str, "DEBUG_FUNCTION") || !strcmp(str, "FUNCTION")) {
274 return LTTNG_LOGLEVEL_DEBUG_FUNCTION;
275 } else if (!strcmp(str, "TRACE_DEBUG_LINE") || !strcmp(str, "DEBUG_LINE") || !strcmp(str, "LINE")) {
276 return LTTNG_LOGLEVEL_DEBUG_LINE;
277 } else if (!strcmp(str, "TRACE_DEBUG") || !strcmp(str, "DEBUG")) {
278 return LTTNG_LOGLEVEL_DEBUG;
279 } else {
280 return -1;
281 }
282 }
283
284 /*
285 * Enabling event using the lttng API.
286 */
287 static int enable_events(char *session_name)
288 {
289 int err, ret = CMD_SUCCESS, warn = 0;
290 char *event_name, *channel_name = NULL;
291 struct lttng_event ev;
292 struct lttng_domain dom;
293
294 memset(&ev, 0, sizeof(ev));
295 memset(&dom, 0, sizeof(dom));
296
297 /* Create lttng domain */
298 if (opt_kernel) {
299 dom.type = LTTNG_DOMAIN_KERNEL;
300 } else if (opt_userspace) {
301 dom.type = LTTNG_DOMAIN_UST;
302 } else {
303 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
304 ret = CMD_ERROR;
305 goto error;
306 }
307
308 if (opt_channel_name == NULL) {
309 err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME);
310 if (err < 0) {
311 ret = CMD_FATAL;
312 goto error;
313 }
314 } else {
315 channel_name = opt_channel_name;
316 }
317
318 handle = lttng_create_handle(session_name, &dom);
319 if (handle == NULL) {
320 ret = -1;
321 goto error;
322 }
323
324 if (opt_enable_all) {
325 /* Default setup for enable all */
326 if (opt_kernel) {
327 ev.type = opt_event_type;
328 ev.name[0] = '\0';
329 /* kernel loglevels not implemented */
330 ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
331 } else {
332 ev.type = LTTNG_EVENT_TRACEPOINT;
333 strcpy(ev.name, "*");
334 ev.loglevel_type = opt_loglevel_type;
335 if (opt_loglevel) {
336 ev.loglevel = loglevel_str_to_value(opt_loglevel);
337 if (ev.loglevel == -1) {
338 ERR("Unknown loglevel %s", opt_loglevel);
339 ret = -1;
340 goto error;
341 }
342 } else {
343 ev.loglevel = -1;
344 }
345 }
346
347 ret = lttng_enable_event(handle, &ev, channel_name);
348 if (ret < 0) {
349 goto error;
350 }
351
352 switch (opt_event_type) {
353 case LTTNG_EVENT_TRACEPOINT:
354 if (opt_loglevel) {
355 MSG("All %s tracepoints are enabled in channel %s for loglevel %s",
356 opt_kernel ? "kernel" : "UST", channel_name,
357 opt_loglevel);
358 } else {
359 MSG("All %s tracepoints are enabled in channel %s",
360 opt_kernel ? "kernel" : "UST", channel_name);
361
362 }
363 break;
364 case LTTNG_EVENT_SYSCALL:
365 if (opt_kernel) {
366 MSG("All kernel system calls are enabled in channel %s",
367 channel_name);
368 }
369 break;
370 case LTTNG_EVENT_ALL:
371 if (opt_loglevel) {
372 MSG("All %s events are enabled in channel %s for loglevel %s",
373 opt_kernel ? "kernel" : "UST", channel_name,
374 opt_loglevel);
375 } else {
376 MSG("All %s events are enabled in channel %s",
377 opt_kernel ? "kernel" : "UST", channel_name);
378 }
379 break;
380 default:
381 /*
382 * We should not be here since lttng_enable_event should have
383 * failed on the event type.
384 */
385 goto error;
386 }
387 goto end;
388 }
389
390 /* Strip event list */
391 event_name = strtok(opt_event_list, ",");
392 while (event_name != NULL) {
393 /* Copy name and type of the event */
394 strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
395 ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
396 ev.type = opt_event_type;
397
398 /* Kernel tracer action */
399 if (opt_kernel) {
400 DBG("Enabling kernel event %s for channel %s",
401 event_name, channel_name);
402
403 switch (opt_event_type) {
404 case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
405 ev.type = LTTNG_EVENT_TRACEPOINT;
406 /* Fall-through */
407 case LTTNG_EVENT_TRACEPOINT:
408 break;
409 case LTTNG_EVENT_PROBE:
410 ret = parse_probe_opts(&ev, opt_probe);
411 if (ret < 0) {
412 ERR("Unable to parse probe options");
413 ret = 0;
414 goto error;
415 }
416 break;
417 case LTTNG_EVENT_FUNCTION:
418 ret = parse_probe_opts(&ev, opt_function);
419 if (ret < 0) {
420 ERR("Unable to parse function probe options");
421 ret = 0;
422 goto error;
423 }
424 break;
425 case LTTNG_EVENT_FUNCTION_ENTRY:
426 strncpy(ev.attr.ftrace.symbol_name, opt_function_entry_symbol,
427 LTTNG_SYMBOL_NAME_LEN);
428 ev.attr.ftrace.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
429 break;
430 case LTTNG_EVENT_SYSCALL:
431 MSG("per-syscall selection not supported yet. Use \"-a\" "
432 "for all syscalls.");
433 default:
434 ret = CMD_UNDEFINED;
435 goto error;
436 }
437
438 if (opt_loglevel) {
439 MSG("Kernel loglevels are not supported.");
440 ret = CMD_UNDEFINED;
441 goto error;
442 }
443
444 /* kernel loglevels not implemented */
445 ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
446 } else if (opt_userspace) { /* User-space tracer action */
447 #if 0
448 if (opt_cmd_name != NULL || opt_pid) {
449 MSG("Only supporting tracing all UST processes (-u) for now.");
450 ret = CMD_UNDEFINED;
451 goto error;
452 }
453 #endif
454
455 DBG("Enabling UST event %s for channel %s, loglevel %s", event_name,
456 channel_name, opt_loglevel ? : "<all>");
457
458 switch (opt_event_type) {
459 case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
460 /* Fall-through */
461 case LTTNG_EVENT_TRACEPOINT:
462 /* Copy name and type of the event */
463 ev.type = LTTNG_EVENT_TRACEPOINT;
464 strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN);
465 ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
466 break;
467 case LTTNG_EVENT_PROBE:
468 case LTTNG_EVENT_FUNCTION:
469 case LTTNG_EVENT_FUNCTION_ENTRY:
470 case LTTNG_EVENT_SYSCALL:
471 default:
472 ERR("Event type not available for user-space tracing");
473 ret = CMD_UNDEFINED;
474 goto error;
475 }
476
477 ev.loglevel_type = opt_loglevel_type;
478 if (opt_loglevel) {
479 ev.loglevel = loglevel_str_to_value(opt_loglevel);
480 if (ev.loglevel == -1) {
481 ERR("Unknown loglevel %s", opt_loglevel);
482 ret = -1;
483 goto error;
484 }
485 } else {
486 ev.loglevel = -1;
487 }
488 } else {
489 ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
490 ret = CMD_ERROR;
491 goto error;
492 }
493
494 ret = lttng_enable_event(handle, &ev, channel_name);
495 if (ret < 0) {
496 ERR("Event %s: %s (channel %s, session %s)", event_name,
497 lttng_strerror(ret), channel_name, session_name);
498 warn = 1;
499 } else {
500 MSG("%s event %s created in channel %s",
501 opt_kernel ? "kernel": "UST", event_name, channel_name);
502 }
503
504 /* Next event */
505 event_name = strtok(NULL, ",");
506 }
507
508 end:
509 error:
510 if (warn) {
511 ret = CMD_WARNING;
512 }
513 if (opt_channel_name == NULL) {
514 free(channel_name);
515 }
516 lttng_destroy_handle(handle);
517
518 return ret;
519 }
520
521 /*
522 * Add event to trace session
523 */
524 int cmd_enable_events(int argc, const char **argv)
525 {
526 int opt, ret = CMD_SUCCESS;
527 static poptContext pc;
528 char *session_name = NULL;
529
530 pc = poptGetContext(NULL, argc, argv, long_options, 0);
531 poptReadDefaultConfig(pc, 0);
532
533 /* Default event type */
534 opt_event_type = LTTNG_EVENT_ALL;
535
536 while ((opt = poptGetNextOpt(pc)) != -1) {
537 switch (opt) {
538 case OPT_HELP:
539 usage(stdout);
540 goto end;
541 case OPT_TRACEPOINT:
542 opt_event_type = LTTNG_EVENT_TRACEPOINT;
543 break;
544 case OPT_PROBE:
545 opt_event_type = LTTNG_EVENT_PROBE;
546 break;
547 case OPT_FUNCTION:
548 opt_event_type = LTTNG_EVENT_FUNCTION;
549 break;
550 case OPT_FUNCTION_ENTRY:
551 opt_event_type = LTTNG_EVENT_FUNCTION_ENTRY;
552 break;
553 case OPT_SYSCALL:
554 opt_event_type = LTTNG_EVENT_SYSCALL;
555 break;
556 case OPT_USERSPACE:
557 opt_userspace = 1;
558 break;
559 case OPT_LOGLEVEL:
560 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
561 opt_loglevel = poptGetOptArg(pc);
562 break;
563 case OPT_LOGLEVEL_ONLY:
564 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
565 opt_loglevel = poptGetOptArg(pc);
566 break;
567 case OPT_LIST_OPTIONS:
568 list_cmd_options(stdout, long_options);
569 goto end;
570 default:
571 usage(stderr);
572 ret = CMD_UNDEFINED;
573 goto end;
574 }
575 }
576
577 opt_event_list = (char*) poptGetArg(pc);
578 if (opt_event_list == NULL && opt_enable_all == 0) {
579 ERR("Missing event name(s).\n");
580 usage(stderr);
581 ret = CMD_ERROR;
582 goto end;
583 }
584
585 if (!opt_session_name) {
586 session_name = get_session_name();
587 if (session_name == NULL) {
588 ret = CMD_ERROR;
589 goto end;
590 }
591 } else {
592 session_name = opt_session_name;
593 }
594
595 ret = enable_events(session_name);
596
597 end:
598 if (opt_session_name == NULL) {
599 free(session_name);
600 }
601
602 poptFreeContext(pc);
603 return ret;
604 }
This page took 0.04208 seconds and 3 git commands to generate.