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