Add --userspace-probe kernel event type
[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 *
d14d33bf
AM
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.
f3ed775e
DG
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 *
d14d33bf
AM
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.
f3ed775e
DG
16 */
17
6c1c0768 18#define _LGPL_SOURCE
b2064f54 19#include <assert.h>
f3ed775e
DG
20#include <popt.h>
21#include <stdio.h>
22#include <stdlib.h>
f3ed775e
DG
23#include <sys/stat.h>
24#include <sys/types.h>
25#include <unistd.h>
5a0de755 26#include <inttypes.h>
8f0d098b 27#include <ctype.h>
f3ed775e 28
343af227 29#include <common/sessiond-comm/sessiond-comm.h>
f5436bfc 30#include <common/compat/string.h>
dbc478f3 31#include <common/compat/getenv.h>
9f449915 32#include <common/string-utils/string-utils.h>
dbc478f3 33#include <common/utils.h>
f3ed775e 34
dbc478f3 35#include <lttng/constant.h>
89476427
JRJ
36/* Mi dependancy */
37#include <common/mi-lttng.h>
38
39#include "../command.h"
40
8ab7c0d9
MD
41#if (LTTNG_SYMBOL_NAME_LEN == 256)
42#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
43#endif
44
f3ed775e
DG
45static char *opt_event_list;
46static int opt_event_type;
0cda4f28
MD
47static const char *opt_loglevel;
48static int opt_loglevel_type;
6181537c 49static int opt_kernel;
5440dc42 50static char *opt_session_name;
f3ed775e 51static int opt_userspace;
b9dfb167 52static int opt_jul;
5cdb6027 53static int opt_log4j;
0e115563 54static int opt_python;
f3ed775e 55static int opt_enable_all;
cf0e5467 56static char *opt_probe;
dcabc190 57static char *opt_userspace_probe;
8f0d098b 58static char *opt_function;
f3ed775e 59static char *opt_channel_name;
53a80697 60static char *opt_filter;
fac3366c 61static char *opt_exclude;
f3ed775e 62
4fc83d94
PP
63#ifdef LTTNG_EMBED_HELP
64static const char help_msg[] =
65#include <lttng-enable-event.1.h>
66;
67#endif
68
f3ed775e
DG
69enum {
70 OPT_HELP = 1,
f3ed775e 71 OPT_TRACEPOINT,
cf0e5467 72 OPT_PROBE,
dcabc190 73 OPT_USERSPACE_PROBE,
f3ed775e 74 OPT_FUNCTION,
a54bd42d 75 OPT_SYSCALL,
eeac7d46 76 OPT_USERSPACE,
0cda4f28
MD
77 OPT_LOGLEVEL,
78 OPT_LOGLEVEL_ONLY,
679b4943 79 OPT_LIST_OPTIONS,
53a80697 80 OPT_FILTER,
fac3366c 81 OPT_EXCLUDE,
f3ed775e
DG
82};
83
cd80958d 84static struct lttng_handle *handle;
89476427 85static struct mi_writer *writer;
cd80958d 86
f3ed775e
DG
87static struct poptOption long_options[] = {
88 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
89 {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
5440dc42 90 {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
e14f64a8 91 {"all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0},
f3ed775e
DG
92 {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
93 {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
d78d6610 94 {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
b9dfb167 95 {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
5cdb6027 96 {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0},
0e115563 97 {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
f3ed775e 98 {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
7ebae521 99 {"probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0},
dcabc190 100 {"userspace-probe",0, POPT_ARG_STRING, &opt_userspace_probe, OPT_USERSPACE_PROBE, 0, 0},
40e9d5d3 101 {"function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0},
7ebae521 102 {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0},
0cda4f28
MD
103 {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0},
104 {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0},
679b4943 105 {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
53a80697 106 {"filter", 'f', POPT_ARG_STRING, &opt_filter, OPT_FILTER, 0, 0},
fac3366c 107 {"exclude", 'x', POPT_ARG_STRING, &opt_exclude, OPT_EXCLUDE, 0, 0},
f3ed775e
DG
108 {0, 0, 0, 0, 0, 0, 0}
109};
110
0d63dd19 111/*
6181537c 112 * Parse probe options.
0d63dd19 113 */
cf0e5467 114static int parse_probe_opts(struct lttng_event *ev, char *opt)
0d63dd19 115{
49d4e302
JRJ
116 int ret = CMD_SUCCESS;
117 int match;
8ff0bbd0 118 char s_hex[19];
8ab7c0d9 119#define S_HEX_LEN_SCANF_IS_A_BROKEN_API "18" /* 18 is (19 - 1) (\0 is extra) */
0d63dd19
DG
120 char name[LTTNG_SYMBOL_NAME_LEN];
121
122 if (opt == NULL) {
49d4e302 123 ret = CMD_ERROR;
8f0d098b 124 goto end;
0d63dd19
DG
125 }
126
127 /* Check for symbol+offset */
49d4e302 128 match = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
8ab7c0d9 129 "[^'+']+%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", name, s_hex);
49d4e302 130 if (match == 2) {
7d29a247 131 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
99497cd0 132 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
cf0e5467 133 DBG("probe symbol %s", ev->attr.probe.symbol_name);
9d035200 134 if (*s_hex == '\0') {
8ff0bbd0 135 ERR("Invalid probe offset %s", s_hex);
49d4e302 136 ret = CMD_ERROR;
8f0d098b 137 goto end;
0d63dd19 138 }
8ff0bbd0 139 ev->attr.probe.offset = strtoul(s_hex, NULL, 0);
cf0e5467 140 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
3000dc78 141 ev->attr.probe.addr = 0;
8f0d098b
MD
142 goto end;
143 }
144
145 /* Check for symbol */
146 if (isalpha(name[0])) {
49d4e302 147 match = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "s",
8ab7c0d9 148 name);
49d4e302 149 if (match == 1) {
8f0d098b 150 strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
99497cd0 151 ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
8f0d098b
MD
152 DBG("probe symbol %s", ev->attr.probe.symbol_name);
153 ev->attr.probe.offset = 0;
154 DBG("probe offset %" PRIu64, ev->attr.probe.offset);
155 ev->attr.probe.addr = 0;
156 goto end;
157 }
0d63dd19
DG
158 }
159
160 /* Check for address */
49d4e302
JRJ
161 match = sscanf(opt, "%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", s_hex);
162 if (match > 0) {
9d035200 163 if (*s_hex == '\0') {
8ff0bbd0 164 ERR("Invalid probe address %s", s_hex);
49d4e302 165 ret = CMD_ERROR;
8f0d098b 166 goto end;
0d63dd19 167 }
8ff0bbd0 168 ev->attr.probe.addr = strtoul(s_hex, NULL, 0);
cf0e5467 169 DBG("probe addr %" PRIu64, ev->attr.probe.addr);
3000dc78
DG
170 ev->attr.probe.offset = 0;
171 memset(ev->attr.probe.symbol_name, 0, LTTNG_SYMBOL_NAME_LEN);
8f0d098b 172 goto end;
0d63dd19
DG
173 }
174
175 /* No match */
49d4e302 176 ret = CMD_ERROR;
0d63dd19 177
8f0d098b 178end:
0d63dd19
DG
179 return ret;
180}
181
dbc478f3
FD
182/*
183 * Walk the directories in the PATH environment variable to find the target
184 * binary passed as parameter.
185 *
186 * On success, the full path of the binary is copied in binary_full_path out
187 * parameter. This buffer is allocated by the caller and must be at least
188 * LTTNG_PATH_MAX bytes long.
189 * On failure, returns -1;
190 */
191static int walk_command_search_path(const char *binary, char *binary_full_path)
192{
193 char *tentative_binary_path = NULL;
194 char *command_search_path = NULL;
195 char *curr_search_dir_end = NULL;
196 char *curr_search_dir = NULL;
197 struct stat stat_output;
198 int ret = 0;
199
200 command_search_path = lttng_secure_getenv("PATH");
201 if (!command_search_path) {
202 ret = -1;
203 goto end;
204 }
205
206 /*
207 * Duplicate the $PATH string as the char pointer returned by getenv() should
208 * not be modified.
209 */
210 command_search_path = strdup(command_search_path);
211 if (!command_search_path) {
212 ret = -1;
213 goto end;
214 }
215
216 /*
217 * This char array is used to concatenate path to binary to look for
218 * the binary.
219 */
220 tentative_binary_path = zmalloc(LTTNG_PATH_MAX * sizeof(char));
221 if (!tentative_binary_path) {
222 ret = -1;
223 goto alloc_error;
224 }
225
226 curr_search_dir = command_search_path;
227 do {
228 /*
229 * Split on ':'. The return value of this call points to the
230 * matching character.
231 */
232 curr_search_dir_end = strchr(curr_search_dir, ':');
233 if (curr_search_dir_end != NULL) {
234 /*
235 * Add a NULL byte to the end of the first token so it
236 * can be used as a string.
237 */
238 curr_search_dir_end[0] = '\0';
239 }
240
241 /* Empty the tentative path */
242 memset(tentative_binary_path, 0, LTTNG_PATH_MAX * sizeof(char));
243
244 /*
245 * Build the tentative path to the binary using the current
246 * search directory and the name of the binary.
247 */
248 ret = snprintf(tentative_binary_path, LTTNG_PATH_MAX, "%s/%s",
249 curr_search_dir, binary);
250 if (ret < 0) {
251 goto free_binary_path;
252 }
253 if (ret < LTTNG_PATH_MAX) {
254 /*
255 * Use STAT(2) to see if the file exists.
256 */
257 ret = stat(tentative_binary_path, &stat_output);
258 if (ret == 0) {
259 /*
260 * Verify that it is a regular file or a
261 * symlink and not a special file (e.g.
262 * device).
263 */
264 if (S_ISREG(stat_output.st_mode)
265 || S_ISLNK(stat_output.st_mode)) {
266 /*
267 * Found a match, set the out parameter
268 * and return success.
269 */
270 ret = lttng_strncpy(binary_full_path,
271 tentative_binary_path,
272 LTTNG_PATH_MAX);
273 if (ret == -1) {
274 ERR("Source path does not fit "
275 "in destination buffer.");
276 }
277 goto free_binary_path;
278 }
279 }
280 }
281 /* Go to the next entry in the $PATH variable. */
282 curr_search_dir = curr_search_dir_end + 1;
283 } while (curr_search_dir_end != NULL);
284
285free_binary_path:
286 free(tentative_binary_path);
287alloc_error:
288 free(command_search_path);
289end:
290 return ret;
291}
292
dcabc190
FD
293/*
294 * Parse userspace probe options
295 * Set the userspace probe fields in the lttng_event struct and set the
296 * target_path to the path to the binary.
297 */
298static int parse_userspace_probe_opts(struct lttng_event *ev, char *opt)
299{
300 int ret = CMD_SUCCESS;
301 int num_token;
302 char **tokens;
303 char *target_path = NULL;
304 char *unescaped_target_path = NULL;
305 char *real_target_path = NULL;
306 char *symbol_name = NULL, *probe_name = NULL, *provider_name = NULL;
307 struct lttng_userspace_probe_location *probe_location = NULL;
308 struct lttng_userspace_probe_location_lookup_method *lookup_method =
309 NULL;
310
311 if (opt == NULL) {
312 ret = CMD_ERROR;
313 goto end;
314 }
315
316 /*
317 * userspace probe fields are separated by ':'.
318 */
319 tokens = strutils_split(opt, ':', 1);
320 num_token = strutils_array_of_strings_len(tokens);
321
322 /*
323 * Early sanity check that the number of parameter is between 2 and 4
324 * inclusively.
325 * elf:PATH:SYMBOL
326 * std:PATH:PROVIDER_NAME:PROBE_NAME
327 * PATH:SYMBOL (same behavior as ELF)
328 */
329 if (num_token < 2 || num_token > 4) {
330 ret = CMD_ERROR;
331 goto end_string;
332 }
333
334 /*
335 * Looking up the first parameter will tell the technique to use to
336 * interpret the userspace probe/function description.
337 */
338 switch (num_token) {
339 case 2:
340 /* When the probe type is omitted we assume ELF for now. */
341 case 3:
342 if (num_token == 3 && strcmp(tokens[0], "elf") == 0) {
343 target_path = tokens[1];
344 symbol_name = tokens[2];
345 } else if (num_token == 2) {
346 target_path = tokens[0];
347 symbol_name = tokens[1];
348 } else {
349 ret = CMD_ERROR;
350 goto end_string;
351 }
352 lookup_method =
353 lttng_userspace_probe_location_lookup_method_function_elf_create();
354 if (!lookup_method) {
355 WARN("Failed to create ELF lookup method");
356 ret = CMD_ERROR;
357 goto end_string;
358 }
359 break;
360 case 4:
361 if (strcmp(tokens[0], "sdt") == 0) {
362 target_path = tokens[1];
363 provider_name = tokens[2];
364 probe_name = tokens[3];
365 } else {
366 ret = CMD_ERROR;
367 goto end_string;
368 }
369 lookup_method =
370 lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create();
371 if (!lookup_method) {
372 WARN("Failed to create ELF lookup method");
373 ret = CMD_ERROR;
374 goto end_string;
375 }
376 break;
377 default:
378 ret = CMD_ERROR;
379 goto end_string;
380 }
381
382 /* strutils_unescape_string allocates a new char *. */
383 unescaped_target_path = strutils_unescape_string(target_path, 0);
384 if (!unescaped_target_path) {
385 ret = -LTTNG_ERR_INVALID;
386 goto end_string;
387 }
388
389 /*
390 * If there is not forward slash in the path. Walk the $PATH else
391 * expand.
392 */
393 if (strchr(target_path, '/') == NULL) {
394 /* Walk the $PATH variable to find the targeted binary. */
395 real_target_path = zmalloc(LTTNG_PATH_MAX * sizeof(char));
396 if (!real_target_path) {
397 PERROR("Error allocating path buffer");
398 ret = CMD_ERROR;
399 goto end_unescaped_string;
400 }
401 ret = walk_command_search_path(target_path, real_target_path);
402 if (ret) {
403 ERR("Binary not found.");
404 ret = CMD_ERROR;
405 goto end_free_path;
406 }
407 } else {
408 /*
409 * Expand references to `/./` and `/../`. This function does not check
410 * if the file exists.
411 */
412 real_target_path = utils_expand_path_keep_symlink(target_path);
413 if (!real_target_path) {
414 ERR("Error expanding the path to binary.");
415 ret = CMD_ERROR;
416 goto end_free_path;
417 }
418
419 /*
420 * Check if the file exists using access(2). If it does not, walk the
421 * $PATH.
422 */
423 ret = access(real_target_path, F_OK);
424 if (ret) {
425 ret = CMD_ERROR;
426 goto end_free_path;
427 }
428 }
429
430 switch (lttng_userspace_probe_location_lookup_method_get_type(lookup_method)) {
431 case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
432 probe_location = lttng_userspace_probe_location_function_create(
433 real_target_path, symbol_name, lookup_method);
434 if (!probe_location) {
435 WARN("Failed to create function probe location");
436 ret = CMD_ERROR;
437 goto end_destroy_lookup_method;
438 }
439
440 /* Ownership transferred to probe_location. */
441 lookup_method = NULL;
442
443 ret = lttng_event_set_userspace_probe_location(ev, probe_location);
444 if (ret) {
445 WARN("Failed to set probe location on event");
446 ret = CMD_ERROR;
447 goto end_destroy_location;
448 }
449 break;
450 case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
451 probe_location = lttng_userspace_probe_location_tracepoint_create(
452 real_target_path, provider_name, probe_name, lookup_method);
453 if (!probe_location) {
454 WARN("Failed to create function probe location");
455 ret = CMD_ERROR;
456 goto end_destroy_lookup_method;
457 }
458
459 /* Ownership transferred to probe_location. */
460 lookup_method = NULL;
461
462 ret = lttng_event_set_userspace_probe_location(ev, probe_location);
463 if (ret) {
464 WARN("Failed to set probe location on event");
465 ret = CMD_ERROR;
466 goto end_destroy_location;
467 }
468 break;
469 default:
470 ret = CMD_ERROR;
471 goto end_string;
472 }
473
474 switch (ev->type) {
475 case LTTNG_EVENT_USERSPACE_PROBE:
476 break;
477 default:
478 assert(0);
479 }
480
481 goto end;
482
483end_destroy_location:
484 lttng_userspace_probe_location_destroy(probe_location);
485end_destroy_lookup_method:
486 lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
487end_free_path:
488 /*
489 * Free path that was allocated by the call to realpath() or when walking
490 * the PATH.
491 */
492 free(real_target_path);
493end_unescaped_string:
494 free(unescaped_target_path);
495end_string:
496 strutils_free_null_terminated_array_of_strings(tokens);
497end:
498 return ret;
499}
500
5cdb6027
DG
501/*
502 * Maps LOG4j loglevel from string to value
503 */
504static int loglevel_log4j_str_to_value(const char *inputstr)
505{
506 int i = 0;
507 char str[LTTNG_SYMBOL_NAME_LEN];
508
3712b110
JG
509 if (!inputstr || strlen(inputstr) == 0) {
510 return -1;
511 }
512
5cdb6027
DG
513 /*
514 * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
515 * added at the end of the loop so a the upper bound we avoid the overflow.
516 */
517 while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
518 str[i] = toupper(inputstr[i]);
519 i++;
520 }
521 str[i] = '\0';
522
523 if (!strcmp(str, "LOG4J_OFF") || !strcmp(str, "OFF")) {
524 return LTTNG_LOGLEVEL_LOG4J_OFF;
525 } else if (!strcmp(str, "LOG4J_FATAL") || !strcmp(str, "FATAL")) {
526 return LTTNG_LOGLEVEL_LOG4J_FATAL;
527 } else if (!strcmp(str, "LOG4J_ERROR") || !strcmp(str, "ERROR")) {
528 return LTTNG_LOGLEVEL_LOG4J_ERROR;
529 } else if (!strcmp(str, "LOG4J_WARN") || !strcmp(str, "WARN")) {
530 return LTTNG_LOGLEVEL_LOG4J_WARN;
531 } else if (!strcmp(str, "LOG4J_INFO") || !strcmp(str, "INFO")) {
532 return LTTNG_LOGLEVEL_LOG4J_INFO;
533 } else if (!strcmp(str, "LOG4J_DEBUG") || !strcmp(str, "DEBUG")) {
534 return LTTNG_LOGLEVEL_LOG4J_DEBUG;
535 } else if (!strcmp(str, "LOG4J_TRACE") || !strcmp(str, "TRACE")) {
536 return LTTNG_LOGLEVEL_LOG4J_TRACE;
537 } else if (!strcmp(str, "LOG4J_ALL") || !strcmp(str, "ALL")) {
538 return LTTNG_LOGLEVEL_LOG4J_ALL;
539 } else {
540 return -1;
541 }
542}
543
b2064f54
DG
544/*
545 * Maps JUL loglevel from string to value
546 */
547static int loglevel_jul_str_to_value(const char *inputstr)
548{
549 int i = 0;
550 char str[LTTNG_SYMBOL_NAME_LEN];
551
3712b110
JG
552 if (!inputstr || strlen(inputstr) == 0) {
553 return -1;
554 }
555
b2064f54
DG
556 /*
557 * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
558 * added at the end of the loop so a the upper bound we avoid the overflow.
559 */
560 while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
561 str[i] = toupper(inputstr[i]);
562 i++;
563 }
564 str[i] = '\0';
565
566 if (!strcmp(str, "JUL_OFF") || !strcmp(str, "OFF")) {
567 return LTTNG_LOGLEVEL_JUL_OFF;
568 } else if (!strcmp(str, "JUL_SEVERE") || !strcmp(str, "SEVERE")) {
569 return LTTNG_LOGLEVEL_JUL_SEVERE;
570 } else if (!strcmp(str, "JUL_WARNING") || !strcmp(str, "WARNING")) {
571 return LTTNG_LOGLEVEL_JUL_WARNING;
572 } else if (!strcmp(str, "JUL_INFO") || !strcmp(str, "INFO")) {
573 return LTTNG_LOGLEVEL_JUL_INFO;
574 } else if (!strcmp(str, "JUL_CONFIG") || !strcmp(str, "CONFIG")) {
575 return LTTNG_LOGLEVEL_JUL_CONFIG;
576 } else if (!strcmp(str, "JUL_FINE") || !strcmp(str, "FINE")) {
577 return LTTNG_LOGLEVEL_JUL_FINE;
578 } else if (!strcmp(str, "JUL_FINER") || !strcmp(str, "FINER")) {
579 return LTTNG_LOGLEVEL_JUL_FINER;
580 } else if (!strcmp(str, "JUL_FINEST") || !strcmp(str, "FINEST")) {
581 return LTTNG_LOGLEVEL_JUL_FINEST;
582 } else if (!strcmp(str, "JUL_ALL") || !strcmp(str, "ALL")) {
583 return LTTNG_LOGLEVEL_JUL_ALL;
584 } else {
585 return -1;
586 }
587}
588
0e115563
DG
589/*
590 * Maps Python loglevel from string to value
591 */
592static int loglevel_python_str_to_value(const char *inputstr)
593{
594 int i = 0;
595 char str[LTTNG_SYMBOL_NAME_LEN];
596
3712b110
JG
597 if (!inputstr || strlen(inputstr) == 0) {
598 return -1;
599 }
600
0e115563
DG
601 /*
602 * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
603 * added at the end of the loop so a the upper bound we avoid the overflow.
604 */
605 while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
606 str[i] = toupper(inputstr[i]);
607 i++;
608 }
609 str[i] = '\0';
610
611 if (!strcmp(str, "PYTHON_CRITICAL") || !strcmp(str, "CRITICAL")) {
612 return LTTNG_LOGLEVEL_PYTHON_CRITICAL;
613 } else if (!strcmp(str, "PYTHON_ERROR") || !strcmp(str, "ERROR")) {
614 return LTTNG_LOGLEVEL_PYTHON_ERROR;
615 } else if (!strcmp(str, "PYTHON_WARNING") || !strcmp(str, "WARNING")) {
616 return LTTNG_LOGLEVEL_PYTHON_WARNING;
617 } else if (!strcmp(str, "PYTHON_INFO") || !strcmp(str, "INFO")) {
618 return LTTNG_LOGLEVEL_PYTHON_INFO;
619 } else if (!strcmp(str, "PYTNON_DEBUG") || !strcmp(str, "DEBUG")) {
620 return LTTNG_LOGLEVEL_PYTHON_DEBUG;
621 } else if (!strcmp(str, "PYTHON_NOTSET") || !strcmp(str, "NOTSET")) {
622 return LTTNG_LOGLEVEL_PYTHON_NOTSET;
623 } else {
624 return -1;
625 }
626}
627
8005f29a 628/*
0c8477c8 629 * Maps loglevel from string to value
8005f29a
MD
630 */
631static
46839cc2 632int loglevel_str_to_value(const char *inputstr)
8005f29a 633{
46839cc2
MD
634 int i = 0;
635 char str[LTTNG_SYMBOL_NAME_LEN];
636
3712b110
JG
637 if (!inputstr || strlen(inputstr) == 0) {
638 return -1;
639 }
640
e051e07c
DG
641 /*
642 * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
643 * added at the end of the loop so a the upper bound we avoid the overflow.
644 */
645 while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
46839cc2
MD
646 str[i] = toupper(inputstr[i]);
647 i++;
648 }
649 str[i] = '\0';
650 if (!strcmp(str, "TRACE_EMERG") || !strcmp(str, "EMERG")) {
651 return LTTNG_LOGLEVEL_EMERG;
652 } else if (!strcmp(str, "TRACE_ALERT") || !strcmp(str, "ALERT")) {
653 return LTTNG_LOGLEVEL_ALERT;
654 } else if (!strcmp(str, "TRACE_CRIT") || !strcmp(str, "CRIT")) {
655 return LTTNG_LOGLEVEL_CRIT;
656 } else if (!strcmp(str, "TRACE_ERR") || !strcmp(str, "ERR")) {
657 return LTTNG_LOGLEVEL_ERR;
658 } else if (!strcmp(str, "TRACE_WARNING") || !strcmp(str, "WARNING")) {
659 return LTTNG_LOGLEVEL_WARNING;
660 } else if (!strcmp(str, "TRACE_NOTICE") || !strcmp(str, "NOTICE")) {
661 return LTTNG_LOGLEVEL_NOTICE;
662 } else if (!strcmp(str, "TRACE_INFO") || !strcmp(str, "INFO")) {
663 return LTTNG_LOGLEVEL_INFO;
664 } else if (!strcmp(str, "TRACE_DEBUG_SYSTEM") || !strcmp(str, "DEBUG_SYSTEM") || !strcmp(str, "SYSTEM")) {
665 return LTTNG_LOGLEVEL_DEBUG_SYSTEM;
666 } else if (!strcmp(str, "TRACE_DEBUG_PROGRAM") || !strcmp(str, "DEBUG_PROGRAM") || !strcmp(str, "PROGRAM")) {
667 return LTTNG_LOGLEVEL_DEBUG_PROGRAM;
668 } else if (!strcmp(str, "TRACE_DEBUG_PROCESS") || !strcmp(str, "DEBUG_PROCESS") || !strcmp(str, "PROCESS")) {
669 return LTTNG_LOGLEVEL_DEBUG_PROCESS;
670 } else if (!strcmp(str, "TRACE_DEBUG_MODULE") || !strcmp(str, "DEBUG_MODULE") || !strcmp(str, "MODULE")) {
671 return LTTNG_LOGLEVEL_DEBUG_MODULE;
672 } else if (!strcmp(str, "TRACE_DEBUG_UNIT") || !strcmp(str, "DEBUG_UNIT") || !strcmp(str, "UNIT")) {
673 return LTTNG_LOGLEVEL_DEBUG_UNIT;
674 } else if (!strcmp(str, "TRACE_DEBUG_FUNCTION") || !strcmp(str, "DEBUG_FUNCTION") || !strcmp(str, "FUNCTION")) {
675 return LTTNG_LOGLEVEL_DEBUG_FUNCTION;
676 } else if (!strcmp(str, "TRACE_DEBUG_LINE") || !strcmp(str, "DEBUG_LINE") || !strcmp(str, "LINE")) {
677 return LTTNG_LOGLEVEL_DEBUG_LINE;
678 } else if (!strcmp(str, "TRACE_DEBUG") || !strcmp(str, "DEBUG")) {
679 return LTTNG_LOGLEVEL_DEBUG;
8005f29a
MD
680 } else {
681 return -1;
682 }
683}
684
85076754
MD
685static
686const char *print_channel_name(const char *name)
687{
688 return name ? : DEFAULT_CHANNEL_NAME;
689}
690
691static
692const char *print_raw_channel_name(const char *name)
693{
694 return name ? : "<default>";
695}
696
89476427
JRJ
697/*
698 * Mi print exlcusion list
699 */
700static
9f449915 701int mi_print_exclusion(char **names)
89476427
JRJ
702{
703 int i, ret;
9f449915 704 int count = names ? strutils_array_of_strings_len(names) : 0;
89476427
JRJ
705
706 assert(writer);
707
708 if (count == 0) {
709 ret = 0;
710 goto end;
711 }
712 ret = mi_lttng_writer_open_element(writer, config_element_exclusions);
713 if (ret) {
714 goto end;
715 }
716
717 for (i = 0; i < count; i++) {
718 ret = mi_lttng_writer_write_element_string(writer,
719 config_element_exclusion, names[i]);
720 if (ret) {
721 goto end;
722 }
723 }
724
725 /* Close exclusions element */
726 ret = mi_lttng_writer_close_element(writer);
727
728end:
729 return ret;
730}
731
9c48cab3
JI
732/*
733 * Return allocated string for pretty-printing exclusion names.
734 */
735static
9f449915 736char *print_exclusions(char **names)
9c48cab3
JI
737{
738 int length = 0;
739 int i;
740 const char *preamble = " excluding ";
741 char *ret;
9f449915 742 int count = names ? strutils_array_of_strings_len(names) : 0;
9c48cab3
JI
743
744 if (count == 0) {
745 return strdup("");
746 }
747
748 /* calculate total required length */
749 for (i = 0; i < count; i++) {
9f449915 750 length += strlen(names[i]) + 4;
9c48cab3
JI
751 }
752
753 /* add length of preamble + one for NUL - one for last (missing) comma */
754 length += strlen(preamble);
9f449915 755 ret = zmalloc(length + 1);
fd591b18
MD
756 if (!ret) {
757 return NULL;
758 }
9c48cab3
JI
759 strncpy(ret, preamble, length);
760 for (i = 0; i < count; i++) {
9f449915 761 strcat(ret, "\"");
9c48cab3 762 strcat(ret, names[i]);
9f449915 763 strcat(ret, "\"");
9c48cab3 764 if (i != count - 1) {
9f449915 765 strcat(ret, ", ");
9c48cab3
JI
766 }
767 }
89476427 768
9c48cab3
JI
769 return ret;
770}
771
748bde76 772static
9f449915 773int check_exclusion_subsets(const char *event_name, const char *exclusion)
748bde76 774{
9f449915
PP
775 bool warn = false;
776 int ret = 0;
777 const char *e = event_name;
778 const char *x = exclusion;
779
780 /* Scan both the excluder and the event letter by letter */
781 while (true) {
782 if (*e == '\\') {
783 if (*x != *e) {
784 warn = true;
785 goto end;
786 }
748bde76 787
9f449915
PP
788 e++;
789 x++;
790 goto cmp_chars;
791 }
792
793 if (*x == '*') {
794 /* Event is a subset of the excluder */
795 ERR("Event %s: %s excludes all events from %s",
796 event_name, exclusion, event_name);
797 goto error;
798 }
799
800 if (*e == '*') {
801 /*
802 * Reached the end of the event name before the
803 * end of the exclusion: this is valid.
804 */
805 goto end;
806 }
807
808cmp_chars:
809 if (*x != *e) {
810 warn = true;
811 break;
812 }
813
814 x++;
815 e++;
748bde76
JI
816 }
817
9f449915 818 goto end;
748bde76 819
9f449915
PP
820error:
821 ret = -1;
748bde76 822
9f449915
PP
823end:
824 if (warn) {
825 WARN("Event %s: %s does not exclude any events from %s",
826 event_name, exclusion, event_name);
827 }
748bde76 828
9f449915
PP
829 return ret;
830}
831
9f449915
PP
832static
833int create_exclusion_list_and_validate(const char *event_name,
834 const char *exclusions_arg,
835 char ***exclusion_list)
836{
837 int ret = 0;
838 char **exclusions = NULL;
839
840 /* Event name must be a valid globbing pattern to allow exclusions. */
841 if (!strutils_is_star_glob_pattern(event_name)) {
842 ERR("Event %s: Exclusions can only be used with a globbing pattern",
843 event_name);
844 goto error;
845 }
846
847 /* Split exclusions. */
848 exclusions = strutils_split(exclusions_arg, ',', true);
849 if (!exclusions) {
850 goto error;
851 }
852
853 /*
854 * If the event name is a star-at-end only globbing pattern,
855 * then we can validate the individual exclusions. Otherwise
856 * all exclusions are passed to the session daemon.
857 */
858 if (strutils_is_star_at_the_end_only_glob_pattern(event_name)) {
859 char * const *exclusion;
860
861 for (exclusion = exclusions; *exclusion; exclusion++) {
862 if (!strutils_is_star_glob_pattern(*exclusion) ||
863 strutils_is_star_at_the_end_only_glob_pattern(*exclusion)) {
8aa579d4 864 ret = check_exclusion_subsets(event_name, *exclusion);
9f449915 865 if (ret) {
5ef79758
MD
866 goto error;
867 }
748bde76 868 }
748bde76
JI
869 }
870 }
9f449915
PP
871
872 *exclusion_list = exclusions;
873
748bde76 874 goto end;
9f449915 875
748bde76 876error:
9f449915
PP
877 ret = -1;
878 strutils_free_null_terminated_array_of_strings(exclusions);
879
748bde76 880end:
748bde76
JI
881 return ret;
882}
502bbe89 883
9f449915
PP
884static void warn_on_truncated_exclusion_names(char * const *exclusion_list,
885 int *warn)
502bbe89 886{
9f449915 887 char * const *exclusion;
502bbe89 888
9f449915
PP
889 for (exclusion = exclusion_list; *exclusion; exclusion++) {
890 if (strlen(*exclusion) >= LTTNG_SYMBOL_NAME_LEN) {
502bbe89 891 WARN("Event exclusion \"%s\" will be truncated",
9f449915 892 *exclusion);
502bbe89
PP
893 *warn = 1;
894 }
895 }
896}
897
f3ed775e 898/*
6181537c 899 * Enabling event using the lttng API.
89476427 900 * Note: in case of error only the last error code will be return.
f3ed775e 901 */
cd80958d 902static int enable_events(char *session_name)
f3ed775e 903{
89476427
JRJ
904 int ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
905 int error_holder = CMD_SUCCESS, warn = 0, error = 0, success = 1;
b73d0b29 906 char *event_name, *channel_name = NULL;
91744e14 907 struct lttng_event *ev;
7d29a247 908 struct lttng_domain dom;
7ed70bc9 909 char **exclusion_list = NULL;
f3ed775e 910
441c16a7
MD
911 memset(&dom, 0, sizeof(dom));
912
91744e14
FD
913 ev = lttng_event_create();
914 if (!ev) {
915 ret = CMD_ERROR;
916 goto error;
917 }
918
53a80697 919 if (opt_kernel) {
67b58630
JG
920 if (opt_loglevel) {
921 WARN("Kernel loglevels are not supported.");
922 }
53a80697
MD
923 }
924
7d29a247
DG
925 /* Create lttng domain */
926 if (opt_kernel) {
927 dom.type = LTTNG_DOMAIN_KERNEL;
7972aab2 928 dom.buf_type = LTTNG_BUFFER_GLOBAL;
d78d6610 929 } else if (opt_userspace) {
2bdd86d4 930 dom.type = LTTNG_DOMAIN_UST;
7972aab2 931 /* Default. */
8692d4e5 932 dom.buf_type = LTTNG_BUFFER_PER_UID;
b9dfb167
DG
933 } else if (opt_jul) {
934 dom.type = LTTNG_DOMAIN_JUL;
935 /* Default. */
936 dom.buf_type = LTTNG_BUFFER_PER_UID;
5cdb6027
DG
937 } else if (opt_log4j) {
938 dom.type = LTTNG_DOMAIN_LOG4J;
939 /* Default. */
940 dom.buf_type = LTTNG_BUFFER_PER_UID;
0e115563
DG
941 } else if (opt_python) {
942 dom.type = LTTNG_DOMAIN_PYTHON;
943 /* Default. */
944 dom.buf_type = LTTNG_BUFFER_PER_UID;
6181537c 945 } else {
3ecec76a
PP
946 /* Checked by the caller. */
947 assert(0);
2bdd86d4 948 }
7d29a247 949
8b08c525
AB
950 if (opt_exclude) {
951 switch (dom.type) {
952 case LTTNG_DOMAIN_KERNEL:
953 case LTTNG_DOMAIN_JUL:
954 case LTTNG_DOMAIN_LOG4J:
955 case LTTNG_DOMAIN_PYTHON:
956 ERR("Event name exclusions are not yet implemented for %s events",
957 get_domain_str(dom.type));
958 ret = CMD_ERROR;
959 goto error;
960 case LTTNG_DOMAIN_UST:
961 /* Exclusions supported */
962 break;
963 default:
964 assert(0);
965 }
d5dd17fd
JI
966 }
967
85076754 968 channel_name = opt_channel_name;
ae856491 969
cd80958d
DG
970 handle = lttng_create_handle(session_name, &dom);
971 if (handle == NULL) {
972 ret = -1;
973 goto error;
974 }
1aef21b6 975
89476427
JRJ
976 /* Prepare Mi */
977 if (lttng_opt_mi) {
978 /* Open a events element */
979 ret = mi_lttng_writer_open_element(writer, config_element_events);
980 if (ret) {
981 ret = CMD_ERROR;
982 goto error;
983 }
984 }
985
cd80958d 986 if (opt_enable_all) {
8c9ae521 987 /* Default setup for enable all */
75e8c5ab 988 if (opt_kernel) {
91744e14
FD
989 ev->type = opt_event_type;
990 strcpy(ev->name, "*");
300b8fd5 991 /* kernel loglevels not implemented */
91744e14 992 ev->loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
75e8c5ab 993 } else {
91744e14
FD
994 ev->type = LTTNG_EVENT_TRACEPOINT;
995 strcpy(ev->name, "*");
996 ev->loglevel_type = opt_loglevel_type;
300b8fd5 997 if (opt_loglevel) {
0e115563 998 assert(opt_userspace || opt_jul || opt_log4j || opt_python);
b2064f54 999 if (opt_userspace) {
91744e14 1000 ev->loglevel = loglevel_str_to_value(opt_loglevel);
b2064f54 1001 } else if (opt_jul) {
91744e14 1002 ev->loglevel = loglevel_jul_str_to_value(opt_loglevel);
5cdb6027 1003 } else if (opt_log4j) {
91744e14 1004 ev->loglevel = loglevel_log4j_str_to_value(opt_loglevel);
0e115563 1005 } else if (opt_python) {
91744e14 1006 ev->loglevel = loglevel_python_str_to_value(opt_loglevel);
b2064f54 1007 }
91744e14 1008 if (ev->loglevel == -1) {
300b8fd5 1009 ERR("Unknown loglevel %s", opt_loglevel);
2f70b271 1010 ret = -LTTNG_ERR_INVALID;
300b8fd5
MD
1011 goto error;
1012 }
22e25b71 1013 } else {
0e115563 1014 assert(opt_userspace || opt_jul || opt_log4j || opt_python);
b2064f54 1015 if (opt_userspace) {
91744e14 1016 ev->loglevel = -1;
34aa3685 1017 } else if (opt_jul) {
91744e14 1018 ev->loglevel = LTTNG_LOGLEVEL_JUL_ALL;
34aa3685 1019 } else if (opt_log4j) {
91744e14 1020 ev->loglevel = LTTNG_LOGLEVEL_LOG4J_ALL;
0e115563 1021 } else if (opt_python) {
91744e14 1022 ev->loglevel = LTTNG_LOGLEVEL_PYTHON_DEBUG;
b2064f54 1023 }
300b8fd5 1024 }
75e8c5ab 1025 }
8c9ae521 1026
7ed70bc9 1027 if (opt_exclude) {
9f449915
PP
1028 ret = create_exclusion_list_and_validate("*",
1029 opt_exclude, &exclusion_list);
1030 if (ret) {
1031 ret = CMD_ERROR;
7ed70bc9
JI
1032 goto error;
1033 }
502bbe89 1034
91744e14 1035 ev->exclusion = 1;
502bbe89 1036 warn_on_truncated_exclusion_names(exclusion_list,
9f449915 1037 &warn);
7ed70bc9 1038 }
025faf73 1039 if (!opt_filter) {
7ed70bc9 1040 ret = lttng_enable_event_with_exclusions(handle,
91744e14 1041 ev, channel_name,
7ed70bc9 1042 NULL,
9f449915
PP
1043 exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0,
1044 exclusion_list);
025faf73
DG
1045 if (ret < 0) {
1046 switch (-ret) {
1047 case LTTNG_ERR_KERN_EVENT_EXIST:
1048 WARN("Kernel events already enabled (channel %s, session %s)",
85076754 1049 print_channel_name(channel_name), session_name);
89476427 1050 warn = 1;
025faf73 1051 break;
45d5d421
CB
1052 case LTTNG_ERR_TRACE_ALREADY_STARTED:
1053 {
1054 const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
1055 ERR("Events: %s (channel %s, session %s)",
1056 msg,
1057 print_channel_name(channel_name),
1058 session_name);
1059 error = 1;
1060 break;
1061 }
025faf73
DG
1062 default:
1063 ERR("Events: %s (channel %s, session %s)",
85076754
MD
1064 lttng_strerror(ret),
1065 ret == -LTTNG_ERR_NEED_CHANNEL_NAME
1066 ? print_raw_channel_name(channel_name)
1067 : print_channel_name(channel_name),
1068 session_name);
89476427 1069 error = 1;
025faf73
DG
1070 break;
1071 }
1072 goto end;
42224349 1073 }
8c9ae521 1074
025faf73
DG
1075 switch (opt_event_type) {
1076 case LTTNG_EVENT_TRACEPOINT:
67b58630 1077 if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) {
9f449915 1078 char *exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1079
1080 if (!exclusion_string) {
1081 PERROR("Cannot allocate exclusion_string");
1082 error = 1;
1083 goto end;
1084 }
9c48cab3 1085 MSG("All %s tracepoints%s are enabled in channel %s for loglevel %s",
b9dfb167 1086 get_domain_str(dom.type),
9c48cab3 1087 exclusion_string,
85076754 1088 print_channel_name(channel_name),
025faf73 1089 opt_loglevel);
9c48cab3 1090 free(exclusion_string);
025faf73 1091 } else {
9f449915 1092 char *exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1093
1094 if (!exclusion_string) {
1095 PERROR("Cannot allocate exclusion_string");
1096 error = 1;
1097 goto end;
1098 }
9c48cab3 1099 MSG("All %s tracepoints%s are enabled in channel %s",
b9dfb167 1100 get_domain_str(dom.type),
9c48cab3 1101 exclusion_string,
85076754 1102 print_channel_name(channel_name));
9c48cab3 1103 free(exclusion_string);
025faf73
DG
1104 }
1105 break;
1106 case LTTNG_EVENT_SYSCALL:
1107 if (opt_kernel) {
6e911cad
MD
1108 MSG("All %s system calls are enabled in channel %s",
1109 get_domain_str(dom.type),
85076754 1110 print_channel_name(channel_name));
025faf73
DG
1111 }
1112 break;
1113 case LTTNG_EVENT_ALL:
67b58630 1114 if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) {
9f449915 1115 char *exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1116
1117 if (!exclusion_string) {
1118 PERROR("Cannot allocate exclusion_string");
1119 error = 1;
1120 goto end;
1121 }
9c48cab3 1122 MSG("All %s events%s are enabled in channel %s for loglevel %s",
b9dfb167 1123 get_domain_str(dom.type),
9c48cab3 1124 exclusion_string,
85076754 1125 print_channel_name(channel_name),
025faf73 1126 opt_loglevel);
9c48cab3 1127 free(exclusion_string);
025faf73 1128 } else {
9f449915 1129 char *exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1130
1131 if (!exclusion_string) {
1132 PERROR("Cannot allocate exclusion_string");
1133 error = 1;
1134 goto end;
1135 }
9c48cab3 1136 MSG("All %s events%s are enabled in channel %s",
b9dfb167 1137 get_domain_str(dom.type),
9c48cab3 1138 exclusion_string,
85076754 1139 print_channel_name(channel_name));
9c48cab3 1140 free(exclusion_string);
025faf73
DG
1141 }
1142 break;
1143 default:
1144 /*
1145 * We should not be here since lttng_enable_event should have
1146 * failed on the event type.
1147 */
1148 goto error;
57064ada 1149 }
f3ed775e 1150 }
89476427 1151
025faf73 1152 if (opt_filter) {
91744e14 1153 command_ret = lttng_enable_event_with_exclusions(handle, ev, channel_name,
9f449915
PP
1154 opt_filter,
1155 exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0,
1156 exclusion_list);
89476427
JRJ
1157 if (command_ret < 0) {
1158 switch (-command_ret) {
16363652 1159 case LTTNG_ERR_FILTER_EXIST:
85076754 1160 WARN("Filter on all events is already enabled"
16363652 1161 " (channel %s, session %s)",
85076754 1162 print_channel_name(channel_name), session_name);
89476427 1163 warn = 1;
16363652 1164 break;
45d5d421
CB
1165 case LTTNG_ERR_TRACE_ALREADY_STARTED:
1166 {
1167 const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
1168 ERR("All events: %s (channel %s, session %s, filter \'%s\')",
1169 msg,
1170 print_channel_name(channel_name),
1171 session_name, opt_filter);
1172 error = 1;
1173 break;
1174 }
16363652 1175 default:
85076754 1176 ERR("All events: %s (channel %s, session %s, filter \'%s\')",
da3d7d0e
JRJ
1177 lttng_strerror(command_ret),
1178 command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
85076754
MD
1179 ? print_raw_channel_name(channel_name)
1180 : print_channel_name(channel_name),
1181 session_name, opt_filter);
89476427 1182 error = 1;
16363652
DG
1183 break;
1184 }
89476427 1185 error_holder = command_ret;
16363652 1186 } else {
91744e14 1187 ev->filter = 1;
16363652
DG
1188 MSG("Filter '%s' successfully set", opt_filter);
1189 }
1190 }
89476427
JRJ
1191
1192 if (lttng_opt_mi) {
1193 /* The wildcard * is used for kernel and ust domain to
1194 * represent ALL. We copy * in event name to force the wildcard use
1195 * for kernel domain
1196 *
1197 * Note: this is strictly for semantic and printing while in
1198 * machine interface mode.
1199 */
91744e14 1200 strcpy(ev->name, "*");
89476427
JRJ
1201
1202 /* If we reach here the events are enabled */
1203 if (!error && !warn) {
91744e14 1204 ev->enabled = 1;
89476427 1205 } else {
91744e14 1206 ev->enabled = 0;
89476427
JRJ
1207 success = 0;
1208 }
91744e14 1209 ret = mi_lttng_event(writer, ev, 1, handle->domain.type);
89476427
JRJ
1210 if (ret) {
1211 ret = CMD_ERROR;
1212 goto error;
1213 }
1214
1215 /* print exclusion */
9f449915 1216 ret = mi_print_exclusion(exclusion_list);
89476427
JRJ
1217 if (ret) {
1218 ret = CMD_ERROR;
1219 goto error;
1220 }
1221
1222 /* Success ? */
1223 ret = mi_lttng_writer_write_element_bool(writer,
1224 mi_lttng_element_command_success, success);
1225 if (ret) {
1226 ret = CMD_ERROR;
1227 goto error;
1228 }
1229
1230 /* Close event element */
1231 ret = mi_lttng_writer_close_element(writer);
1232 if (ret) {
1233 ret = CMD_ERROR;
1234 goto error;
1235 }
1236 }
1237
8c9ae521 1238 goto end;
f3ed775e
DG
1239 }
1240
1241 /* Strip event list */
1242 event_name = strtok(opt_event_list, ",");
1243 while (event_name != NULL) {
6181537c 1244 /* Copy name and type of the event */
91744e14
FD
1245 strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
1246 ev->name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
1247 ev->type = opt_event_type;
6181537c 1248
f3ed775e
DG
1249 /* Kernel tracer action */
1250 if (opt_kernel) {
1251 DBG("Enabling kernel event %s for channel %s",
85076754
MD
1252 event_name,
1253 print_channel_name(channel_name));
f3ed775e
DG
1254
1255 switch (opt_event_type) {
29c62722
MD
1256 case LTTNG_EVENT_ALL: /* Enable tracepoints and syscalls */
1257 /* If event name differs from *, select tracepoint. */
91744e14
FD
1258 if (strcmp(ev->name, "*")) {
1259 ev->type = LTTNG_EVENT_TRACEPOINT;
29c62722
MD
1260 }
1261 break;
e6ddca71 1262 case LTTNG_EVENT_TRACEPOINT:
f3ed775e 1263 break;
7d29a247 1264 case LTTNG_EVENT_PROBE:
91744e14 1265 ret = parse_probe_opts(ev, opt_probe);
49d4e302 1266 if (ret) {
cf0e5467 1267 ERR("Unable to parse probe options");
91744e14 1268 ret = CMD_ERROR;
0d63dd19
DG
1269 goto error;
1270 }
f3ed775e 1271 break;
dcabc190
FD
1272 case LTTNG_EVENT_USERSPACE_PROBE:
1273 ret = parse_userspace_probe_opts(ev, opt_userspace_probe);
1274 if (ret) {
1275 ERR("Unable to parse userspace probe options");
1276 ret = CMD_ERROR;
1277 goto error;
1278 }
1279 break;
f3ed775e 1280 case LTTNG_EVENT_FUNCTION:
91744e14 1281 ret = parse_probe_opts(ev, opt_function);
49d4e302 1282 if (ret) {
8f0d098b 1283 ERR("Unable to parse function probe options");
91744e14 1284 ret = CMD_ERROR;
8f0d098b
MD
1285 goto error;
1286 }
1287 break;
a54bd42d 1288 case LTTNG_EVENT_SYSCALL:
91744e14 1289 ev->type = LTTNG_EVENT_SYSCALL;
c6aa2d41 1290 break;
f3ed775e 1291 default:
1ab1ea0b 1292 ret = CMD_UNDEFINED;
f3ed775e
DG
1293 goto error;
1294 }
0cda4f28 1295
0cda4f28 1296 /* kernel loglevels not implemented */
91744e14 1297 ev->loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
f3ed775e 1298 } else if (opt_userspace) { /* User-space tracer action */
300b8fd5 1299 DBG("Enabling UST event %s for channel %s, loglevel %s", event_name,
85076754 1300 print_channel_name(channel_name), opt_loglevel ? : "<all>");
2bdd86d4
MD
1301
1302 switch (opt_event_type) {
1303 case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
2bdd86d4
MD
1304 /* Fall-through */
1305 case LTTNG_EVENT_TRACEPOINT:
e4baff1e 1306 /* Copy name and type of the event */
91744e14
FD
1307 ev->type = LTTNG_EVENT_TRACEPOINT;
1308 strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
1309 ev->name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
2bdd86d4
MD
1310 break;
1311 case LTTNG_EVENT_PROBE:
1312 case LTTNG_EVENT_FUNCTION:
2bdd86d4 1313 case LTTNG_EVENT_SYSCALL:
dcabc190 1314 case LTTNG_EVENT_USERSPACE_PROBE:
2bdd86d4 1315 default:
cc62c0c0 1316 ERR("Event type not available for user-space tracing");
4ce78777 1317 ret = CMD_UNSUPPORTED;
2bdd86d4
MD
1318 goto error;
1319 }
0cda4f28 1320
7ed70bc9 1321 if (opt_exclude) {
91744e14 1322 ev->exclusion = 1;
d5dd17fd
JI
1323 if (opt_event_type != LTTNG_EVENT_ALL && opt_event_type != LTTNG_EVENT_TRACEPOINT) {
1324 ERR("Exclusion option can only be used with tracepoint events");
1325 ret = CMD_ERROR;
1326 goto error;
1327 }
7ed70bc9 1328 /* Free previously allocated items */
9f449915
PP
1329 strutils_free_null_terminated_array_of_strings(
1330 exclusion_list);
1331 exclusion_list = NULL;
1332 ret = create_exclusion_list_and_validate(
1333 event_name, opt_exclude,
1334 &exclusion_list);
1335 if (ret) {
1336 ret = CMD_ERROR;
7ed70bc9
JI
1337 goto error;
1338 }
502bbe89
PP
1339
1340 warn_on_truncated_exclusion_names(
9f449915 1341 exclusion_list, &warn);
7ed70bc9
JI
1342 }
1343
91744e14 1344 ev->loglevel_type = opt_loglevel_type;
ed7f4083 1345 if (opt_loglevel) {
91744e14
FD
1346 ev->loglevel = loglevel_str_to_value(opt_loglevel);
1347 if (ev->loglevel == -1) {
8005f29a 1348 ERR("Unknown loglevel %s", opt_loglevel);
2f70b271 1349 ret = -LTTNG_ERR_INVALID;
8005f29a
MD
1350 goto error;
1351 }
22e25b71 1352 } else {
91744e14 1353 ev->loglevel = -1;
ed7f4083 1354 }
0e115563 1355 } else if (opt_jul || opt_log4j || opt_python) {
b9dfb167
DG
1356 if (opt_event_type != LTTNG_EVENT_ALL &&
1357 opt_event_type != LTTNG_EVENT_TRACEPOINT) {
5cdb6027 1358 ERR("Event type not supported for domain.");
b9dfb167
DG
1359 ret = CMD_UNSUPPORTED;
1360 goto error;
1361 }
b2064f54 1362
91744e14 1363 ev->loglevel_type = opt_loglevel_type;
b2064f54 1364 if (opt_loglevel) {
5cdb6027 1365 if (opt_jul) {
91744e14 1366 ev->loglevel = loglevel_jul_str_to_value(opt_loglevel);
5cdb6027 1367 } else if (opt_log4j) {
91744e14 1368 ev->loglevel = loglevel_log4j_str_to_value(opt_loglevel);
0e115563 1369 } else if (opt_python) {
91744e14 1370 ev->loglevel = loglevel_python_str_to_value(opt_loglevel);
5cdb6027 1371 }
91744e14 1372 if (ev->loglevel == -1) {
b2064f54
DG
1373 ERR("Unknown loglevel %s", opt_loglevel);
1374 ret = -LTTNG_ERR_INVALID;
1375 goto error;
1376 }
1377 } else {
5cdb6027 1378 if (opt_jul) {
91744e14 1379 ev->loglevel = LTTNG_LOGLEVEL_JUL_ALL;
5cdb6027 1380 } else if (opt_log4j) {
91744e14 1381 ev->loglevel = LTTNG_LOGLEVEL_LOG4J_ALL;
0e115563 1382 } else if (opt_python) {
91744e14 1383 ev->loglevel = LTTNG_LOGLEVEL_PYTHON_DEBUG;
5cdb6027 1384 }
b2064f54 1385 }
91744e14
FD
1386 ev->type = LTTNG_EVENT_TRACEPOINT;
1387 strncpy(ev->name, event_name, LTTNG_SYMBOL_NAME_LEN);
1388 ev->name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
f3ed775e 1389 } else {
3ecec76a 1390 assert(0);
f3ed775e
DG
1391 }
1392
025faf73 1393 if (!opt_filter) {
9c48cab3
JI
1394 char *exclusion_string;
1395
89476427 1396 command_ret = lttng_enable_event_with_exclusions(handle,
91744e14 1397 ev, channel_name,
9f449915
PP
1398 NULL,
1399 exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0,
1400 exclusion_list);
1401 exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1402 if (!exclusion_string) {
1403 PERROR("Cannot allocate exclusion_string");
1404 error = 1;
1405 goto end;
1406 }
89476427 1407 if (command_ret < 0) {
025faf73 1408 /* Turn ret to positive value to handle the positive error code */
89476427 1409 switch (-command_ret) {
025faf73 1410 case LTTNG_ERR_KERN_EVENT_EXIST:
9c48cab3 1411 WARN("Kernel event %s%s already enabled (channel %s, session %s)",
85076754 1412 event_name,
9c48cab3 1413 exclusion_string,
85076754 1414 print_channel_name(channel_name), session_name);
89476427 1415 warn = 1;
025faf73 1416 break;
45d5d421
CB
1417 case LTTNG_ERR_TRACE_ALREADY_STARTED:
1418 {
1419 const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
1420 ERR("Event %s%s: %s (channel %s, session %s)", event_name,
1421 exclusion_string,
1422 msg,
1423 print_channel_name(channel_name),
1424 session_name);
1425 error = 1;
1426 break;
1427 }
dcabc190
FD
1428 case LTTNG_ERR_SDT_PROBE_SEMAPHORE:
1429 ERR("SDT probes %s guarded by semaphores are not supported (channel %s, session %s)",
1430 event_name, print_channel_name(channel_name),
1431 session_name);
1432 error = 1;
1433 break;
025faf73 1434 default:
9c48cab3
JI
1435 ERR("Event %s%s: %s (channel %s, session %s)", event_name,
1436 exclusion_string,
da3d7d0e
JRJ
1437 lttng_strerror(command_ret),
1438 command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
85076754
MD
1439 ? print_raw_channel_name(channel_name)
1440 : print_channel_name(channel_name),
1441 session_name);
89476427 1442 error = 1;
025faf73
DG
1443 break;
1444 }
89476427 1445 error_holder = command_ret;
025faf73 1446 } else {
8274eeba
AB
1447 switch (dom.type) {
1448 case LTTNG_DOMAIN_KERNEL:
1449 case LTTNG_DOMAIN_UST:
49ceaa70 1450 MSG("%s event %s%s created in channel %s",
8274eeba
AB
1451 get_domain_str(dom.type),
1452 event_name,
1453 exclusion_string,
1454 print_channel_name(channel_name));
1455 break;
1456 case LTTNG_DOMAIN_JUL:
1457 case LTTNG_DOMAIN_LOG4J:
1458 case LTTNG_DOMAIN_PYTHON:
1459 /*
1460 * Don't print the default channel
1461 * name for agent domains.
1462 */
895707da 1463 MSG("%s event %s%s enabled",
8274eeba
AB
1464 get_domain_str(dom.type),
1465 event_name,
1466 exclusion_string);
1467 break;
1468 default:
1469 assert(0);
49ceaa70 1470 }
42224349 1471 }
9c48cab3 1472 free(exclusion_string);
6181537c 1473 }
025faf73
DG
1474
1475 if (opt_filter) {
9c48cab3
JI
1476 char *exclusion_string;
1477
89476427 1478 /* Filter present */
91744e14 1479 ev->filter = 1;
89476427 1480
91744e14 1481 command_ret = lttng_enable_event_with_exclusions(handle, ev, channel_name,
9f449915
PP
1482 opt_filter,
1483 exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0,
1484 exclusion_list);
1485 exclusion_string = print_exclusions(exclusion_list);
5ef79758
MD
1486 if (!exclusion_string) {
1487 PERROR("Cannot allocate exclusion_string");
1488 error = 1;
1489 goto end;
1490 }
89476427
JRJ
1491 if (command_ret < 0) {
1492 switch (-command_ret) {
7671f53c 1493 case LTTNG_ERR_FILTER_EXIST:
9c48cab3 1494 WARN("Filter on event %s%s is already enabled"
7671f53c 1495 " (channel %s, session %s)",
85076754 1496 event_name,
9c48cab3 1497 exclusion_string,
85076754 1498 print_channel_name(channel_name), session_name);
89476427 1499 warn = 1;
7671f53c 1500 break;
45d5d421
CB
1501 case LTTNG_ERR_TRACE_ALREADY_STARTED:
1502 {
1503 const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
91744e14 1504 ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev->name,
45d5d421
CB
1505 exclusion_string,
1506 msg,
1507 print_channel_name(channel_name),
1508 session_name, opt_filter);
1509 error = 1;
1510 break;
1511 }
7671f53c 1512 default:
91744e14 1513 ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev->name,
9c48cab3 1514 exclusion_string,
da3d7d0e
JRJ
1515 lttng_strerror(command_ret),
1516 command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
85076754
MD
1517 ? print_raw_channel_name(channel_name)
1518 : print_channel_name(channel_name),
1519 session_name, opt_filter);
89476427 1520 error = 1;
7671f53c
CB
1521 break;
1522 }
89476427
JRJ
1523 error_holder = command_ret;
1524
16363652 1525 } else {
9c48cab3
JI
1526 MSG("Event %s%s: Filter '%s' successfully set",
1527 event_name, exclusion_string,
1528 opt_filter);
53a80697 1529 }
9c48cab3 1530 free(exclusion_string);
53a80697 1531 }
6181537c 1532
89476427
JRJ
1533 if (lttng_opt_mi) {
1534 if (command_ret) {
1535 success = 0;
91744e14 1536 ev->enabled = 0;
89476427 1537 } else {
91744e14 1538 ev->enabled = 1;
89476427
JRJ
1539 }
1540
91744e14 1541 ret = mi_lttng_event(writer, ev, 1, handle->domain.type);
89476427
JRJ
1542 if (ret) {
1543 ret = CMD_ERROR;
1544 goto error;
1545 }
1546
1547 /* print exclusion */
9f449915 1548 ret = mi_print_exclusion(exclusion_list);
89476427
JRJ
1549 if (ret) {
1550 ret = CMD_ERROR;
1551 goto error;
1552 }
1553
1554 /* Success ? */
1555 ret = mi_lttng_writer_write_element_bool(writer,
1556 mi_lttng_element_command_success, success);
1557 if (ret) {
1558 ret = CMD_ERROR;
1559 goto end;
1560 }
1561
1562 /* Close event element */
1563 ret = mi_lttng_writer_close_element(writer);
1564 if (ret) {
1565 ret = CMD_ERROR;
1566 goto end;
1567 }
1568 }
1569
f3ed775e
DG
1570 /* Next event */
1571 event_name = strtok(NULL, ",");
89476427
JRJ
1572 /* Reset warn, error and success */
1573 success = 1;
f3ed775e
DG
1574 }
1575
8c9ae521 1576end:
89476427
JRJ
1577 /* Close Mi */
1578 if (lttng_opt_mi) {
1579 /* Close events element */
1580 ret = mi_lttng_writer_close_element(writer);
1581 if (ret) {
1582 ret = CMD_ERROR;
1583 goto error;
1584 }
1585 }
f3ed775e 1586error:
ae856491
DG
1587 if (warn) {
1588 ret = CMD_WARNING;
1589 }
89476427
JRJ
1590 if (error) {
1591 ret = CMD_ERROR;
1592 }
cd80958d 1593 lttng_destroy_handle(handle);
9f449915 1594 strutils_free_null_terminated_array_of_strings(exclusion_list);
7ed70bc9 1595
89476427
JRJ
1596 /* Overwrite ret with error_holder if there was an actual error with
1597 * enabling an event.
1598 */
1599 ret = error_holder ? error_holder : ret;
1600
91744e14 1601 lttng_event_destroy(ev);
f3ed775e
DG
1602 return ret;
1603}
1604
1605/*
6181537c 1606 * Add event to trace session
f3ed775e
DG
1607 */
1608int cmd_enable_events(int argc, const char **argv)
1609{
89476427 1610 int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
f3ed775e 1611 static poptContext pc;
cd80958d 1612 char *session_name = NULL;
68c7f6e5 1613 const char *leftover = NULL;
de044b7a 1614 int event_type = -1;
f3ed775e
DG
1615
1616 pc = poptGetContext(NULL, argc, argv, long_options, 0);
1617 poptReadDefaultConfig(pc, 0);
1618
1619 /* Default event type */
7a3d1328 1620 opt_event_type = LTTNG_EVENT_ALL;
f3ed775e
DG
1621
1622 while ((opt = poptGetNextOpt(pc)) != -1) {
1623 switch (opt) {
1624 case OPT_HELP:
4ba92f18 1625 SHOW_HELP();
f3ed775e 1626 goto end;
f3ed775e 1627 case OPT_TRACEPOINT:
e6ddca71 1628 opt_event_type = LTTNG_EVENT_TRACEPOINT;
f3ed775e 1629 break;
cf0e5467 1630 case OPT_PROBE:
7d29a247 1631 opt_event_type = LTTNG_EVENT_PROBE;
f3ed775e 1632 break;
dcabc190
FD
1633 case OPT_USERSPACE_PROBE:
1634 opt_event_type = LTTNG_EVENT_USERSPACE_PROBE;
1635 break;
f3ed775e
DG
1636 case OPT_FUNCTION:
1637 opt_event_type = LTTNG_EVENT_FUNCTION;
8f0d098b 1638 break;
a54bd42d
MD
1639 case OPT_SYSCALL:
1640 opt_event_type = LTTNG_EVENT_SYSCALL;
0133c199 1641 break;
eeac7d46
MD
1642 case OPT_USERSPACE:
1643 opt_userspace = 1;
eeac7d46 1644 break;
0cda4f28 1645 case OPT_LOGLEVEL:
8005f29a 1646 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
0cda4f28
MD
1647 opt_loglevel = poptGetOptArg(pc);
1648 break;
1649 case OPT_LOGLEVEL_ONLY:
8005f29a 1650 opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
0cda4f28 1651 opt_loglevel = poptGetOptArg(pc);
13dce3b7 1652 break;
679b4943
SM
1653 case OPT_LIST_OPTIONS:
1654 list_cmd_options(stdout, long_options);
679b4943 1655 goto end;
53a80697
MD
1656 case OPT_FILTER:
1657 break;
fac3366c
JI
1658 case OPT_EXCLUDE:
1659 break;
f3ed775e 1660 default:
f3ed775e
DG
1661 ret = CMD_UNDEFINED;
1662 goto end;
1663 }
de044b7a
DG
1664
1665 /* Validate event type. Multiple event type are not supported. */
1666 if (event_type == -1) {
1667 event_type = opt_event_type;
1668 } else {
1669 if (event_type != opt_event_type) {
1670 ERR("Multiple event type not supported.");
1671 ret = CMD_ERROR;
1672 goto end;
1673 }
1674 }
f3ed775e
DG
1675 }
1676
3ecec76a
PP
1677 ret = print_missing_or_multiple_domains(
1678 opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python);
1679 if (ret) {
1680 ret = CMD_ERROR;
1681 goto end;
1682 }
1683
89476427
JRJ
1684 /* Mi check */
1685 if (lttng_opt_mi) {
1686 writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
1687 if (!writer) {
1688 ret = -LTTNG_ERR_NOMEM;
1689 goto end;
1690 }
1691
1692 /* Open command element */
1693 ret = mi_lttng_writer_command_open(writer,
1694 mi_lttng_element_command_enable_event);
1695 if (ret) {
1696 ret = CMD_ERROR;
1697 goto end;
1698 }
1699
1700 /* Open output element */
1701 ret = mi_lttng_writer_open_element(writer,
1702 mi_lttng_element_command_output);
1703 if (ret) {
1704 ret = CMD_ERROR;
1705 goto end;
1706 }
1707 }
1708
f3ed775e
DG
1709 opt_event_list = (char*) poptGetArg(pc);
1710 if (opt_event_list == NULL && opt_enable_all == 0) {
1711 ERR("Missing event name(s).\n");
ca1c3607 1712 ret = CMD_ERROR;
f3ed775e
DG
1713 goto end;
1714 }
1715
68c7f6e5
JD
1716 leftover = poptGetArg(pc);
1717 if (leftover) {
1718 ERR("Unknown argument: %s", leftover);
1719 ret = CMD_ERROR;
1720 goto end;
1721 }
1722
cd80958d
DG
1723 if (!opt_session_name) {
1724 session_name = get_session_name();
1725 if (session_name == NULL) {
89476427
JRJ
1726 command_ret = CMD_ERROR;
1727 success = 0;
1728 goto mi_closing;
cd80958d
DG
1729 }
1730 } else {
1731 session_name = opt_session_name;
1732 }
1733
89476427
JRJ
1734 command_ret = enable_events(session_name);
1735 if (command_ret) {
1736 success = 0;
1737 goto mi_closing;
1738 }
1739
1740mi_closing:
1741 /* Mi closing */
1742 if (lttng_opt_mi) {
1743 /* Close output element */
1744 ret = mi_lttng_writer_close_element(writer);
1745 if (ret) {
1746 ret = CMD_ERROR;
1747 goto end;
1748 }
1749
1750 ret = mi_lttng_writer_write_element_bool(writer,
1751 mi_lttng_element_command_success, success);
1752 if (ret) {
1753 ret = CMD_ERROR;
1754 goto end;
1755 }
1756
1757 /* Command element close */
1758 ret = mi_lttng_writer_command_close(writer);
1759 if (ret) {
1760 ret = CMD_ERROR;
1761 goto end;
1762 }
1763 }
f3ed775e
DG
1764
1765end:
89476427
JRJ
1766 /* Mi clean-up */
1767 if (writer && mi_lttng_writer_destroy(writer)) {
1768 /* Preserve original error code */
1769 ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
1770 }
1771
cd80958d
DG
1772 if (opt_session_name == NULL) {
1773 free(session_name);
1774 }
1775
89476427
JRJ
1776 /* Overwrite ret if an error occurred in enable_events */
1777 ret = command_ret ? command_ret : ret;
1778
ca1c3607 1779 poptFreeContext(pc);
f3ed775e
DG
1780 return ret;
1781}
9f449915 1782
This page took 0.16963 seconds and 5 git commands to generate.