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");
350 WARN("Kernel loglevels are not supported.");
354 /* Create lttng domain */
356 dom
.type
= LTTNG_DOMAIN_KERNEL
;
357 dom
.buf_type
= LTTNG_BUFFER_GLOBAL
;
358 } else if (opt_userspace
) {
359 dom
.type
= LTTNG_DOMAIN_UST
;
361 dom
.buf_type
= LTTNG_BUFFER_PER_UID
;
362 } else if (opt_jul
) {
363 dom
.type
= LTTNG_DOMAIN_JUL
;
365 dom
.buf_type
= LTTNG_BUFFER_PER_UID
;
367 print_missing_domain();
372 channel_name
= opt_channel_name
;
374 handle
= lttng_create_handle(session_name
, &dom
);
375 if (handle
== NULL
) {
380 if (opt_enable_all
) {
381 /* Default setup for enable all */
383 ev
.type
= opt_event_type
;
385 /* kernel loglevels not implemented */
386 ev
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_ALL
;
388 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
389 strcpy(ev
.name
, "*");
390 ev
.loglevel_type
= opt_loglevel_type
;
392 ev
.loglevel
= loglevel_str_to_value(opt_loglevel
);
393 if (ev
.loglevel
== -1) {
394 ERR("Unknown loglevel %s", opt_loglevel
);
395 ret
= -LTTNG_ERR_INVALID
;
404 ret
= lttng_enable_event(handle
, &ev
, channel_name
);
407 case LTTNG_ERR_KERN_EVENT_EXIST
:
408 WARN("Kernel events already enabled (channel %s, session %s)",
409 print_channel_name(channel_name
), session_name
);
412 ERR("Events: %s (channel %s, session %s)",
414 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
415 ? print_raw_channel_name(channel_name
)
416 : print_channel_name(channel_name
),
423 switch (opt_event_type
) {
424 case LTTNG_EVENT_TRACEPOINT
:
425 if (opt_loglevel
&& dom
.type
!= LTTNG_DOMAIN_KERNEL
) {
426 MSG("All %s tracepoints are enabled in channel %s for loglevel %s",
427 get_domain_str(dom
.type
),
428 print_channel_name(channel_name
),
431 MSG("All %s tracepoints are enabled in channel %s",
432 get_domain_str(dom
.type
),
433 print_channel_name(channel_name
));
436 case LTTNG_EVENT_SYSCALL
:
438 MSG("All kernel system calls are enabled in channel %s",
439 print_channel_name(channel_name
));
442 case LTTNG_EVENT_ALL
:
443 if (opt_loglevel
&& dom
.type
!= LTTNG_DOMAIN_KERNEL
) {
444 MSG("All %s events are enabled in channel %s for loglevel %s",
445 get_domain_str(dom
.type
),
446 print_channel_name(channel_name
),
449 MSG("All %s events are enabled in channel %s",
450 get_domain_str(dom
.type
),
451 print_channel_name(channel_name
));
456 * We should not be here since lttng_enable_event should have
457 * failed on the event type.
463 ret
= lttng_enable_event_with_filter(handle
, &ev
, channel_name
,
467 case LTTNG_ERR_FILTER_EXIST
:
468 WARN("Filter on all events is already enabled"
469 " (channel %s, session %s)",
470 print_channel_name(channel_name
), session_name
);
473 ERR("All events: %s (channel %s, session %s, filter \'%s\')",
475 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
476 ? print_raw_channel_name(channel_name
)
477 : print_channel_name(channel_name
),
478 session_name
, opt_filter
);
483 MSG("Filter '%s' successfully set", opt_filter
);
489 /* Strip event list */
490 event_name
= strtok(opt_event_list
, ",");
491 while (event_name
!= NULL
) {
492 /* Copy name and type of the event */
493 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
494 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
495 ev
.type
= opt_event_type
;
497 /* Kernel tracer action */
499 DBG("Enabling kernel event %s for channel %s",
501 print_channel_name(channel_name
));
503 switch (opt_event_type
) {
504 case LTTNG_EVENT_ALL
: /* Default behavior is tracepoint */
505 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
507 case LTTNG_EVENT_TRACEPOINT
:
509 case LTTNG_EVENT_PROBE
:
510 ret
= parse_probe_opts(&ev
, opt_probe
);
512 ERR("Unable to parse probe options");
517 case LTTNG_EVENT_FUNCTION
:
518 ret
= parse_probe_opts(&ev
, opt_function
);
520 ERR("Unable to parse function probe options");
525 case LTTNG_EVENT_FUNCTION_ENTRY
:
526 strncpy(ev
.attr
.ftrace
.symbol_name
, opt_function_entry_symbol
,
527 LTTNG_SYMBOL_NAME_LEN
);
528 ev
.attr
.ftrace
.symbol_name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
530 case LTTNG_EVENT_SYSCALL
:
531 MSG("per-syscall selection not supported yet. Use \"-a\" "
532 "for all syscalls.");
538 /* kernel loglevels not implemented */
539 ev
.loglevel_type
= LTTNG_EVENT_LOGLEVEL_ALL
;
540 } else if (opt_userspace
) { /* User-space tracer action */
542 if (opt_cmd_name
!= NULL
|| opt_pid
) {
543 MSG("Only supporting tracing all UST processes (-u) for now.");
549 DBG("Enabling UST event %s for channel %s, loglevel %s", event_name
,
550 print_channel_name(channel_name
), opt_loglevel
? : "<all>");
552 switch (opt_event_type
) {
553 case LTTNG_EVENT_ALL
: /* Default behavior is tracepoint */
555 case LTTNG_EVENT_TRACEPOINT
:
556 /* Copy name and type of the event */
557 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
558 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
559 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
561 case LTTNG_EVENT_PROBE
:
562 case LTTNG_EVENT_FUNCTION
:
563 case LTTNG_EVENT_FUNCTION_ENTRY
:
564 case LTTNG_EVENT_SYSCALL
:
566 ERR("Event type not available for user-space tracing");
567 ret
= CMD_UNSUPPORTED
;
571 ev
.loglevel_type
= opt_loglevel_type
;
573 ev
.loglevel
= loglevel_str_to_value(opt_loglevel
);
574 if (ev
.loglevel
== -1) {
575 ERR("Unknown loglevel %s", opt_loglevel
);
576 ret
= -LTTNG_ERR_INVALID
;
582 } else if (opt_jul
) {
583 if (opt_event_type
!= LTTNG_EVENT_ALL
&&
584 opt_event_type
!= LTTNG_EVENT_TRACEPOINT
) {
585 ERR("Event type not supported for JUL domain.");
586 ret
= CMD_UNSUPPORTED
;
589 ev
.type
= LTTNG_EVENT_TRACEPOINT
;
590 strncpy(ev
.name
, event_name
, LTTNG_SYMBOL_NAME_LEN
);
591 ev
.name
[LTTNG_SYMBOL_NAME_LEN
- 1] = '\0';
593 print_missing_domain();
599 ret
= lttng_enable_event(handle
, &ev
, channel_name
);
601 /* Turn ret to positive value to handle the positive error code */
603 case LTTNG_ERR_KERN_EVENT_EXIST
:
604 WARN("Kernel event %s already enabled (channel %s, session %s)",
606 print_channel_name(channel_name
), session_name
);
609 ERR("Event %s: %s (channel %s, session %s)", event_name
,
611 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
612 ? print_raw_channel_name(channel_name
)
613 : print_channel_name(channel_name
),
619 MSG("%s event %s created in channel %s",
620 get_domain_str(dom
.type
), event_name
,
621 print_channel_name(channel_name
));
626 ret
= lttng_enable_event_with_filter(handle
, &ev
, channel_name
,
630 case LTTNG_ERR_FILTER_EXIST
:
631 WARN("Filter on event %s is already enabled"
632 " (channel %s, session %s)",
634 print_channel_name(channel_name
), session_name
);
637 ERR("Event %s: %s (channel %s, session %s, filter \'%s\')", ev
.name
,
639 ret
== -LTTNG_ERR_NEED_CHANNEL_NAME
640 ? print_raw_channel_name(channel_name
)
641 : print_channel_name(channel_name
),
642 session_name
, opt_filter
);
647 MSG("Filter '%s' successfully set", opt_filter
);
652 event_name
= strtok(NULL
, ",");
660 lttng_destroy_handle(handle
);
666 * Add event to trace session
668 int cmd_enable_events(int argc
, const char **argv
)
670 int opt
, ret
= CMD_SUCCESS
;
671 static poptContext pc
;
672 char *session_name
= NULL
;
675 pc
= poptGetContext(NULL
, argc
, argv
, long_options
, 0);
676 poptReadDefaultConfig(pc
, 0);
678 /* Default event type */
679 opt_event_type
= LTTNG_EVENT_ALL
;
681 while ((opt
= poptGetNextOpt(pc
)) != -1) {
687 opt_event_type
= LTTNG_EVENT_TRACEPOINT
;
690 opt_event_type
= LTTNG_EVENT_PROBE
;
693 opt_event_type
= LTTNG_EVENT_FUNCTION
;
695 case OPT_FUNCTION_ENTRY
:
696 opt_event_type
= LTTNG_EVENT_FUNCTION_ENTRY
;
699 opt_event_type
= LTTNG_EVENT_SYSCALL
;
705 opt_loglevel_type
= LTTNG_EVENT_LOGLEVEL_RANGE
;
706 opt_loglevel
= poptGetOptArg(pc
);
708 case OPT_LOGLEVEL_ONLY
:
709 opt_loglevel_type
= LTTNG_EVENT_LOGLEVEL_SINGLE
;
710 opt_loglevel
= poptGetOptArg(pc
);
712 case OPT_LIST_OPTIONS
:
713 list_cmd_options(stdout
, long_options
);
723 /* Validate event type. Multiple event type are not supported. */
724 if (event_type
== -1) {
725 event_type
= opt_event_type
;
727 if (event_type
!= opt_event_type
) {
728 ERR("Multiple event type not supported.");
735 opt_event_list
= (char*) poptGetArg(pc
);
736 if (opt_event_list
== NULL
&& opt_enable_all
== 0) {
737 ERR("Missing event name(s).\n");
743 if (!opt_session_name
) {
744 session_name
= get_session_name();
745 if (session_name
== NULL
) {
750 session_name
= opt_session_name
;
753 ret
= enable_events(session_name
);
756 if (opt_session_name
== NULL
) {