2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
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.
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.
24 #include <sys/types.h>
29 #include "../command.h"
30 #include <src/common/sessiond-comm/sessiond-comm.h>
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
;
40 static int opt_enable_all
;
41 static char *opt_probe
;
42 static char *opt_function
;
43 static char *opt_function_entry_symbol
;
44 static char *opt_channel_name
;
45 static char *opt_filter
;
47 /* Not implemented yet */
48 static char *opt_cmd_name
;
66 static struct lttng_handle
*handle
;
68 static struct poptOption long_options
[] = {
69 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
70 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
71 {"session", 's', POPT_ARG_STRING
, &opt_session_name
, 0, 0, 0},
72 {"all", 'a', POPT_ARG_VAL
, &opt_enable_all
, 1, 0, 0},
73 {"channel", 'c', POPT_ARG_STRING
, &opt_channel_name
, 0, 0, 0},
74 {"kernel", 'k', POPT_ARG_VAL
, &opt_kernel
, 1, 0, 0},
75 {"userspace", 'u', POPT_ARG_NONE
, 0, OPT_USERSPACE
, 0, 0},
76 {"jul", 'j', POPT_ARG_VAL
, &opt_jul
, 1, 0, 0},
77 {"tracepoint", 0, POPT_ARG_NONE
, 0, OPT_TRACEPOINT
, 0, 0},
78 {"probe", 0, POPT_ARG_STRING
, &opt_probe
, OPT_PROBE
, 0, 0},
79 {"function", 0, POPT_ARG_STRING
, &opt_function
, OPT_FUNCTION
, 0, 0},
82 * Currently removed from lttng kernel tracer. Removed from
83 * lttng UI to discourage its use.
85 {"function:entry", 0, POPT_ARG_STRING
, &opt_function_entry_symbol
, OPT_FUNCTION_ENTRY
, 0, 0},
87 {"syscall", 0, POPT_ARG_NONE
, 0, OPT_SYSCALL
, 0, 0},
88 {"loglevel", 0, POPT_ARG_STRING
, 0, OPT_LOGLEVEL
, 0, 0},
89 {"loglevel-only", 0, POPT_ARG_STRING
, 0, OPT_LOGLEVEL_ONLY
, 0, 0},
90 {"list-options", 0, POPT_ARG_NONE
, NULL
, OPT_LIST_OPTIONS
, NULL
, NULL
},
91 {"filter", 'f', POPT_ARG_STRING
, &opt_filter
, OPT_FILTER
, 0, 0},
98 static void usage(FILE *ofp
)
100 fprintf(ofp
, "usage: lttng enable-event NAME[,NAME2,...] [-k|-u] [OPTIONS] \n");
102 fprintf(ofp
, "Options:\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 NAME Apply to session name\n");
106 fprintf(ofp
, " -c, --channel NAME 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 fprintf(ofp
, " -u, --userspace Apply to the user-space tracer\n");
110 fprintf(ofp
, " -j, --jul Apply for Java application using JUL\n");
112 fprintf(ofp
, "Event options:\n");
113 fprintf(ofp
, " --tracepoint Tracepoint event (default)\n");
114 fprintf(ofp
, " - userspace tracer supports wildcards at end of string.\n");
115 fprintf(ofp
, " Don't forget to quote to deal with bash expansion.\n");
116 fprintf(ofp
, " e.g.:\n");
117 fprintf(ofp
, " \"*\"\n");
118 fprintf(ofp
, " \"app_component:na*\"\n");
119 fprintf(ofp
, " --probe (addr | symbol | symbol+offset)\n");
120 fprintf(ofp
, " Dynamic probe.\n");
121 fprintf(ofp
, " Addr and offset can be octal (0NNN...),\n");
122 fprintf(ofp
, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
123 fprintf(ofp
, " --function (addr | symbol | symbol+offset)\n");
124 fprintf(ofp
, " Dynamic function entry/return probe.\n");
125 fprintf(ofp
, " Addr and offset can be octal (0NNN...),\n");
126 fprintf(ofp
, " decimal (NNN...) or hexadecimal (0xNNN...)\n");
128 fprintf(ofp
, " --function:entry symbol\n");
129 fprintf(ofp
, " Function tracer event\n");
131 fprintf(ofp
, " --syscall System call event\n");
133 fprintf(ofp
, " --loglevel name\n");
134 fprintf(ofp
, " Tracepoint loglevel range from 0 to loglevel\n");
135 fprintf(ofp
, " --loglevel-only name\n");
136 fprintf(ofp
, " Tracepoint loglevel (only this loglevel)\n");
138 fprintf(ofp
, " The loglevel or loglevel-only options should be\n");
139 fprintf(ofp
, " combined with a tracepoint name or tracepoint\n");
140 fprintf(ofp
, " wildcard.\n");
141 fprintf(ofp
, " Available loglevels:\n");
142 fprintf(ofp
, " (higher value is more verbose)\n");
143 fprintf(ofp
, " TRACE_EMERG = 0\n");
144 fprintf(ofp
, " TRACE_ALERT = 1\n");
145 fprintf(ofp
, " TRACE_CRIT = 2\n");
146 fprintf(ofp
, " TRACE_ERR = 3\n");
147 fprintf(ofp
, " TRACE_WARNING = 4\n");
148 fprintf(ofp
, " TRACE_NOTICE = 5\n");
149 fprintf(ofp
, " TRACE_INFO = 6\n");
150 fprintf(ofp
, " TRACE_DEBUG_SYSTEM = 7\n");
151 fprintf(ofp
, " TRACE_DEBUG_PROGRAM = 8\n");
152 fprintf(ofp
, " TRACE_DEBUG_PROCESS = 9\n");
153 fprintf(ofp
, " TRACE_DEBUG_MODULE = 10\n");
154 fprintf(ofp
, " TRACE_DEBUG_UNIT = 11\n");
155 fprintf(ofp
, " TRACE_DEBUG_FUNCTION = 12\n");
156 fprintf(ofp
, " TRACE_DEBUG_LINE = 13\n");
157 fprintf(ofp
, " TRACE_DEBUG = 14\n");
158 fprintf(ofp
, " (shortcuts such as \"system\" are allowed)\n");
159 fprintf(ofp
, " -f, --filter \'expression\'\n");
160 fprintf(ofp
, " Filter expression on event fields and context.\n");
161 fprintf(ofp
, " Event recording depends on evaluation.\n");
162 fprintf(ofp
, " Only specify on first activation of\n");
163 fprintf(ofp
, " a given event within a session.\n");
164 fprintf(ofp
, " Filter only allowed when enabling\n");
165 fprintf(ofp
, " events within a session before tracing\n");
166 fprintf(ofp
, " is started. If the filter fails to link\n");
167 fprintf(ofp
, " with the event within the traced domain,\n");
168 fprintf(ofp
, " the event will be discarded. Currently,\n");
169 fprintf(ofp
, " filter is only implemented for the user-space\n");
170 fprintf(ofp
, " tracer.\n");
171 fprintf(ofp
, " Expression examples:.\n");
173 fprintf(ofp
, " 'intfield > 500 && intfield < 503'\n");
174 fprintf(ofp
, " '(strfield == \"test\" || intfield != 10) && intfield > 33'\n");
175 fprintf(ofp
, " 'doublefield > 1.1 && intfield < 5.3'\n");
177 fprintf(ofp
, " Wildcards are allowed at the end of strings:\n");
178 fprintf(ofp
, " 'seqfield1 == \"te*\"'\n");
179 fprintf(ofp
, " In string literals, the escape character is '\\'.\n");
180 fprintf(ofp
, " Use '\\*' for the '*' character, and '\\\\' for\n");
181 fprintf(ofp
, " the '\\' character. Wildcard match any sequence of,\n");
182 fprintf(ofp
, " characters including an empty sub-string (match 0 or\n");
183 fprintf(ofp
, " more characters).\n");
185 fprintf(ofp
, " Context information can be used for filtering. The\n");
186 fprintf(ofp
, " examples below show usage of context filtering on\n");
187 fprintf(ofp
, " process name (with a wildcard), process ID range, and\n");
188 fprintf(ofp
, " unique thread ID for filtering. The process and\n");
189 fprintf(ofp
, " thread ID of running applications can be found under\n");
190 fprintf(ofp
, " columns \"PID\" and \"LWP\" of the \"ps -eLf\" command.\n");
192 fprintf(ofp
, " '$ctx.procname == \"demo*\"'\n");
193 fprintf(ofp
, " '$ctx.vpid >= 4433 && $ctx.vpid < 4455'\n");
194 fprintf(ofp
, " '$ctx.vtid == 1234'\n");
199 * Parse probe options.
201 static int parse_probe_opts(struct lttng_event
*ev
, char *opt
)
205 char name
[LTTNG_SYMBOL_NAME_LEN
];
212 /* Check for symbol+offset */
213 ret
= sscanf(opt
, "%[^'+']+%s", name
, s_hex
);
215 strncpy(ev
->attr
.probe
.symbol_name
, name
, LTTNG_SYMBOL_NAME_LEN
);
216 ev
->attr
.probe
.symbol_name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
217 DBG("probe symbol %s", ev
->attr
.probe
.symbol_name
);
218 if (*s_hex
== '\0') {
219 ERR("Invalid probe offset %s", s_hex
);
223 ev
->attr
.probe
.offset
= strtoul(s_hex
, NULL
, 0);
224 DBG("probe offset %" PRIu64
, ev
->attr
.probe
.offset
);
225 ev
->attr
.probe
.addr
= 0;
229 /* Check for symbol */
230 if (isalpha(name
[0])) {
231 ret
= sscanf(opt
, "%s", name
);
233 strncpy(ev
->attr
.probe
.symbol_name
, name
, LTTNG_SYMBOL_NAME_LEN
);
234 ev
->attr
.probe
.symbol_name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
235 DBG("probe symbol %s", ev
->attr
.probe
.symbol_name
);
236 ev
->attr
.probe
.offset
= 0;
237 DBG("probe offset %" PRIu64
, ev
->attr
.probe
.offset
);
238 ev
->attr
.probe
.addr
= 0;
243 /* Check for address */
244 ret
= sscanf(opt
, "%s", s_hex
);
246 if (*s_hex
== '\0') {
247 ERR("Invalid probe address %s", s_hex
);
251 ev
->attr
.probe
.addr
= strtoul(s_hex
, NULL
, 0);
252 DBG("probe addr %" PRIu64
, ev
->attr
.probe
.addr
);
253 ev
->attr
.probe
.offset
= 0;
254 memset(ev
->attr
.probe
.symbol_name
, 0, LTTNG_SYMBOL_NAME_LEN
);
266 * Maps loglevel from string to value
269 int loglevel_str_to_value(const char *inputstr
)
272 char str
[LTTNG_SYMBOL_NAME_LEN
];
275 * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
276 * added at the end of the loop so a the upper bound we avoid the overflow.
278 while (i
< (LTTNG_SYMBOL_NAME_LEN
- 1) && inputstr
[i
] != '\0') {
279 str
[i
] = toupper(inputstr
[i
]);
283 if (!strcmp(str
, "TRACE_EMERG") || !strcmp(str
, "EMERG")) {
284 return LTTNG_LOGLEVEL_EMERG
;
285 } else if (!strcmp(str
, "TRACE_ALERT") || !strcmp(str
, "ALERT")) {
286 return LTTNG_LOGLEVEL_ALERT
;
287 } else if (!strcmp(str
, "TRACE_CRIT") || !strcmp(str
, "CRIT")) {
288 return LTTNG_LOGLEVEL_CRIT
;
289 } else if (!strcmp(str
, "TRACE_ERR") || !strcmp(str
, "ERR")) {
290 return LTTNG_LOGLEVEL_ERR
;
291 } else if (!strcmp(str
, "TRACE_WARNING") || !strcmp(str
, "WARNING")) {
292 return LTTNG_LOGLEVEL_WARNING
;
293 } else if (!strcmp(str
, "TRACE_NOTICE") || !strcmp(str
, "NOTICE")) {
294 return LTTNG_LOGLEVEL_NOTICE
;
295 } else if (!strcmp(str
, "TRACE_INFO") || !strcmp(str
, "INFO")) {
296 return LTTNG_LOGLEVEL_INFO
;
297 } else if (!strcmp(str
, "TRACE_DEBUG_SYSTEM") || !strcmp(str
, "DEBUG_SYSTEM") || !strcmp(str
, "SYSTEM")) {
298 return LTTNG_LOGLEVEL_DEBUG_SYSTEM
;
299 } else if (!strcmp(str
, "TRACE_DEBUG_PROGRAM") || !strcmp(str
, "DEBUG_PROGRAM") || !strcmp(str
, "PROGRAM")) {
300 return LTTNG_LOGLEVEL_DEBUG_PROGRAM
;
301 } else if (!strcmp(str
, "TRACE_DEBUG_PROCESS") || !strcmp(str
, "DEBUG_PROCESS") || !strcmp(str
, "PROCESS")) {
302 return LTTNG_LOGLEVEL_DEBUG_PROCESS
;
303 } else if (!strcmp(str
, "TRACE_DEBUG_MODULE") || !strcmp(str
, "DEBUG_MODULE") || !strcmp(str
, "MODULE")) {
304 return LTTNG_LOGLEVEL_DEBUG_MODULE
;
305 } else if (!strcmp(str
, "TRACE_DEBUG_UNIT") || !strcmp(str
, "DEBUG_UNIT") || !strcmp(str
, "UNIT")) {
306 return LTTNG_LOGLEVEL_DEBUG_UNIT
;
307 } else if (!strcmp(str
, "TRACE_DEBUG_FUNCTION") || !strcmp(str
, "DEBUG_FUNCTION") || !strcmp(str
, "FUNCTION")) {
308 return LTTNG_LOGLEVEL_DEBUG_FUNCTION
;
309 } else if (!strcmp(str
, "TRACE_DEBUG_LINE") || !strcmp(str
, "DEBUG_LINE") || !strcmp(str
, "LINE")) {
310 return LTTNG_LOGLEVEL_DEBUG_LINE
;
311 } else if (!strcmp(str
, "TRACE_DEBUG") || !strcmp(str
, "DEBUG")) {
312 return LTTNG_LOGLEVEL_DEBUG
;
319 const char *print_channel_name(const char *name
)
321 return name
? : DEFAULT_CHANNEL_NAME
;
325 const char *print_raw_channel_name(const char *name
)
327 return name
? : "<default>";
331 * Enabling event using the lttng API.
333 static int enable_events(char *session_name
)
335 int ret
= CMD_SUCCESS
, warn
= 0;
336 char *event_name
, *channel_name
= NULL
;
337 struct lttng_event ev
;
338 struct lttng_domain dom
;
340 memset(&ev
, 0, sizeof(ev
));
341 memset(&dom
, 0, sizeof(dom
));
345 ERR("Filter not implement for kernel tracing yet");
351 /* Create lttng domain */
353 dom
.type
= LTTNG_DOMAIN_KERNEL
;
354 dom
.buf_type
= LTTNG_BUFFER_GLOBAL
;
355 } else if (opt_userspace
) {
356 dom
.type
= LTTNG_DOMAIN_UST
;
358 dom
.buf_type
= LTTNG_BUFFER_PER_UID
;
359 } else if (opt_jul
) {
360 dom
.type
= LTTNG_DOMAIN_JUL
;
362 dom
.buf_type
= LTTNG_BUFFER_PER_UID
;
364 print_missing_domain();
369 channel_name
= opt_channel_name
;
371 handle
= lttng_create_handle(session_name
, &dom
);
372 if (handle
== NULL
) {
377 if (opt_enable_all
) {
378 /* Default setup for enable all */
380 ev
.type
= opt_event_type
;
382 /* kernel loglevels not implemented */
383 ev
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_ALL
;
385 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
386 strcpy(ev
.name
, "*");
387 ev
.loglevel_type
= opt_loglevel_type
;
389 ev
.loglevel
= loglevel_str_to_value(opt_loglevel
);
390 if (ev
.loglevel
== -1) {
391 ERR("Unknown loglevel %s", opt_loglevel
);
392 ret
= -LTTNG_ERR_INVALID
;
401 ret
= lttng_enable_event(handle
, &ev
, channel_name
);
404 case LTTNG_ERR_KERN_EVENT_EXIST
:
405 WARN("Kernel events already enabled (channel %s, session %s)",
406 print_channel_name(channel_name
), session_name
);
409 ERR("Events: %s (channel %s, session %s)",
411 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
412 ? print_raw_channel_name(channel_name
)
413 : print_channel_name(channel_name
),
420 switch (opt_event_type
) {
421 case LTTNG_EVENT_TRACEPOINT
:
423 MSG("All %s tracepoints are enabled in channel %s for loglevel %s",
424 get_domain_str(dom
.type
),
425 print_channel_name(channel_name
),
428 MSG("All %s tracepoints are enabled in channel %s",
429 get_domain_str(dom
.type
),
430 print_channel_name(channel_name
));
434 case LTTNG_EVENT_SYSCALL
:
436 MSG("All kernel system calls are enabled in channel %s",
437 print_channel_name(channel_name
));
440 case LTTNG_EVENT_ALL
:
442 MSG("All %s events are enabled in channel %s for loglevel %s",
443 get_domain_str(dom
.type
),
444 print_channel_name(channel_name
),
447 MSG("All %s events are enabled in channel %s",
448 get_domain_str(dom
.type
),
449 print_channel_name(channel_name
));
454 * We should not be here since lttng_enable_event should have
455 * failed on the event type.
461 ret
= lttng_enable_event_with_filter(handle
, &ev
, channel_name
,
465 case LTTNG_ERR_FILTER_EXIST
:
466 WARN("Filter on all events is already enabled"
467 " (channel %s, session %s)",
468 print_channel_name(channel_name
), session_name
);
471 ERR("All events: %s (channel %s, session %s, filter \'%s\')",
473 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
474 ? print_raw_channel_name(channel_name
)
475 : print_channel_name(channel_name
),
476 session_name
, opt_filter
);
481 MSG("Filter '%s' successfully set", opt_filter
);
487 /* Strip event list */
488 event_name
= strtok(opt_event_list
, ",");
489 while (event_name
!= NULL
) {
490 /* Copy name and type of the event */
491 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
492 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
493 ev
.type
= opt_event_type
;
495 /* Kernel tracer action */
497 DBG("Enabling kernel event %s for channel %s",
499 print_channel_name(channel_name
));
501 switch (opt_event_type
) {
502 case LTTNG_EVENT_ALL
: /* Default behavior is tracepoint */
503 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
505 case LTTNG_EVENT_TRACEPOINT
:
507 case LTTNG_EVENT_PROBE
:
508 ret
= parse_probe_opts(&ev
, opt_probe
);
510 ERR("Unable to parse probe options");
515 case LTTNG_EVENT_FUNCTION
:
516 ret
= parse_probe_opts(&ev
, opt_function
);
518 ERR("Unable to parse function probe options");
523 case LTTNG_EVENT_FUNCTION_ENTRY
:
524 strncpy(ev
.attr
.ftrace
.symbol_name
, opt_function_entry_symbol
,
525 LTTNG_SYMBOL_NAME_LEN
);
526 ev
.attr
.ftrace
.symbol_name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
528 case LTTNG_EVENT_SYSCALL
:
529 MSG("per-syscall selection not supported yet. Use \"-a\" "
530 "for all syscalls.");
537 MSG("Kernel loglevels are not supported.");
538 ret
= CMD_UNSUPPORTED
;
542 /* kernel loglevels not implemented */
543 ev
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_ALL
;
544 } else if (opt_userspace
) { /* User-space tracer action */
546 if (opt_cmd_name
!= NULL
|| opt_pid
) {
547 MSG("Only supporting tracing all UST processes (-u) for now.");
553 DBG("Enabling UST event %s for channel %s, loglevel %s", event_name
,
554 print_channel_name(channel_name
), opt_loglevel
? : "<all>");
556 switch (opt_event_type
) {
557 case LTTNG_EVENT_ALL
: /* Default behavior is tracepoint */
559 case LTTNG_EVENT_TRACEPOINT
:
560 /* Copy name and type of the event */
561 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
562 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
563 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
565 case LTTNG_EVENT_PROBE
:
566 case LTTNG_EVENT_FUNCTION
:
567 case LTTNG_EVENT_FUNCTION_ENTRY
:
568 case LTTNG_EVENT_SYSCALL
:
570 ERR("Event type not available for user-space tracing");
571 ret
= CMD_UNSUPPORTED
;
575 ev
.loglevel_type
= opt_loglevel_type
;
577 ev
.loglevel
= loglevel_str_to_value(opt_loglevel
);
578 if (ev
.loglevel
== -1) {
579 ERR("Unknown loglevel %s", opt_loglevel
);
580 ret
= -LTTNG_ERR_INVALID
;
586 } else if (opt_jul
) {
587 if (opt_event_type
!= LTTNG_EVENT_ALL
&&
588 opt_event_type
!= LTTNG_EVENT_TRACEPOINT
) {
589 ERR("Event type not supported for JUL domain.");
590 ret
= CMD_UNSUPPORTED
;
593 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
594 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
595 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
597 print_missing_domain();
603 ret
= lttng_enable_event(handle
, &ev
, channel_name
);
605 /* Turn ret to positive value to handle the positive error code */
607 case LTTNG_ERR_KERN_EVENT_EXIST
:
608 WARN("Kernel event %s already enabled (channel %s, session %s)",
610 print_channel_name(channel_name
), session_name
);
613 ERR("Event %s: %s (channel %s, session %s)", event_name
,
615 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
616 ? print_raw_channel_name(channel_name
)
617 : print_channel_name(channel_name
),
623 MSG("%s event %s created in channel %s",
624 get_domain_str(dom
.type
), event_name
,
625 print_channel_name(channel_name
));
630 ret
= lttng_enable_event_with_filter(handle
, &ev
, channel_name
,
634 case LTTNG_ERR_FILTER_EXIST
:
635 WARN("Filter on event %s is already enabled"
636 " (channel %s, session %s)",
638 print_channel_name(channel_name
), session_name
);
641 ERR("Event %s: %s (channel %s, session %s, filter \'%s\')", ev
.name
,
643 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
644 ? print_raw_channel_name(channel_name
)
645 : print_channel_name(channel_name
),
646 session_name
, opt_filter
);
651 MSG("Filter '%s' successfully set", opt_filter
);
656 event_name
= strtok(NULL
, ",");
664 lttng_destroy_handle(handle
);
670 * Add event to trace session
672 int cmd_enable_events(int argc
, const char **argv
)
674 int opt
, ret
= CMD_SUCCESS
;
675 static poptContext pc
;
676 char *session_name
= NULL
;
679 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
680 poptReadDefaultConfig(pc
, 0);
682 /* Default event type */
683 opt_event_type
= LTTNG_EVENT_ALL
;
685 while ((opt
= poptGetNextOpt(pc
)) != -1) {
691 opt_event_type
= LTTNG_EVENT_TRACEPOINT
;
694 opt_event_type
= LTTNG_EVENT_PROBE
;
697 opt_event_type
= LTTNG_EVENT_FUNCTION
;
699 case OPT_FUNCTION_ENTRY
:
700 opt_event_type
= LTTNG_EVENT_FUNCTION_ENTRY
;
703 opt_event_type
= LTTNG_EVENT_SYSCALL
;
709 opt_loglevel_type
= LTTNG_EVENT_LOGLEVEL_RANGE
;
710 opt_loglevel
= poptGetOptArg(pc
);
712 case OPT_LOGLEVEL_ONLY
:
713 opt_loglevel_type
= LTTNG_EVENT_LOGLEVEL_SINGLE
;
714 opt_loglevel
= poptGetOptArg(pc
);
716 case OPT_LIST_OPTIONS
:
717 list_cmd_options(stdout
, long_options
);
727 /* Validate event type. Multiple event type are not supported. */
728 if (event_type
== -1) {
729 event_type
= opt_event_type
;
731 if (event_type
!= opt_event_type
) {
732 ERR("Multiple event type not supported.");
739 opt_event_list
= (char*) poptGetArg(pc
);
740 if (opt_event_list
== NULL
&& opt_enable_all
== 0) {
741 ERR("Missing event name(s).\n");
747 if (!opt_session_name
) {
748 session_name
= get_session_name();
749 if (session_name
== NULL
) {
754 session_name
= opt_session_name
;
757 ret
= enable_events(session_name
);
760 if (opt_session_name
== NULL
) {