Refactoring: introduce lttng_tracker_ids data structure
[lttng-tools.git] / src / bin / lttng / commands / list.c
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #define _LGPL_SOURCE
19 #include <inttypes.h>
20 #include <popt.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <assert.h>
25
26 #include <common/mi-lttng.h>
27 #include <common/time.h>
28 #include <lttng/constant.h>
29 #include <lttng/tracker.h>
30
31 #include "../command.h"
32
33 static int opt_userspace;
34 static int opt_kernel;
35 static int opt_jul;
36 static int opt_log4j;
37 static int opt_python;
38 static char *opt_channel;
39 static int opt_domain;
40 static int opt_fields;
41 static int opt_syscall;
42
43 const char *indent4 = " ";
44 const char *indent6 = " ";
45 const char *indent8 = " ";
46
47 #ifdef LTTNG_EMBED_HELP
48 static const char help_msg[] =
49 #include <lttng-list.1.h>
50 ;
51 #endif
52
53 enum {
54 OPT_HELP = 1,
55 OPT_USERSPACE,
56 OPT_LIST_OPTIONS,
57 };
58
59 static struct lttng_handle *handle;
60 static struct mi_writer *writer;
61
62 /* Only set when listing a single session. */
63 static struct lttng_session listed_session;
64
65 static struct poptOption long_options[] = {
66 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
67 {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
68 {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
69 {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
70 {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0},
71 {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
72 {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
73 {"channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0},
74 {"domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
75 {"fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0},
76 {"syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, 0, 0},
77 {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
78 {0, 0, 0, 0, 0, 0, 0}
79 };
80
81 /*
82 * Get command line from /proc for a specific pid.
83 *
84 * On success, return an allocated string pointer to the proc cmdline.
85 * On error, return NULL.
86 */
87 static char *get_cmdline_by_pid(pid_t pid)
88 {
89 int ret;
90 FILE *fp = NULL;
91 char *cmdline = NULL;
92 /* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */
93 char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1];
94
95 snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
96 fp = fopen(path, "r");
97 if (fp == NULL) {
98 goto end;
99 }
100
101 /* Caller must free() *cmdline */
102 cmdline = zmalloc(PATH_MAX);
103 if (!cmdline) {
104 PERROR("malloc cmdline");
105 goto end;
106 }
107 ret = fread(cmdline, 1, PATH_MAX, fp);
108 if (ret < 0) {
109 PERROR("fread proc list");
110 }
111
112 end:
113 if (fp) {
114 fclose(fp);
115 }
116 return cmdline;
117 }
118
119 static
120 const char *active_string(int value)
121 {
122 switch (value) {
123 case 0: return "inactive";
124 case 1: return "active";
125 case -1: return "";
126 default: return NULL;
127 }
128 }
129
130 static const char *snapshot_string(int value)
131 {
132 switch (value) {
133 case 1:
134 return " snapshot";
135 default:
136 return "";
137 }
138 }
139
140 static
141 const char *enabled_string(int value)
142 {
143 switch (value) {
144 case 0: return " [disabled]";
145 case 1: return " [enabled]";
146 case -1: return "";
147 default: return NULL;
148 }
149 }
150
151 static
152 const char *safe_string(const char *str)
153 {
154 return str ? str : "";
155 }
156
157 static const char *logleveltype_string(enum lttng_loglevel_type value)
158 {
159 switch (value) {
160 case LTTNG_EVENT_LOGLEVEL_ALL:
161 return ":";
162 case LTTNG_EVENT_LOGLEVEL_RANGE:
163 return " <=";
164 case LTTNG_EVENT_LOGLEVEL_SINGLE:
165 return " ==";
166 default:
167 return " <<TYPE UNKN>>";
168 }
169 }
170
171 static const char *bitness_event(enum lttng_event_flag flags)
172 {
173 if (flags & LTTNG_EVENT_FLAG_SYSCALL_32) {
174 if (flags & LTTNG_EVENT_FLAG_SYSCALL_64) {
175 return " [32/64-bit]";
176 } else {
177 return " [32-bit]";
178 }
179 } else if (flags & LTTNG_EVENT_FLAG_SYSCALL_64) {
180 return " [64-bit]";
181 } else {
182 return "";
183 }
184 }
185
186 /*
187 * Get exclusion names message for a single event.
188 *
189 * Returned pointer must be freed by caller. Returns NULL on error.
190 */
191 static char *get_exclusion_names_msg(struct lttng_event *event)
192 {
193 int ret;
194 int exclusion_count;
195 char *exclusion_msg = NULL;
196 char *at;
197 size_t i;
198 const char * const exclusion_fmt = " [exclusions: ";
199 const size_t exclusion_fmt_len = strlen(exclusion_fmt);
200
201 exclusion_count = lttng_event_get_exclusion_name_count(event);
202 if (exclusion_count < 0) {
203 goto end;
204 } else if (exclusion_count == 0) {
205 /*
206 * No exclusions: return copy of empty string so that
207 * it can be freed by caller.
208 */
209 exclusion_msg = strdup("");
210 goto end;
211 }
212
213 /*
214 * exclusion_msg's size is bounded by the exclusion_fmt string,
215 * a comma per entry, the entry count (fixed-size), a closing
216 * bracket, and a trailing \0.
217 */
218 exclusion_msg = malloc(exclusion_count +
219 exclusion_count * LTTNG_SYMBOL_NAME_LEN +
220 exclusion_fmt_len + 1);
221 if (!exclusion_msg) {
222 goto end;
223 }
224
225 at = strcpy(exclusion_msg, exclusion_fmt) + exclusion_fmt_len;
226 for (i = 0; i < exclusion_count; ++i) {
227 const char *name;
228
229 /* Append comma between exclusion names */
230 if (i > 0) {
231 *at = ',';
232 at++;
233 }
234
235 ret = lttng_event_get_exclusion_name(event, i, &name);
236 if (ret) {
237 /* Prints '?' on local error; should never happen */
238 *at = '?';
239 at++;
240 continue;
241 }
242
243 /* Append exclusion name */
244 at += sprintf(at, "%s", name);
245 }
246
247 /* This also puts a final '\0' at the end of exclusion_msg */
248 strcpy(at, "]");
249
250 end:
251 return exclusion_msg;
252 }
253
254 static void print_userspace_probe_location(struct lttng_event *event)
255 {
256 const struct lttng_userspace_probe_location *location;
257 const struct lttng_userspace_probe_location_lookup_method *lookup_method;
258 enum lttng_userspace_probe_location_lookup_method_type lookup_type;
259
260 location = lttng_event_get_userspace_probe_location(event);
261 if (!location) {
262 MSG("Event has no userspace probe location");
263 return;
264 }
265
266 lookup_method = lttng_userspace_probe_location_get_lookup_method(location);
267 if (!lookup_method) {
268 MSG("Event has no userspace probe location lookup method");
269 return;
270 }
271
272 MSG("%s%s (type: userspace-probe)%s", indent6, event->name, enabled_string(event->enabled));
273
274 lookup_type = lttng_userspace_probe_location_lookup_method_get_type(lookup_method);
275
276 switch (lttng_userspace_probe_location_get_type(location)) {
277 case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN:
278 MSG("%sType: Unknown", indent8);
279 break;
280 case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
281 {
282 const char *function_name;
283 const char *binary_path;
284
285 MSG("%sType: Function", indent8);
286 function_name = lttng_userspace_probe_location_function_get_function_name(location);
287 binary_path = realpath(lttng_userspace_probe_location_function_get_binary_path(location), NULL);
288
289 MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
290 MSG("%sFunction: %s()", indent8, function_name ? function_name : "NULL");
291 switch (lookup_type) {
292 case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
293 MSG("%sLookup method: ELF", indent8);
294 break;
295 case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
296 MSG("%sLookup method: default", indent8);
297 break;
298 default:
299 MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
300 break;
301 }
302 break;
303 }
304 case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
305 {
306 const char *probe_name, *provider_name;
307 const char *binary_path;
308
309 MSG("%sType: Tracepoint", indent8);
310 probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
311 provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
312 binary_path = realpath(lttng_userspace_probe_location_tracepoint_get_binary_path(location), NULL);
313 MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
314 MSG("%sTracepoint: %s:%s", indent8, provider_name ? provider_name : "NULL", probe_name ? probe_name : "NULL");
315 switch (lookup_type) {
316 case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
317 MSG("%sLookup method: SDT", indent8);
318 break;
319 default:
320 MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
321 break;
322 }
323 break;
324 }
325 default:
326 ERR("Invalid probe type encountered");
327 }
328 }
329
330 /*
331 * Pretty print single event.
332 */
333 static void print_events(struct lttng_event *event)
334 {
335 int ret;
336 const char *filter_str;
337 char *filter_msg = NULL;
338 char *exclusion_msg = NULL;
339
340 ret = lttng_event_get_filter_expression(event, &filter_str);
341
342 if (ret) {
343 filter_msg = strdup(" [failed to retrieve filter]");
344 } else if (filter_str) {
345 const char * const filter_fmt = " [filter: '%s']";
346
347 filter_msg = malloc(strlen(filter_str) +
348 strlen(filter_fmt) + 1);
349 if (filter_msg) {
350 sprintf(filter_msg, filter_fmt,
351 filter_str);
352 }
353 }
354
355 exclusion_msg = get_exclusion_names_msg(event);
356 if (!exclusion_msg) {
357 exclusion_msg = strdup(" [failed to retrieve exclusions]");
358 }
359
360 switch (event->type) {
361 case LTTNG_EVENT_TRACEPOINT:
362 {
363 if (event->loglevel != -1) {
364 MSG("%s%s (loglevel%s %s (%d)) (type: tracepoint)%s%s%s",
365 indent6,
366 event->name,
367 logleveltype_string(event->loglevel_type),
368 mi_lttng_loglevel_string(event->loglevel, handle->domain.type),
369 event->loglevel,
370 enabled_string(event->enabled),
371 safe_string(exclusion_msg),
372 safe_string(filter_msg));
373 } else {
374 MSG("%s%s (type: tracepoint)%s%s%s",
375 indent6,
376 event->name,
377 enabled_string(event->enabled),
378 safe_string(exclusion_msg),
379 safe_string(filter_msg));
380 }
381 break;
382 }
383 case LTTNG_EVENT_FUNCTION:
384 MSG("%s%s (type: function)%s%s", indent6,
385 event->name, enabled_string(event->enabled),
386 safe_string(filter_msg));
387 if (event->attr.probe.addr != 0) {
388 MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
389 } else {
390 MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
391 MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
392 }
393 break;
394 case LTTNG_EVENT_PROBE:
395 MSG("%s%s (type: probe)%s%s", indent6,
396 event->name, enabled_string(event->enabled),
397 safe_string(filter_msg));
398 if (event->attr.probe.addr != 0) {
399 MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
400 } else {
401 MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
402 MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
403 }
404 break;
405 case LTTNG_EVENT_USERSPACE_PROBE:
406 print_userspace_probe_location(event);
407 break;
408 case LTTNG_EVENT_FUNCTION_ENTRY:
409 MSG("%s%s (type: function)%s%s", indent6,
410 event->name, enabled_string(event->enabled),
411 safe_string(filter_msg));
412 MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
413 break;
414 case LTTNG_EVENT_SYSCALL:
415 MSG("%s%s%s%s%s%s", indent6, event->name,
416 (opt_syscall ? "" : " (type:syscall)"),
417 enabled_string(event->enabled),
418 bitness_event(event->flags),
419 safe_string(filter_msg));
420 break;
421 case LTTNG_EVENT_NOOP:
422 MSG("%s (type: noop)%s%s", indent6,
423 enabled_string(event->enabled),
424 safe_string(filter_msg));
425 break;
426 case LTTNG_EVENT_ALL:
427 /* Fall-through. */
428 default:
429 /* We should never have "all" events in list. */
430 assert(0);
431 break;
432 }
433
434 free(filter_msg);
435 free(exclusion_msg);
436 }
437
438 static const char *field_type(struct lttng_event_field *field)
439 {
440 switch(field->type) {
441 case LTTNG_EVENT_FIELD_INTEGER:
442 return "integer";
443 case LTTNG_EVENT_FIELD_ENUM:
444 return "enum";
445 case LTTNG_EVENT_FIELD_FLOAT:
446 return "float";
447 case LTTNG_EVENT_FIELD_STRING:
448 return "string";
449 case LTTNG_EVENT_FIELD_OTHER:
450 default: /* fall-through */
451 return "unknown";
452 }
453 }
454
455 /*
456 * Pretty print single event fields.
457 */
458 static void print_event_field(struct lttng_event_field *field)
459 {
460 if (!field->field_name[0]) {
461 return;
462 }
463 MSG("%sfield: %s (%s)%s", indent8, field->field_name,
464 field_type(field), field->nowrite ? " [no write]" : "");
465 }
466
467 /*
468 * Machine interface
469 * Jul and ust event listing
470 */
471 static int mi_list_agent_ust_events(struct lttng_event *events, int count,
472 struct lttng_domain *domain)
473 {
474 int ret, i;
475 pid_t cur_pid = 0;
476 char *cmdline = NULL;
477 int pid_element_open = 0;
478
479 /* Open domains element */
480 ret = mi_lttng_domains_open(writer);
481 if (ret) {
482 goto end;
483 }
484
485 /* Write domain */
486 ret = mi_lttng_domain(writer, domain, 1);
487 if (ret) {
488 goto end;
489 }
490
491 /* Open pids element element */
492 ret = mi_lttng_pids_open(writer);
493 if (ret) {
494 goto end;
495 }
496
497 for (i = 0; i < count; i++) {
498 if (cur_pid != events[i].pid) {
499 if (pid_element_open) {
500 /* Close the previous events and pid element */
501 ret = mi_lttng_close_multi_element(writer, 2);
502 if (ret) {
503 goto end;
504 }
505 pid_element_open = 0;
506 }
507
508 cur_pid = events[i].pid;
509 cmdline = get_cmdline_by_pid(cur_pid);
510 if (!cmdline) {
511 ret = CMD_ERROR;
512 goto end;
513 }
514
515 if (!pid_element_open) {
516 /* Open and write a pid element */
517 ret = mi_lttng_pid(writer, cur_pid, cmdline, 1);
518 if (ret) {
519 goto error;
520 }
521
522 /* Open events element */
523 ret = mi_lttng_events_open(writer);
524 if (ret) {
525 goto error;
526 }
527
528 pid_element_open = 1;
529 }
530 free(cmdline);
531 }
532
533 /* Write an event */
534 ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
535 if (ret) {
536 goto end;
537 }
538 }
539
540 /* Close pids */
541 ret = mi_lttng_writer_close_element(writer);
542 if (ret) {
543 goto end;
544 }
545
546 /* Close domain, domains */
547 ret = mi_lttng_close_multi_element(writer, 2);
548 end:
549 return ret;
550 error:
551 free(cmdline);
552 return ret;
553 }
554
555 static int list_agent_events(void)
556 {
557 int i, size, ret = CMD_SUCCESS;
558 struct lttng_domain domain;
559 struct lttng_handle *handle = NULL;
560 struct lttng_event *event_list = NULL;
561 pid_t cur_pid = 0;
562 char *cmdline = NULL;
563 const char *agent_domain_str;
564
565 memset(&domain, 0, sizeof(domain));
566 if (opt_jul) {
567 domain.type = LTTNG_DOMAIN_JUL;
568 } else if (opt_log4j) {
569 domain.type = LTTNG_DOMAIN_LOG4J;
570 } else if (opt_python) {
571 domain.type = LTTNG_DOMAIN_PYTHON;
572 } else {
573 ERR("Invalid agent domain selected.");
574 ret = CMD_ERROR;
575 goto error;
576 }
577
578 agent_domain_str = get_domain_str(domain.type);
579
580 DBG("Getting %s tracing events", agent_domain_str);
581
582 handle = lttng_create_handle(NULL, &domain);
583 if (handle == NULL) {
584 ret = CMD_ERROR;
585 goto end;
586 }
587
588 size = lttng_list_tracepoints(handle, &event_list);
589 if (size < 0) {
590 ERR("Unable to list %s events: %s", agent_domain_str,
591 lttng_strerror(size));
592 ret = CMD_ERROR;
593 goto end;
594 }
595
596 if (lttng_opt_mi) {
597 /* Mi print */
598 ret = mi_list_agent_ust_events(event_list, size, &domain);
599 if (ret) {
600 ret = CMD_ERROR;
601 goto error;
602 }
603 } else {
604 /* Pretty print */
605 MSG("%s events (Logger name):\n-------------------------",
606 agent_domain_str);
607
608 if (size == 0) {
609 MSG("None");
610 }
611
612 for (i = 0; i < size; i++) {
613 if (cur_pid != event_list[i].pid) {
614 cur_pid = event_list[i].pid;
615 cmdline = get_cmdline_by_pid(cur_pid);
616 if (cmdline == NULL) {
617 ret = CMD_ERROR;
618 goto error;
619 }
620 MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
621 free(cmdline);
622 }
623 MSG("%s- %s", indent6, event_list[i].name);
624 }
625
626 MSG("");
627 }
628
629 error:
630 free(event_list);
631 end:
632 lttng_destroy_handle(handle);
633 return ret;
634 }
635
636 /*
637 * Ask session daemon for all user space tracepoints available.
638 */
639 static int list_ust_events(void)
640 {
641 int i, size, ret = CMD_SUCCESS;
642 struct lttng_domain domain;
643 struct lttng_handle *handle;
644 struct lttng_event *event_list = NULL;
645 pid_t cur_pid = 0;
646 char *cmdline = NULL;
647
648 memset(&domain, 0, sizeof(domain));
649
650 DBG("Getting UST tracing events");
651
652 domain.type = LTTNG_DOMAIN_UST;
653
654 handle = lttng_create_handle(NULL, &domain);
655 if (handle == NULL) {
656 ret = CMD_ERROR;
657 goto end;
658 }
659
660 size = lttng_list_tracepoints(handle, &event_list);
661 if (size < 0) {
662 ERR("Unable to list UST events: %s", lttng_strerror(size));
663 ret = CMD_ERROR;
664 goto error;
665 }
666
667 if (lttng_opt_mi) {
668 /* Mi print */
669 ret = mi_list_agent_ust_events(event_list, size, &domain);
670 } else {
671 /* Pretty print */
672 MSG("UST events:\n-------------");
673
674 if (size == 0) {
675 MSG("None");
676 }
677
678 for (i = 0; i < size; i++) {
679 if (cur_pid != event_list[i].pid) {
680 cur_pid = event_list[i].pid;
681 cmdline = get_cmdline_by_pid(cur_pid);
682 if (cmdline == NULL) {
683 ret = CMD_ERROR;
684 goto error;
685 }
686 MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
687 free(cmdline);
688 }
689 print_events(&event_list[i]);
690 }
691
692 MSG("");
693 }
694
695 error:
696 free(event_list);
697 end:
698 lttng_destroy_handle(handle);
699 return ret;
700 }
701
702 /*
703 * Machine interface
704 * List all ust event with their fields
705 */
706 static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
707 struct lttng_domain *domain)
708 {
709 int ret, i;
710 pid_t cur_pid = 0;
711 char *cmdline = NULL;
712 int pid_element_open = 0;
713 int event_element_open = 0;
714 struct lttng_event cur_event;
715
716 memset(&cur_event, 0, sizeof(cur_event));
717
718 /* Open domains element */
719 ret = mi_lttng_domains_open(writer);
720 if (ret) {
721 goto end;
722 }
723
724 /* Write domain */
725 ret = mi_lttng_domain(writer, domain, 1);
726 if (ret) {
727 goto end;
728 }
729
730 /* Open pids element */
731 ret = mi_lttng_pids_open(writer);
732 if (ret) {
733 goto end;
734 }
735
736 for (i = 0; i < count; i++) {
737 if (cur_pid != fields[i].event.pid) {
738 if (pid_element_open) {
739 if (event_element_open) {
740 /* Close the previous field element and event. */
741 ret = mi_lttng_close_multi_element(writer, 2);
742 if (ret) {
743 goto end;
744 }
745 event_element_open = 0;
746 }
747 /* Close the previous events, pid element */
748 ret = mi_lttng_close_multi_element(writer, 2);
749 if (ret) {
750 goto end;
751 }
752 pid_element_open = 0;
753 }
754
755 cur_pid = fields[i].event.pid;
756 cmdline = get_cmdline_by_pid(cur_pid);
757 if (!pid_element_open) {
758 /* Open and write a pid element */
759 ret = mi_lttng_pid(writer, cur_pid, cmdline, 1);
760 if (ret) {
761 goto error;
762 }
763
764 /* Open events element */
765 ret = mi_lttng_events_open(writer);
766 if (ret) {
767 goto error;
768 }
769 pid_element_open = 1;
770 }
771 free(cmdline);
772 /* Wipe current event since we are about to print a new PID. */
773 memset(&cur_event, 0, sizeof(cur_event));
774 }
775
776 if (strcmp(cur_event.name, fields[i].event.name) != 0) {
777 if (event_element_open) {
778 /* Close the previous fields element and the previous event */
779 ret = mi_lttng_close_multi_element(writer, 2);
780 if (ret) {
781 goto end;
782 }
783 event_element_open = 0;
784 }
785
786 memcpy(&cur_event, &fields[i].event,
787 sizeof(cur_event));
788
789 if (!event_element_open) {
790 /* Open and write the event */
791 ret = mi_lttng_event(writer, &cur_event, 1,
792 handle->domain.type);
793 if (ret) {
794 goto end;
795 }
796
797 /* Open a fields element */
798 ret = mi_lttng_event_fields_open(writer);
799 if (ret) {
800 goto end;
801 }
802 event_element_open = 1;
803 }
804 }
805
806 /* Print the event_field */
807 ret = mi_lttng_event_field(writer, &fields[i]);
808 if (ret) {
809 goto end;
810 }
811 }
812
813 /* Close pids, domain, domains */
814 ret = mi_lttng_close_multi_element(writer, 3);
815 end:
816 return ret;
817 error:
818 free(cmdline);
819 return ret;
820 }
821
822 /*
823 * Ask session daemon for all user space tracepoint fields available.
824 */
825 static int list_ust_event_fields(void)
826 {
827 int i, size, ret = CMD_SUCCESS;
828 struct lttng_domain domain;
829 struct lttng_handle *handle;
830 struct lttng_event_field *event_field_list;
831 pid_t cur_pid = 0;
832 char *cmdline = NULL;
833
834 struct lttng_event cur_event;
835
836 memset(&domain, 0, sizeof(domain));
837 memset(&cur_event, 0, sizeof(cur_event));
838
839 DBG("Getting UST tracing event fields");
840
841 domain.type = LTTNG_DOMAIN_UST;
842
843 handle = lttng_create_handle(NULL, &domain);
844 if (handle == NULL) {
845 ret = CMD_ERROR;
846 goto end;
847 }
848
849 size = lttng_list_tracepoint_fields(handle, &event_field_list);
850 if (size < 0) {
851 ERR("Unable to list UST event fields: %s", lttng_strerror(size));
852 ret = CMD_ERROR;
853 goto end;
854 }
855
856 if (lttng_opt_mi) {
857 /* Mi print */
858 ret = mi_list_ust_event_fields(event_field_list, size, &domain);
859 if (ret) {
860 ret = CMD_ERROR;
861 goto error;
862 }
863 } else {
864 /* Pretty print */
865 MSG("UST events:\n-------------");
866
867 if (size == 0) {
868 MSG("None");
869 }
870
871 for (i = 0; i < size; i++) {
872 if (cur_pid != event_field_list[i].event.pid) {
873 cur_pid = event_field_list[i].event.pid;
874 cmdline = get_cmdline_by_pid(cur_pid);
875 if (cmdline == NULL) {
876 ret = CMD_ERROR;
877 goto error;
878 }
879 MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
880 free(cmdline);
881 /* Wipe current event since we are about to print a new PID. */
882 memset(&cur_event, 0, sizeof(cur_event));
883 }
884 if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) {
885 print_events(&event_field_list[i].event);
886 memcpy(&cur_event, &event_field_list[i].event,
887 sizeof(cur_event));
888 }
889 print_event_field(&event_field_list[i]);
890 }
891
892 MSG("");
893 }
894
895 error:
896 free(event_field_list);
897 end:
898 lttng_destroy_handle(handle);
899 return ret;
900 }
901
902 /*
903 * Machine interface
904 * Print a list of kernel events
905 */
906 static int mi_list_kernel_events(struct lttng_event *events, int count,
907 struct lttng_domain *domain)
908 {
909 int ret, i;
910
911 /* Open domains element */
912 ret = mi_lttng_domains_open(writer);
913 if (ret) {
914 goto end;
915 }
916
917 /* Write domain */
918 ret = mi_lttng_domain(writer, domain, 1);
919 if (ret) {
920 goto end;
921 }
922
923 /* Open events */
924 ret = mi_lttng_events_open(writer);
925 if (ret) {
926 goto end;
927 }
928
929 for (i = 0; i < count; i++) {
930 ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
931 if (ret) {
932 goto end;
933 }
934 }
935
936 /* close events, domain and domains */
937 ret = mi_lttng_close_multi_element(writer, 3);
938 if (ret) {
939 goto end;
940 }
941
942 end:
943 return ret;
944 }
945
946 /*
947 * Ask for all trace events in the kernel
948 */
949 static int list_kernel_events(void)
950 {
951 int i, size, ret = CMD_SUCCESS;
952 struct lttng_domain domain;
953 struct lttng_handle *handle;
954 struct lttng_event *event_list;
955
956 memset(&domain, 0, sizeof(domain));
957
958 DBG("Getting kernel tracing events");
959
960 domain.type = LTTNG_DOMAIN_KERNEL;
961
962 handle = lttng_create_handle(NULL, &domain);
963 if (handle == NULL) {
964 ret = CMD_ERROR;
965 goto error;
966 }
967
968 size = lttng_list_tracepoints(handle, &event_list);
969 if (size < 0) {
970 ERR("Unable to list kernel events: %s", lttng_strerror(size));
971 lttng_destroy_handle(handle);
972 return CMD_ERROR;
973 }
974
975 if (lttng_opt_mi) {
976 /* Mi print */
977 ret = mi_list_kernel_events(event_list, size, &domain);
978 if (ret) {
979 ret = CMD_ERROR;
980 goto end;
981 }
982 } else {
983 MSG("Kernel events:\n-------------");
984
985 for (i = 0; i < size; i++) {
986 print_events(&event_list[i]);
987 }
988
989 MSG("");
990 }
991
992 end:
993 free(event_list);
994
995 lttng_destroy_handle(handle);
996 return ret;
997
998 error:
999 lttng_destroy_handle(handle);
1000 return ret;
1001 }
1002
1003 /*
1004 * Machine interface
1005 * Print a list of system calls.
1006 */
1007 static int mi_list_syscalls(struct lttng_event *events, int count)
1008 {
1009 int ret, i;
1010
1011 /* Open events */
1012 ret = mi_lttng_events_open(writer);
1013 if (ret) {
1014 goto end;
1015 }
1016
1017 for (i = 0; i < count; i++) {
1018 ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
1019 if (ret) {
1020 goto end;
1021 }
1022 }
1023
1024 /* Close events. */
1025 ret = mi_lttng_writer_close_element(writer);
1026 if (ret) {
1027 goto end;
1028 }
1029
1030 end:
1031 return ret;
1032 }
1033
1034 /*
1035 * Ask for kernel system calls.
1036 */
1037 static int list_syscalls(void)
1038 {
1039 int i, size, ret = CMD_SUCCESS;
1040 struct lttng_event *event_list;
1041
1042 DBG("Getting kernel system call events");
1043
1044 size = lttng_list_syscalls(&event_list);
1045 if (size < 0) {
1046 ERR("Unable to list system calls: %s", lttng_strerror(size));
1047 ret = CMD_ERROR;
1048 goto error;
1049 }
1050
1051 if (lttng_opt_mi) {
1052 /* Mi print */
1053 ret = mi_list_syscalls(event_list, size);
1054 if (ret) {
1055 ret = CMD_ERROR;
1056 goto end;
1057 }
1058 } else {
1059 MSG("System calls:\n-------------");
1060
1061 for (i = 0; i < size; i++) {
1062 print_events(&event_list[i]);
1063 }
1064
1065 MSG("");
1066 }
1067
1068 end:
1069 free(event_list);
1070 return ret;
1071
1072 error:
1073 return ret;
1074 }
1075
1076 /*
1077 * Machine Interface
1078 * Print a list of agent events
1079 */
1080 static int mi_list_session_agent_events(struct lttng_event *events, int count)
1081 {
1082 int ret, i;
1083
1084 /* Open events element */
1085 ret = mi_lttng_events_open(writer);
1086 if (ret) {
1087 goto end;
1088 }
1089
1090 for (i = 0; i < count; i++) {
1091 ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
1092 if (ret) {
1093 goto end;
1094 }
1095 }
1096
1097 /* Close events element */
1098 ret = mi_lttng_writer_close_element(writer);
1099
1100 end:
1101 return ret;
1102 }
1103
1104 /*
1105 * List agent events for a specific session using the handle.
1106 *
1107 * Return CMD_SUCCESS on success else a negative value.
1108 */
1109 static int list_session_agent_events(void)
1110 {
1111 int ret = CMD_SUCCESS, count, i;
1112 struct lttng_event *events = NULL;
1113
1114 count = lttng_list_events(handle, "", &events);
1115 if (count < 0) {
1116 ret = CMD_ERROR;
1117 ERR("%s", lttng_strerror(count));
1118 goto error;
1119 }
1120
1121 if (lttng_opt_mi) {
1122 /* Mi print */
1123 ret = mi_list_session_agent_events(events, count);
1124 if (ret) {
1125 ret = CMD_ERROR;
1126 goto end;
1127 }
1128 } else {
1129 /* Pretty print */
1130 MSG("Events (Logger name):\n---------------------");
1131 if (count == 0) {
1132 MSG("%sNone\n", indent6);
1133 goto end;
1134 }
1135
1136 for (i = 0; i < count; i++) {
1137 const char *filter_str;
1138 char *filter_msg = NULL;
1139 struct lttng_event *event = &events[i];
1140
1141 ret = lttng_event_get_filter_expression(event,
1142 &filter_str);
1143 if (ret) {
1144 filter_msg = strdup(" [failed to retrieve filter]");
1145 } else if (filter_str) {
1146 const char * const filter_fmt =
1147 " [filter: '%s']";
1148
1149 filter_msg = malloc(strlen(filter_str) +
1150 strlen(filter_fmt) + 1);
1151 if (filter_msg) {
1152 sprintf(filter_msg, filter_fmt,
1153 filter_str);
1154 }
1155 }
1156
1157 if (event->loglevel_type !=
1158 LTTNG_EVENT_LOGLEVEL_ALL) {
1159 MSG("%s- %s%s (loglevel%s %s)%s", indent4,
1160 event->name,
1161 enabled_string(event->enabled),
1162 logleveltype_string(
1163 event->loglevel_type),
1164 mi_lttng_loglevel_string(
1165 event->loglevel,
1166 handle->domain.type),
1167 safe_string(filter_msg));
1168 } else {
1169 MSG("%s- %s%s%s", indent4, event->name,
1170 enabled_string(event->enabled),
1171 safe_string(filter_msg));
1172 }
1173 free(filter_msg);
1174 }
1175
1176 MSG("");
1177 }
1178
1179 end:
1180 free(events);
1181 error:
1182 return ret;
1183 }
1184
1185 /*
1186 * Machine interface
1187 * print a list of event
1188 */
1189 static int mi_list_events(struct lttng_event *events, int count)
1190 {
1191 int ret, i;
1192
1193 /* Open events element */
1194 ret = mi_lttng_events_open(writer);
1195 if (ret) {
1196 goto end;
1197 }
1198
1199 for (i = 0; i < count; i++) {
1200 ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
1201 if (ret) {
1202 goto end;
1203 }
1204 }
1205
1206 /* Close events element */
1207 ret = mi_lttng_writer_close_element(writer);
1208
1209 end:
1210 return ret;
1211 }
1212
1213 /*
1214 * List events of channel of session and domain.
1215 */
1216 static int list_events(const char *channel_name)
1217 {
1218 int ret = CMD_SUCCESS, count, i;
1219 struct lttng_event *events = NULL;
1220
1221 count = lttng_list_events(handle, channel_name, &events);
1222 if (count < 0) {
1223 ret = CMD_ERROR;
1224 ERR("%s", lttng_strerror(count));
1225 goto error;
1226 }
1227
1228 if (lttng_opt_mi) {
1229 /* Mi print */
1230 ret = mi_list_events(events, count);
1231 if (ret) {
1232 ret = CMD_ERROR;
1233 goto end;
1234 }
1235 } else {
1236 /* Pretty print */
1237 MSG("\n%sEvent rules:", indent4);
1238 if (count == 0) {
1239 MSG("%sNone\n", indent6);
1240 goto end;
1241 }
1242
1243 for (i = 0; i < count; i++) {
1244 print_events(&events[i]);
1245 }
1246
1247 MSG("");
1248 }
1249 end:
1250 free(events);
1251 error:
1252 return ret;
1253 }
1254
1255 static
1256 void print_timer(const char *timer_name, uint32_t space_count, int64_t value)
1257 {
1258 uint32_t i;
1259
1260 _MSG("%s%s:", indent6, timer_name);
1261 for (i = 0; i < space_count; i++) {
1262 _MSG(" ");
1263 }
1264
1265 if (value) {
1266 MSG("%" PRId64 " %s", value, USEC_UNIT);
1267 } else {
1268 MSG("inactive");
1269 }
1270 }
1271
1272 /*
1273 * Pretty print channel
1274 */
1275 static void print_channel(struct lttng_channel *channel)
1276 {
1277 int ret;
1278 uint64_t discarded_events, lost_packets, monitor_timer_interval;
1279 int64_t blocking_timeout;
1280
1281 ret = lttng_channel_get_discarded_event_count(channel,
1282 &discarded_events);
1283 if (ret) {
1284 ERR("Failed to retrieve discarded event count of channel");
1285 return;
1286 }
1287
1288 ret = lttng_channel_get_lost_packet_count(channel,
1289 &lost_packets);
1290 if (ret) {
1291 ERR("Failed to retrieve lost packet count of channel");
1292 return;
1293 }
1294
1295 ret = lttng_channel_get_monitor_timer_interval(channel,
1296 &monitor_timer_interval);
1297 if (ret) {
1298 ERR("Failed to retrieve monitor interval of channel");
1299 return;
1300 }
1301
1302 ret = lttng_channel_get_blocking_timeout(channel,
1303 &blocking_timeout);
1304 if (ret) {
1305 ERR("Failed to retrieve blocking timeout of channel");
1306 return;
1307 }
1308
1309 MSG("- %s:%s\n", channel->name, enabled_string(channel->enabled));
1310 MSG("%sAttributes:", indent4);
1311 MSG("%sEvent-loss mode: %s", indent6, channel->attr.overwrite ? "overwrite" : "discard");
1312 MSG("%sSub-buffer size: %" PRIu64 " bytes", indent6, channel->attr.subbuf_size);
1313 MSG("%sSub-buffer count: %" PRIu64, indent6, channel->attr.num_subbuf);
1314
1315 print_timer("Switch timer", 5, channel->attr.switch_timer_interval);
1316 print_timer("Read timer", 7, channel->attr.read_timer_interval);
1317 print_timer("Monitor timer", 4, monitor_timer_interval);
1318
1319 if (!channel->attr.overwrite) {
1320 if (blocking_timeout == -1) {
1321 MSG("%sBlocking timeout: infinite", indent6);
1322 } else {
1323 MSG("%sBlocking timeout: %" PRId64 " %s", indent6,
1324 blocking_timeout, USEC_UNIT);
1325 }
1326 }
1327
1328 MSG("%sTrace file count: %" PRIu64 " per stream", indent6,
1329 channel->attr.tracefile_count == 0 ?
1330 1 : channel->attr.tracefile_count);
1331 if (channel->attr.tracefile_size != 0 ) {
1332 MSG("%sTrace file size: %" PRIu64 " bytes", indent6,
1333 channel->attr.tracefile_size);
1334 } else {
1335 MSG("%sTrace file size: %s", indent6, "unlimited");
1336 }
1337 switch (channel->attr.output) {
1338 case LTTNG_EVENT_SPLICE:
1339 MSG("%sOutput mode: splice", indent6);
1340 break;
1341 case LTTNG_EVENT_MMAP:
1342 MSG("%sOutput mode: mmap", indent6);
1343 break;
1344 }
1345
1346 MSG("\n%sStatistics:", indent4);
1347 if (listed_session.snapshot_mode) {
1348 /*
1349 * The lost packet count is omitted for sessions in snapshot
1350 * mode as it is misleading: it would indicate the number of
1351 * packets that the consumer could not extract during the
1352 * course of recording the snapshot. It does not have the
1353 * same meaning as the "regular" lost packet count that
1354 * would result from the consumer not keeping up with
1355 * event production in an overwrite-mode channel.
1356 *
1357 * A more interesting statistic would be the number of
1358 * packets lost between the first and last extracted
1359 * packets of a given snapshot (which prevents most analyses).
1360 */
1361 MSG("%sNone", indent6);
1362 goto skip_stats_printing;
1363 }
1364
1365 if (!channel->attr.overwrite) {
1366 MSG("%sDiscarded events: %" PRIu64, indent6, discarded_events);
1367 } else {
1368 MSG("%sLost packets: %" PRIu64, indent6, lost_packets);
1369 }
1370 skip_stats_printing:
1371 return;
1372 }
1373
1374 /*
1375 * Machine interface
1376 * Print a list of channel
1377 *
1378 */
1379 static int mi_list_channels(struct lttng_channel *channels, int count,
1380 const char *channel_name)
1381 {
1382 int i, ret;
1383 unsigned int chan_found = 0;
1384
1385 /* Open channels element */
1386 ret = mi_lttng_channels_open(writer);
1387 if (ret) {
1388 goto error;
1389 }
1390
1391 for (i = 0; i < count; i++) {
1392 if (channel_name != NULL) {
1393 if (strncmp(channels[i].name, channel_name, NAME_MAX) == 0) {
1394 chan_found = 1;
1395 } else {
1396 continue;
1397 }
1398 }
1399
1400 /* Write channel element and leave it open */
1401 ret = mi_lttng_channel(writer, &channels[i], 1);
1402 if (ret) {
1403 goto error;
1404 }
1405
1406 /* Listing events per channel */
1407 ret = list_events(channels[i].name);
1408 if (ret) {
1409 goto error;
1410 }
1411
1412 /* Closing the channel element we opened earlier */
1413 ret = mi_lttng_writer_close_element(writer);
1414 if (ret) {
1415 goto error;
1416 }
1417
1418 if (chan_found) {
1419 break;
1420 }
1421 }
1422
1423 /* Close channels element */
1424 ret = mi_lttng_writer_close_element(writer);
1425 if (ret) {
1426 goto error;
1427 }
1428
1429 error:
1430 return ret;
1431 }
1432
1433 /*
1434 * List channel(s) of session and domain.
1435 *
1436 * If channel_name is NULL, all channels are listed.
1437 */
1438 static int list_channels(const char *channel_name)
1439 {
1440 int count, i, ret = CMD_SUCCESS;
1441 unsigned int chan_found = 0;
1442 struct lttng_channel *channels = NULL;
1443
1444 DBG("Listing channel(s) (%s)", channel_name ? : "<all>");
1445
1446 count = lttng_list_channels(handle, &channels);
1447 if (count < 0) {
1448 switch (-count) {
1449 case LTTNG_ERR_KERN_CHAN_NOT_FOUND:
1450 if (lttng_opt_mi) {
1451 /* When printing mi this is not an error
1452 * but an empty channels element */
1453 count = 0;
1454 } else {
1455 ret = CMD_SUCCESS;
1456 WARN("No kernel channel");
1457 goto error_channels;
1458 }
1459 break;
1460 default:
1461 /* We had a real error */
1462 ret = CMD_ERROR;
1463 ERR("%s", lttng_strerror(count));
1464 goto error_channels;
1465 break;
1466 }
1467 }
1468
1469 if (lttng_opt_mi) {
1470 /* Mi print */
1471 ret = mi_list_channels(channels, count, channel_name);
1472 if (ret) {
1473 ret = CMD_ERROR;
1474 goto error;
1475 }
1476 } else {
1477 /* Pretty print */
1478 if (count) {
1479 MSG("Channels:\n-------------");
1480 }
1481
1482 for (i = 0; i < count; i++) {
1483 if (channel_name != NULL) {
1484 if (strncmp(channels[i].name, channel_name, NAME_MAX) == 0) {
1485 chan_found = 1;
1486 } else {
1487 continue;
1488 }
1489 }
1490 print_channel(&channels[i]);
1491
1492 /* Listing events per channel */
1493 ret = list_events(channels[i].name);
1494 if (ret) {
1495 goto error;
1496 }
1497
1498 if (chan_found) {
1499 break;
1500 }
1501 }
1502
1503 if (!chan_found && channel_name != NULL) {
1504 ret = CMD_ERROR;
1505 ERR("Channel %s not found", channel_name);
1506 goto error;
1507 }
1508 }
1509 error:
1510 free(channels);
1511
1512 error_channels:
1513 return ret;
1514 }
1515
1516 static const char *get_tracker_str(enum lttng_tracker_type tracker_type)
1517 {
1518 switch (tracker_type) {
1519 case LTTNG_TRACKER_PID:
1520 return "PID";
1521 case LTTNG_TRACKER_VPID:
1522 return "VPID";
1523 case LTTNG_TRACKER_UID:
1524 return "UID";
1525 case LTTNG_TRACKER_VUID:
1526 return "VUID";
1527 case LTTNG_TRACKER_GID:
1528 return "GID";
1529 case LTTNG_TRACKER_VGID:
1530 return "VGID";
1531 }
1532 return NULL;
1533 }
1534
1535 /*
1536 * List tracker ID(s) of session and domain.
1537 */
1538 static int list_tracker_ids(enum lttng_tracker_type tracker_type)
1539 {
1540 int ret = 0;
1541 int enabled = 1;
1542 struct lttng_tracker_ids *ids = NULL;
1543 size_t nr_ids, i;
1544 const struct lttng_tracker_id *id;
1545
1546 ret = lttng_list_tracker_ids(handle, tracker_type, &ids);
1547 if (ret) {
1548 return ret;
1549 }
1550
1551 nr_ids = lttng_tracker_ids_get_count(ids);
1552 if (nr_ids == 1) {
1553 id = lttng_tracker_ids_get_at_index(ids, 0);
1554 if (id && lttng_tracker_id_get_type(id) == LTTNG_ID_ALL) {
1555 enabled = 0;
1556 }
1557 }
1558
1559 if (enabled) {
1560 _MSG("%s tracker: [", get_tracker_str(tracker_type));
1561
1562 /* Mi tracker_id element */
1563 if (writer) {
1564 /* Open tracker_id and targets elements */
1565 ret = mi_lttng_id_tracker_open(writer, tracker_type);
1566 if (ret) {
1567 goto end;
1568 }
1569 }
1570
1571 for (i = 0; i < nr_ids; i++) {
1572 enum lttng_tracker_id_status status =
1573 LTTNG_TRACKER_ID_STATUS_OK;
1574 int value;
1575 const char *value_string;
1576
1577 id = lttng_tracker_ids_get_at_index(ids, i);
1578 if (!id) {
1579 ret = CMD_ERROR;
1580 goto end;
1581 }
1582
1583 switch (lttng_tracker_id_get_type(id)) {
1584 case LTTNG_ID_ALL:
1585 break;
1586 case LTTNG_ID_VALUE:
1587 status = lttng_tracker_id_get_value(id, &value);
1588 break;
1589 case LTTNG_ID_STRING:
1590 status = lttng_tracker_id_get_string(
1591 id, &value_string);
1592 break;
1593 case LTTNG_ID_UNKNOWN:
1594 ret = CMD_ERROR;
1595 goto end;
1596 }
1597
1598 if (status != LTTNG_TRACKER_ID_STATUS_OK) {
1599 ERR("Invalid state for tracker id");
1600 ret = CMD_ERROR;
1601 goto end;
1602 }
1603
1604 if (i) {
1605 _MSG(",");
1606 }
1607 switch (lttng_tracker_id_get_type(id)) {
1608 case LTTNG_ID_ALL:
1609 _MSG(" *");
1610 break;
1611 case LTTNG_ID_VALUE:
1612 _MSG(" %d", value);
1613 break;
1614 case LTTNG_ID_STRING:
1615 _MSG(" %s", value_string);
1616 break;
1617 case LTTNG_ID_UNKNOWN:
1618 ERR("Invalid state for tracker id");
1619 ret = CMD_ERROR;
1620 goto end;
1621 }
1622
1623 /* Mi */
1624 if (writer) {
1625 ret = mi_lttng_id_target(
1626 writer, tracker_type, id, 0);
1627 if (ret) {
1628 goto end;
1629 }
1630 }
1631 }
1632 _MSG(" ]\n\n");
1633
1634 /* Mi close tracker_id and targets */
1635 if (writer) {
1636 ret = mi_lttng_close_multi_element(writer, 2);
1637 if (ret) {
1638 goto end;
1639 }
1640 }
1641 }
1642 end:
1643 lttng_tracker_ids_destroy(ids);
1644 return ret;
1645 }
1646
1647 /*
1648 * List all trackers of a domain
1649 */
1650 static int list_trackers(const struct lttng_domain *domain)
1651 {
1652 int ret = 0;
1653
1654 /* Trackers listing */
1655 if (lttng_opt_mi) {
1656 ret = mi_lttng_trackers_open(writer);
1657 if (ret) {
1658 goto end;
1659 }
1660 }
1661
1662 switch (domain->type) {
1663 case LTTNG_DOMAIN_KERNEL:
1664 /* pid tracker */
1665 ret = list_tracker_ids(LTTNG_TRACKER_PID);
1666 if (ret) {
1667 goto end;
1668 }
1669 /* vpid tracker */
1670 ret = list_tracker_ids(LTTNG_TRACKER_VPID);
1671 if (ret) {
1672 goto end;
1673 }
1674 /* uid tracker */
1675 ret = list_tracker_ids(LTTNG_TRACKER_UID);
1676 if (ret) {
1677 goto end;
1678 }
1679 /* vuid tracker */
1680 ret = list_tracker_ids(LTTNG_TRACKER_VUID);
1681 if (ret) {
1682 goto end;
1683 }
1684 /* gid tracker */
1685 ret = list_tracker_ids(LTTNG_TRACKER_GID);
1686 if (ret) {
1687 goto end;
1688 }
1689 /* vgid tracker */
1690 ret = list_tracker_ids(LTTNG_TRACKER_VGID);
1691 if (ret) {
1692 goto end;
1693 }
1694 break;
1695 case LTTNG_DOMAIN_UST:
1696 /* vpid tracker */
1697 ret = list_tracker_ids(LTTNG_TRACKER_VPID);
1698 if (ret) {
1699 goto end;
1700 }
1701 /* vuid tracker */
1702 ret = list_tracker_ids(LTTNG_TRACKER_VUID);
1703 if (ret) {
1704 goto end;
1705 }
1706 /* vgid tracker */
1707 ret = list_tracker_ids(LTTNG_TRACKER_VGID);
1708 if (ret) {
1709 goto end;
1710 }
1711 break;
1712 default:
1713 break;
1714 }
1715 if (lttng_opt_mi) {
1716 /* Close trackers element */
1717 ret = mi_lttng_writer_close_element(writer);
1718 if (ret) {
1719 goto end;
1720 }
1721 }
1722
1723 end:
1724 return ret;
1725 }
1726
1727 static enum cmd_error_code print_periodic_rotation_schedule(
1728 const struct lttng_rotation_schedule *schedule)
1729 {
1730 enum cmd_error_code ret;
1731 enum lttng_rotation_status status;
1732 uint64_t value;
1733
1734 status = lttng_rotation_schedule_periodic_get_period(schedule,
1735 &value);
1736 if (status != LTTNG_ROTATION_STATUS_OK) {
1737 ERR("Failed to retrieve period parameter from periodic rotation schedule.");
1738 ret = CMD_ERROR;
1739 goto end;
1740 }
1741
1742 MSG(" timer period: %" PRIu64" %s", value, USEC_UNIT);
1743 ret = CMD_SUCCESS;
1744 end:
1745 return ret;
1746 }
1747
1748 static enum cmd_error_code print_size_threshold_rotation_schedule(
1749 const struct lttng_rotation_schedule *schedule)
1750 {
1751 enum cmd_error_code ret;
1752 enum lttng_rotation_status status;
1753 uint64_t value;
1754
1755 status = lttng_rotation_schedule_size_threshold_get_threshold(schedule,
1756 &value);
1757 if (status != LTTNG_ROTATION_STATUS_OK) {
1758 ERR("Failed to retrieve size parameter from size-based rotation schedule.");
1759 ret = CMD_ERROR;
1760 goto end;
1761 }
1762
1763 MSG(" size threshold: %" PRIu64" bytes", value);
1764 ret = CMD_SUCCESS;
1765 end:
1766 return ret;
1767 }
1768
1769 static enum cmd_error_code print_rotation_schedule(
1770 const struct lttng_rotation_schedule *schedule)
1771 {
1772 enum cmd_error_code ret;
1773
1774 switch (lttng_rotation_schedule_get_type(schedule)) {
1775 case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
1776 ret = print_size_threshold_rotation_schedule(schedule);
1777 break;
1778 case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
1779 ret = print_periodic_rotation_schedule(schedule);
1780 break;
1781 default:
1782 ret = CMD_ERROR;
1783 }
1784 return ret;
1785 }
1786
1787 /*
1788 * List the automatic rotation settings.
1789 */
1790 static enum cmd_error_code list_rotate_settings(const char *session_name)
1791 {
1792 int ret;
1793 enum cmd_error_code cmd_ret = CMD_SUCCESS;
1794 unsigned int count, i;
1795 struct lttng_rotation_schedules *schedules = NULL;
1796 enum lttng_rotation_status status;
1797
1798 ret = lttng_session_list_rotation_schedules(session_name, &schedules);
1799 if (ret != LTTNG_OK) {
1800 ERR("Failed to list session rotation schedules: %s", lttng_strerror(ret));
1801 cmd_ret = CMD_ERROR;
1802 goto end;
1803 }
1804
1805 status = lttng_rotation_schedules_get_count(schedules, &count);
1806 if (status != LTTNG_ROTATION_STATUS_OK) {
1807 ERR("Failed to retrieve the number of session rotation schedules.");
1808 cmd_ret = CMD_ERROR;
1809 goto end;
1810 }
1811
1812 if (count == 0) {
1813 cmd_ret = CMD_SUCCESS;
1814 goto end;
1815 }
1816
1817 MSG("Automatic rotation schedules:");
1818 if (lttng_opt_mi) {
1819 ret = mi_lttng_writer_open_element(writer,
1820 mi_lttng_element_rotation_schedules);
1821 if (ret) {
1822 cmd_ret = CMD_ERROR;
1823 goto end;
1824 }
1825 }
1826
1827 for (i = 0; i < count; i++) {
1828 enum cmd_error_code tmp_ret = CMD_SUCCESS;
1829 const struct lttng_rotation_schedule *schedule;
1830
1831 schedule = lttng_rotation_schedules_get_at_index(schedules, i);
1832 if (!schedule) {
1833 ERR("Failed to retrieve session rotation schedule.");
1834 cmd_ret = CMD_ERROR;
1835 goto end;
1836 }
1837
1838 if (lttng_opt_mi) {
1839 ret = mi_lttng_rotation_schedule(writer, schedule);
1840 if (ret) {
1841 tmp_ret = CMD_ERROR;
1842 }
1843 } else {
1844 tmp_ret = print_rotation_schedule(schedule);
1845 }
1846
1847 /*
1848 * Report an error if the serialization of any of the
1849 * descriptors failed.
1850 */
1851 cmd_ret = cmd_ret ? cmd_ret : tmp_ret;
1852 }
1853
1854 _MSG("\n");
1855 if (lttng_opt_mi) {
1856 /* Close the rotation_schedules element. */
1857 ret = mi_lttng_writer_close_element(writer);
1858 if (ret) {
1859 cmd_ret = CMD_ERROR;
1860 goto end;
1861 }
1862 }
1863 end:
1864 lttng_rotation_schedules_destroy(schedules);
1865 return cmd_ret;
1866 }
1867
1868 /*
1869 * Machine interface
1870 * Find the session with session_name as name
1871 * and print his informations.
1872 */
1873 static int mi_list_session(const char *session_name,
1874 struct lttng_session *sessions, int count)
1875 {
1876 int ret, i;
1877 unsigned int session_found = 0;
1878
1879 if (session_name == NULL) {
1880 ret = -LTTNG_ERR_SESS_NOT_FOUND;
1881 goto end;
1882 }
1883
1884 for (i = 0; i < count; i++) {
1885 if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
1886 /* We need to leave it open to append other informations
1887 * like domain, channel, events etc.*/
1888 session_found = 1;
1889 ret = mi_lttng_session(writer, &sessions[i], 1);
1890 if (ret) {
1891 goto end;
1892 }
1893 break;
1894 }
1895 }
1896
1897 if (!session_found) {
1898 ERR("Session '%s' not found", session_name);
1899 ret = -LTTNG_ERR_SESS_NOT_FOUND;
1900 goto end;
1901 }
1902
1903 end:
1904 return ret;
1905 }
1906
1907 /*
1908 * Machine interface
1909 * List all availables session
1910 */
1911 static int mi_list_sessions(struct lttng_session *sessions, int count)
1912 {
1913 int ret, i;
1914
1915 /* Opening sessions element */
1916 ret = mi_lttng_sessions_open(writer);
1917 if (ret) {
1918 goto end;
1919 }
1920
1921 /* Listing sessions */
1922 for (i = 0; i < count; i++) {
1923 ret = mi_lttng_session(writer, &sessions[i], 0);
1924 if (ret) {
1925 goto end;
1926 }
1927 }
1928
1929 /* Closing sessions element */
1930 ret = mi_lttng_writer_close_element(writer);
1931 if (ret) {
1932 goto end;
1933 }
1934
1935 end:
1936 return ret;
1937 }
1938
1939 /*
1940 * List available tracing session. List only basic information.
1941 *
1942 * If session_name is NULL, all sessions are listed.
1943 */
1944 static int list_sessions(const char *session_name)
1945 {
1946 int ret = CMD_SUCCESS;
1947 int count, i;
1948 unsigned int session_found = 0;
1949 struct lttng_session *sessions = NULL;
1950
1951 count = lttng_list_sessions(&sessions);
1952 DBG("Session count %d", count);
1953 if (count < 0) {
1954 ret = CMD_ERROR;
1955 ERR("%s", lttng_strerror(count));
1956 goto end;
1957 }
1958
1959 if (lttng_opt_mi) {
1960 /* Mi */
1961 if (session_name == NULL) {
1962 /* List all sessions */
1963 ret = mi_list_sessions(sessions, count);
1964 } else {
1965 /* Note : this return an open session element */
1966 ret = mi_list_session(session_name, sessions, count);
1967 }
1968 if (ret) {
1969 ret = CMD_ERROR;
1970 goto end;
1971 }
1972 } else {
1973 /* Pretty print */
1974 if (count == 0) {
1975 MSG("Currently no available tracing session");
1976 goto end;
1977 }
1978
1979 if (session_name == NULL) {
1980 MSG("Available tracing sessions:");
1981 }
1982
1983 for (i = 0; i < count; i++) {
1984 if (session_name != NULL) {
1985 if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
1986 session_found = 1;
1987 MSG("Tracing session %s: [%s%s]", session_name,
1988 active_string(sessions[i].enabled),
1989 snapshot_string(sessions[i].snapshot_mode));
1990 if (*sessions[i].path) {
1991 MSG("%sTrace output: %s\n", indent4, sessions[i].path);
1992 }
1993 memcpy(&listed_session, &sessions[i],
1994 sizeof(listed_session));
1995 break;
1996 }
1997 } else {
1998 MSG(" %d) %s [%s%s]", i + 1,
1999 sessions[i].name,
2000 active_string(sessions[i].enabled),
2001 snapshot_string(sessions[i].snapshot_mode));
2002 if (*sessions[i].path) {
2003 MSG("%sTrace output: %s", indent4, sessions[i].path);
2004 }
2005 if (sessions[i].live_timer_interval != 0) {
2006 MSG("%sLive timer interval: %u %s", indent4,
2007 sessions[i].live_timer_interval,
2008 USEC_UNIT);
2009 }
2010 MSG("");
2011 }
2012 }
2013
2014 if (!session_found && session_name != NULL) {
2015 ERR("Session '%s' not found", session_name);
2016 ret = CMD_ERROR;
2017 goto end;
2018 }
2019
2020 if (session_name == NULL) {
2021 MSG("\nUse lttng list <session_name> for more details");
2022 }
2023 }
2024
2025 end:
2026 free(sessions);
2027 return ret;
2028 }
2029
2030
2031 /*
2032 * Machine Interface
2033 * list available domain(s) for a session.
2034 */
2035 static int mi_list_domains(struct lttng_domain *domains, int count)
2036 {
2037 int i, ret;
2038 /* Open domains element */
2039 ret = mi_lttng_domains_open(writer);
2040 if (ret) {
2041 goto end;
2042 }
2043
2044 for (i = 0; i < count; i++) {
2045 ret = mi_lttng_domain(writer, &domains[i] , 0);
2046 if (ret) {
2047 goto end;
2048 }
2049 }
2050
2051 /* Closing domains element */
2052 ret = mi_lttng_writer_close_element(writer);
2053 if (ret) {
2054 goto end;
2055 }
2056 end:
2057 return ret;
2058 }
2059
2060 /*
2061 * List available domain(s) for a session.
2062 */
2063 static int list_domains(const char *session_name)
2064 {
2065 int i, count, ret = CMD_SUCCESS;
2066 struct lttng_domain *domains = NULL;
2067
2068
2069 count = lttng_list_domains(session_name, &domains);
2070 if (count < 0) {
2071 ret = CMD_ERROR;
2072 ERR("%s", lttng_strerror(count));
2073 goto end;
2074 }
2075
2076 if (lttng_opt_mi) {
2077 /* Mi output */
2078 ret = mi_list_domains(domains, count);
2079 if (ret) {
2080 ret = CMD_ERROR;
2081 goto error;
2082 }
2083 } else {
2084 /* Pretty print */
2085 MSG("Domains:\n-------------");
2086 if (count == 0) {
2087 MSG(" None");
2088 goto end;
2089 }
2090
2091 for (i = 0; i < count; i++) {
2092 switch (domains[i].type) {
2093 case LTTNG_DOMAIN_KERNEL:
2094 MSG(" - Kernel");
2095 break;
2096 case LTTNG_DOMAIN_UST:
2097 MSG(" - UST global");
2098 break;
2099 case LTTNG_DOMAIN_JUL:
2100 MSG(" - JUL (Java Util Logging)");
2101 break;
2102 case LTTNG_DOMAIN_LOG4J:
2103 MSG(" - LOG4j (Logging for Java)");
2104 break;
2105 case LTTNG_DOMAIN_PYTHON:
2106 MSG(" - Python (logging)");
2107 break;
2108 default:
2109 break;
2110 }
2111 }
2112 }
2113
2114 error:
2115 free(domains);
2116
2117 end:
2118 return ret;
2119 }
2120
2121 /*
2122 * The 'list <options>' first level command
2123 */
2124 int cmd_list(int argc, const char **argv)
2125 {
2126 int opt, ret = CMD_SUCCESS;
2127 const char *session_name, *leftover = NULL;
2128 static poptContext pc;
2129 struct lttng_domain domain;
2130 struct lttng_domain *domains = NULL;
2131
2132 memset(&domain, 0, sizeof(domain));
2133
2134 if (argc < 1) {
2135 ret = CMD_ERROR;
2136 goto end;
2137 }
2138
2139 pc = poptGetContext(NULL, argc, argv, long_options, 0);
2140 poptReadDefaultConfig(pc, 0);
2141
2142 while ((opt = poptGetNextOpt(pc)) != -1) {
2143 switch (opt) {
2144 case OPT_HELP:
2145 SHOW_HELP();
2146 goto end;
2147 case OPT_USERSPACE:
2148 opt_userspace = 1;
2149 break;
2150 case OPT_LIST_OPTIONS:
2151 list_cmd_options(stdout, long_options);
2152 goto end;
2153 default:
2154 ret = CMD_UNDEFINED;
2155 goto end;
2156 }
2157 }
2158
2159 /* Mi check */
2160 if (lttng_opt_mi) {
2161 writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
2162 if (!writer) {
2163 ret = CMD_ERROR;
2164 goto end;
2165 }
2166
2167 /* Open command element */
2168 ret = mi_lttng_writer_command_open(writer,
2169 mi_lttng_element_command_list);
2170 if (ret) {
2171 ret = CMD_ERROR;
2172 goto end;
2173 }
2174
2175 /* Open output element */
2176 ret = mi_lttng_writer_open_element(writer,
2177 mi_lttng_element_command_output);
2178 if (ret) {
2179 ret = CMD_ERROR;
2180 goto end;
2181 }
2182 }
2183
2184 /* Get session name (trailing argument) */
2185 session_name = poptGetArg(pc);
2186 DBG2("Session name: %s", session_name);
2187
2188 leftover = poptGetArg(pc);
2189 if (leftover) {
2190 ERR("Unknown argument: %s", leftover);
2191 ret = CMD_ERROR;
2192 goto end;
2193 }
2194
2195 if (opt_kernel) {
2196 domain.type = LTTNG_DOMAIN_KERNEL;
2197 } else if (opt_userspace) {
2198 DBG2("Listing userspace global domain");
2199 domain.type = LTTNG_DOMAIN_UST;
2200 } else if (opt_jul) {
2201 DBG2("Listing JUL domain");
2202 domain.type = LTTNG_DOMAIN_JUL;
2203 } else if (opt_log4j) {
2204 domain.type = LTTNG_DOMAIN_LOG4J;
2205 } else if (opt_python) {
2206 domain.type = LTTNG_DOMAIN_PYTHON;
2207 }
2208
2209 if (!opt_kernel && opt_syscall) {
2210 WARN("--syscall will only work with the Kernel domain (-k)");
2211 ret = CMD_ERROR;
2212 goto end;
2213 }
2214
2215 if (opt_kernel || opt_userspace || opt_jul || opt_log4j || opt_python) {
2216 handle = lttng_create_handle(session_name, &domain);
2217 if (handle == NULL) {
2218 ret = CMD_FATAL;
2219 goto end;
2220 }
2221 }
2222
2223 if (session_name == NULL) {
2224 if (!opt_kernel && !opt_userspace && !opt_jul && !opt_log4j
2225 && !opt_python) {
2226 ret = list_sessions(NULL);
2227 if (ret) {
2228 goto end;
2229 }
2230 }
2231 if (opt_kernel) {
2232 if (opt_syscall) {
2233 ret = list_syscalls();
2234 if (ret) {
2235 goto end;
2236 }
2237 } else {
2238 ret = list_kernel_events();
2239 if (ret) {
2240 goto end;
2241 }
2242 }
2243 }
2244 if (opt_userspace) {
2245 if (opt_fields) {
2246 ret = list_ust_event_fields();
2247 } else {
2248 ret = list_ust_events();
2249 }
2250 if (ret) {
2251 goto end;
2252 }
2253 }
2254 if (opt_jul || opt_log4j || opt_python) {
2255 ret = list_agent_events();
2256 if (ret) {
2257 goto end;
2258 }
2259 }
2260 } else {
2261 /* List session attributes */
2262 if (lttng_opt_mi) {
2263 /* Open element sessions
2264 * Present for xml consistency */
2265 ret = mi_lttng_sessions_open(writer);
2266 if (ret) {
2267 goto end;
2268 }
2269 }
2270 /* MI: the ouptut of list_sessions is an unclosed session element */
2271 ret = list_sessions(session_name);
2272 if (ret) {
2273 goto end;
2274 }
2275
2276 ret = list_rotate_settings(session_name);
2277 if (ret) {
2278 goto end;
2279 }
2280
2281 /* Domain listing */
2282 if (opt_domain) {
2283 ret = list_domains(session_name);
2284 goto end;
2285 }
2286
2287 /* Channel listing */
2288 if (opt_kernel || opt_userspace) {
2289 if (lttng_opt_mi) {
2290 /* Add of domains and domain element for xml
2291 * consistency and validation
2292 */
2293 ret = mi_lttng_domains_open(writer);
2294 if (ret) {
2295 goto end;
2296 }
2297
2298 /* Open domain and leave it open for
2299 * nested channels printing */
2300 ret = mi_lttng_domain(writer, &domain, 1);
2301 if (ret) {
2302 goto end;
2303 }
2304
2305 }
2306
2307
2308 /* Trackers */
2309 ret = list_trackers(&domain);
2310 if (ret) {
2311 goto end;
2312 }
2313
2314 /* Channels */
2315 ret = list_channels(opt_channel);
2316 if (ret) {
2317 goto end;
2318 }
2319
2320 if (lttng_opt_mi) {
2321 /* Close domain and domain element */
2322 ret = mi_lttng_close_multi_element(writer, 2);
2323 }
2324 if (ret) {
2325 goto end;
2326 }
2327
2328
2329 } else {
2330 int i, nb_domain;
2331
2332 /* We want all domain(s) */
2333 nb_domain = lttng_list_domains(session_name, &domains);
2334 if (nb_domain < 0) {
2335 ret = CMD_ERROR;
2336 ERR("%s", lttng_strerror(nb_domain));
2337 goto end;
2338 }
2339
2340 if (lttng_opt_mi) {
2341 ret = mi_lttng_domains_open(writer);
2342 if (ret) {
2343 ret = CMD_ERROR;
2344 goto end;
2345 }
2346 }
2347
2348 for (i = 0; i < nb_domain; i++) {
2349 switch (domains[i].type) {
2350 case LTTNG_DOMAIN_KERNEL:
2351 MSG("=== Domain: Kernel ===\n");
2352 break;
2353 case LTTNG_DOMAIN_UST:
2354 MSG("=== Domain: UST global ===\n");
2355 MSG("Buffer type: %s\n",
2356 domains[i].buf_type ==
2357 LTTNG_BUFFER_PER_PID ? "per PID" : "per UID");
2358 break;
2359 case LTTNG_DOMAIN_JUL:
2360 MSG("=== Domain: JUL (Java Util Logging) ===\n");
2361 break;
2362 case LTTNG_DOMAIN_LOG4J:
2363 MSG("=== Domain: LOG4j (Logging for Java) ===\n");
2364 break;
2365 case LTTNG_DOMAIN_PYTHON:
2366 MSG("=== Domain: Python (logging) ===\n");
2367 break;
2368 default:
2369 MSG("=== Domain: Unimplemented ===\n");
2370 break;
2371 }
2372
2373 if (lttng_opt_mi) {
2374 ret = mi_lttng_domain(writer, &domains[i], 1);
2375 if (ret) {
2376 ret = CMD_ERROR;
2377 goto end;
2378 }
2379 }
2380
2381 /* Clean handle before creating a new one */
2382 if (handle) {
2383 lttng_destroy_handle(handle);
2384 }
2385
2386 handle = lttng_create_handle(session_name, &domains[i]);
2387 if (handle == NULL) {
2388 ret = CMD_FATAL;
2389 goto end;
2390 }
2391
2392 if (domains[i].type == LTTNG_DOMAIN_JUL ||
2393 domains[i].type == LTTNG_DOMAIN_LOG4J ||
2394 domains[i].type == LTTNG_DOMAIN_PYTHON) {
2395 ret = list_session_agent_events();
2396 if (ret) {
2397 goto end;
2398 }
2399
2400 goto next_domain;
2401 }
2402
2403 switch (domains[i].type) {
2404 case LTTNG_DOMAIN_KERNEL:
2405 case LTTNG_DOMAIN_UST:
2406 ret = list_trackers(&domains[i]);
2407 if (ret) {
2408 goto end;
2409 }
2410 break;
2411 default:
2412 break;
2413 }
2414
2415 ret = list_channels(opt_channel);
2416 if (ret) {
2417 goto end;
2418 }
2419
2420 next_domain:
2421 if (lttng_opt_mi) {
2422 /* Close domain element */
2423 ret = mi_lttng_writer_close_element(writer);
2424 if (ret) {
2425 ret = CMD_ERROR;
2426 goto end;
2427 }
2428 }
2429
2430 }
2431 if (lttng_opt_mi) {
2432 /* Close the domains, session and sessions element */
2433 ret = mi_lttng_close_multi_element(writer, 3);
2434 if (ret) {
2435 ret = CMD_ERROR;
2436 goto end;
2437 }
2438 }
2439 }
2440 }
2441
2442 /* Mi closing */
2443 if (lttng_opt_mi) {
2444 /* Close output element */
2445 ret = mi_lttng_writer_close_element(writer);
2446 if (ret) {
2447 ret = CMD_ERROR;
2448 goto end;
2449 }
2450
2451 /* Command element close */
2452 ret = mi_lttng_writer_command_close(writer);
2453 if (ret) {
2454 ret = CMD_ERROR;
2455 goto end;
2456 }
2457 }
2458 end:
2459 /* Mi clean-up */
2460 if (writer && mi_lttng_writer_destroy(writer)) {
2461 /* Preserve original error code */
2462 ret = ret ? ret : -LTTNG_ERR_MI_IO_FAIL;
2463 }
2464
2465 free(domains);
2466 if (handle) {
2467 lttng_destroy_handle(handle);
2468 }
2469
2470 poptFreeContext(pc);
2471 return ret;
2472 }
This page took 0.117806 seconds and 5 git commands to generate.