6f9c65ac6a61100436c74b768359ed5a2c781d93
[lttngtop.git] / src / lttngtop.c
1 /*
2 * Copyright (C) 2013 Julien Desfossez
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 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #define _GNU_SOURCE
19 #include <config.h>
20 #include <stdio.h>
21 #include <stdint.h>
22 #include <babeltrace/babeltrace.h>
23 #include <babeltrace/ctf/events.h>
24 #include <babeltrace/ctf/callbacks.h>
25 #include <babeltrace/ctf/iterator.h>
26 #include <fcntl.h>
27 #include <pthread.h>
28 #include <popt.h>
29 #include <stdlib.h>
30 #include <ftw.h>
31 #include <dirent.h>
32 #include <ctype.h>
33 #include <sys/stat.h>
34 #include <unistd.h>
35 #include <string.h>
36 #include <errno.h>
37 #include <sys/types.h>
38 #include <fts.h>
39 #include <assert.h>
40 #include <sys/mman.h>
41 #include <sys/wait.h>
42 #include <lttng/lttng.h>
43
44 #ifdef LTTNGTOP_MMAP_LIVE
45 #include <lttng/lttngtop-helper.h>
46 #include <babeltrace/lttngtopmmappacketseek.h>
47 #include "mmap-live.h"
48 #endif /* LTTNGTOP_MMAP_LIVE */
49
50 #include "lttngtoptypes.h"
51 #include "cputop.h"
52 #include "iostreamtop.h"
53 #include "common.h"
54 #include "network-live.h"
55 #include "lttng-session.h"
56
57 #ifdef HAVE_LIBNCURSES
58 #include "cursesdisplay.h"
59 #endif
60
61 #define NET_URL_PREFIX "net://"
62 #define NET4_URL_PREFIX "net4://"
63 #define NET6_URL_PREFIX "net6://"
64
65 #define DEFAULT_FILE_ARRAY_SIZE 1
66
67 const char *opt_input_path;
68 int opt_textdump;
69 int opt_child;
70 int opt_begin;
71 int opt_all;
72
73 int quit = 0;
74 /* We need at least one valid trace to start processing. */
75 int valid_trace = 0;
76
77 struct lttngtop *copy;
78 pthread_t display_thread;
79 pthread_t timer_thread;
80
81 unsigned long refresh_display = 1 * NSEC_PER_SEC;
82 unsigned long last_display_update = 0;
83 unsigned long last_event_ts = 0;
84 struct syscall *last_syscall;
85
86 /* list of FDs available for being read with snapshots */
87 struct bt_mmap_stream_list mmap_list;
88 GPtrArray *lttng_consumer_stream_array;
89 int sessiond_metadata, consumerd_metadata;
90 struct lttng_consumer_local_data *ctx = NULL;
91 /* list of snapshots currently not consumed */
92 GPtrArray *available_snapshots;
93 sem_t metadata_available;
94 int reload_trace = 0;
95
96 uint64_t prev_ts = 0;
97
98 enum {
99 OPT_NONE = 0,
100 OPT_HELP,
101 OPT_TEXTDUMP,
102 OPT_PID,
103 OPT_CHILD,
104 OPT_PROCNAME,
105 OPT_RELAY_HOSTNAME,
106 OPT_KPROBES,
107 OPT_BEGIN,
108 OPT_ALL,
109 OPT_OUTPUT_FILE,
110 OPT_VERBOSE,
111 OPT_GUI_TEST,
112 OPT_CREATE_LOCAL_SESSION,
113 OPT_CREATE_LIVE_SESSION,
114 };
115
116 static struct poptOption long_options[] = {
117 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
118 { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
119 { "textdump", 't', POPT_ARG_NONE, NULL, OPT_TEXTDUMP, NULL, NULL },
120 { "child", 'f', POPT_ARG_NONE, NULL, OPT_CHILD, NULL, NULL },
121 { "begin", 'b', POPT_ARG_NONE, NULL, OPT_BEGIN, NULL, NULL },
122 { "pid", 'p', POPT_ARG_STRING, &opt_tid, OPT_PID, NULL, NULL },
123 { "procname", 'n', POPT_ARG_STRING, &opt_procname, OPT_PROCNAME, NULL, NULL },
124 { "relay-hostname", 'r', POPT_ARG_STRING, &opt_relay_hostname,
125 OPT_RELAY_HOSTNAME, NULL, NULL },
126 { "kprobes", 'k', POPT_ARG_STRING, &opt_kprobes, OPT_KPROBES, NULL, NULL },
127 { "all", 'a', POPT_ARG_NONE, NULL, OPT_ALL, NULL, NULL },
128 { "output", 'o', POPT_ARG_STRING, &opt_output, OPT_OUTPUT_FILE, NULL, NULL },
129 { "verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, NULL, NULL },
130 { "gui-test", 'g', POPT_ARG_NONE, NULL, OPT_GUI_TEST, NULL, NULL },
131 { "create-local-session", 0, POPT_ARG_NONE, NULL, OPT_CREATE_LOCAL_SESSION, NULL, NULL },
132 { "create-live-session", 0, POPT_ARG_NONE, NULL, OPT_CREATE_LIVE_SESSION, NULL, NULL },
133 { NULL, 0, 0, NULL, 0, NULL, NULL },
134 };
135
136 #ifdef LTTNGTOP_MMAP_LIVE
137 static void handle_textdump_sigterm(int signal)
138 {
139 quit = 1;
140 lttng_destroy_session("test");
141 }
142 #endif
143
144 void *refresh_thread(void *p)
145 {
146 while (1) {
147 if (quit) {
148 sem_post(&pause_sem);
149 sem_post(&timer);
150 sem_post(&end_trace_sem);
151 sem_post(&goodtodisplay);
152 sem_post(&goodtoupdate);
153 pthread_exit(0);
154 }
155 if (!opt_input_path) {
156 #ifdef LTTNGTOP_MMAP_LIVE
157 mmap_live_flush(mmap_list);
158 #endif
159 }
160 sem_wait(&pause_sem);
161 sem_post(&pause_sem);
162 sem_post(&timer);
163 sleep(refresh_display/NSEC_PER_SEC);
164 }
165 }
166
167 #ifdef HAVE_LIBNCURSES
168 void *ncurses_display(void *p)
169 {
170 unsigned int current_display_index = 0;
171
172 sem_wait(&bootstrap);
173 /*
174 * Prevent the 1 second delay when we hit ESC
175 */
176 ESCDELAY = 0;
177 init_ncurses();
178
179 while (1) {
180 sem_wait(&timer);
181 sem_wait(&goodtodisplay);
182 sem_wait(&pause_sem);
183
184 if (quit) {
185 sem_post(&pause_sem);
186 sem_post(&timer);
187 reset_ncurses();
188 pthread_exit(0);
189 }
190
191 copy = g_ptr_array_index(copies, current_display_index);
192 assert(copy);
193 display(current_display_index++);
194
195 sem_post(&goodtoupdate);
196 sem_post(&pause_sem);
197 }
198 }
199 #endif /* HAVE_LIBNCURSES */
200
201 void print_fields(struct bt_ctf_event *event, const char *procname,
202 int pid)
203 {
204 unsigned int cnt, i;
205 const struct bt_definition *const * list;
206 const struct bt_declaration *l;
207 const struct bt_definition *scope;
208 enum ctf_type_id type;
209 const char *str;
210 struct processtop *current_proc;
211 struct files *current_file;
212 int fd, fd_value = -1;
213
214 scope = bt_ctf_get_top_level_scope(event, BT_EVENT_FIELDS);
215
216 bt_ctf_get_field_list(event, scope, &list, &cnt);
217 for (i = 0; i < cnt; i++) {
218 if (i != 0)
219 fprintf(output, ", ");
220 fprintf(output, "%s = ", bt_ctf_field_name(list[i]));
221 l = bt_ctf_get_decl_from_def(list[i]);
222 if (strncmp(bt_ctf_field_name(list[i]), "fd", 2) == 0)
223 fd = 1;
224 else
225 fd = 0;
226 type = bt_ctf_field_type(l);
227 if (type == CTF_TYPE_INTEGER) {
228 if (bt_ctf_get_int_signedness(l) == 0) {
229 fd_value = bt_ctf_get_uint64(list[i]);
230 fprintf(output, "%" PRIu64, bt_ctf_get_uint64(list[i]));
231 } else {
232 fd_value = bt_ctf_get_int64(list[i]);
233 fprintf(output, "%" PRId64, bt_ctf_get_int64(list[i]));
234 }
235 } else if (type == CTF_TYPE_STRING) {
236 fprintf(output, "%s", bt_ctf_get_string(list[i]));
237 } else if (type == CTF_TYPE_ARRAY) {
238 str = bt_ctf_get_char_array(list[i]);
239 if (!bt_ctf_field_get_error() && str)
240 fprintf(output, "%s", str);
241 }
242 if (fd) {
243 current_proc = find_process_tid(&lttngtop, pid, procname);
244 if (!current_proc)
245 continue;
246 current_file = get_file(current_proc, fd_value);
247 if (!current_file || !current_file->name)
248 continue;
249 fprintf(output, "<%s>", current_file->name);
250 }
251 }
252 }
253
254 /*
255 * hook on each event to check the timestamp and refresh the display if
256 * necessary
257 */
258 enum bt_cb_ret textdump(struct bt_ctf_event *call_data, void *private_data)
259 {
260 unsigned long timestamp;
261 uint64_t delta;
262 struct tm start;
263 uint64_t ts_nsec_start;
264 int pid, cpu_id, tid, ret, lookup, current_syscall = 0;
265 const struct bt_definition *scope;
266 const char *hostname, *procname;
267 struct cputime *cpu;
268 char *from_syscall = NULL;
269
270 timestamp = bt_ctf_get_timestamp(call_data);
271
272 /* can happen in network live when tracing is idle */
273 if (timestamp < last_event_ts)
274 goto end_stop;
275
276 last_event_ts = timestamp;
277
278 start = format_timestamp(timestamp);
279 ts_nsec_start = timestamp % NSEC_PER_SEC;
280
281 pid = get_context_pid(call_data);
282 if (pid == -1ULL && opt_tid) {
283 goto error;
284 }
285
286 tid = get_context_tid(call_data);
287
288 hostname = get_context_hostname(call_data);
289 if (opt_child)
290 lookup = pid;
291 else
292 lookup = tid;
293 if (opt_tid || opt_procname || opt_exec_name) {
294 if (!lookup_filter_tid_list(lookup)) {
295 /* To display when a process of ours in getting scheduled in */
296 if (strcmp(bt_ctf_event_name(call_data), "sched_switch") == 0) {
297 int next_tid;
298
299 scope = bt_ctf_get_top_level_scope(call_data,
300 BT_EVENT_FIELDS);
301 next_tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
302 scope, "_next_tid"));
303 if (bt_ctf_field_get_error()) {
304 fprintf(stderr, "Missing next_tid field\n");
305 goto error;
306 }
307 if (!lookup_filter_tid_list(next_tid)) {
308 if (!opt_all)
309 goto end;
310 } else {
311 if (opt_all)
312 fprintf(output, "%c[1m", 27);
313 }
314 } else if (!opt_all) {
315 goto end;
316 }
317 } else {
318 if (opt_all)
319 fprintf(output, "%c[1m", 27);
320 }
321 }
322
323 if (last_syscall && (strncmp(bt_ctf_event_name(call_data),
324 "exit_syscall", 12)) != 0) {
325 last_syscall = NULL;
326 fprintf(output, " ...interrupted...\n");
327 }
328
329 cpu_id = get_cpu_id(call_data);
330 procname = get_context_comm(call_data);
331 if (strncmp(bt_ctf_event_name(call_data), "sys", 3) == 0) {
332 cpu = get_cpu(cpu_id);
333 cpu->current_syscall = g_new0(struct syscall, 1);
334 cpu->current_syscall->name = strdup(bt_ctf_event_name(call_data));
335 cpu->current_syscall->ts_start = timestamp;
336 cpu->current_syscall->cpu_id = cpu_id;
337 last_syscall = cpu->current_syscall;
338 current_syscall = 1;
339 } else if ((strncmp(bt_ctf_event_name(call_data), "exit_syscall", 12)) == 0) {
340 struct tm start_ts;
341
342 /* Return code of a syscall if it was the last displayed event. */
343 if (last_syscall && last_syscall->ts_start == prev_ts) {
344 if (last_syscall->cpu_id == cpu_id) {
345 int64_t syscall_ret;
346
347 delta = timestamp - last_syscall->ts_start;
348 scope = bt_ctf_get_top_level_scope(call_data,
349 BT_EVENT_FIELDS);
350 syscall_ret = bt_ctf_get_int64(bt_ctf_get_field(call_data,
351 scope, "_ret"));
352
353 fprintf(output, "= %" PRId64 " (%" PRIu64 ".%09" PRIu64 "s)\n",
354 syscall_ret, delta / NSEC_PER_SEC,
355 delta % NSEC_PER_SEC);
356 last_syscall = NULL;
357 goto end;
358 } else {
359 last_syscall = NULL;
360 fprintf(output, " ...interrupted...\n");
361 }
362 }
363
364 cpu = get_cpu(cpu_id);
365 if (cpu->current_syscall) {
366 delta = timestamp - cpu->current_syscall->ts_start;
367 start_ts = format_timestamp(cpu->current_syscall->ts_start);
368 ret = asprintf(&from_syscall, " [from %02d:%02d:%02d.%09" PRIu64
369 " (+%" PRIu64 ".%09" PRIu64 ") (cpu %d) %s]",
370 start_ts.tm_hour, start_ts.tm_min, start_ts.tm_sec,
371 cpu->current_syscall->ts_start % NSEC_PER_SEC,
372 delta / NSEC_PER_SEC, delta % NSEC_PER_SEC,
373 cpu_id, cpu->current_syscall->name);
374 if (ret < 0) {
375 goto error;
376 }
377 free(cpu->current_syscall->name);
378 g_free(cpu->current_syscall);
379 cpu->current_syscall = NULL;
380 last_syscall = NULL;
381 }
382 }
383
384 if (prev_ts == 0)
385 prev_ts = timestamp;
386 delta = timestamp - prev_ts;
387 prev_ts = timestamp;
388
389 fprintf(output, "%02d:%02d:%02d.%09" PRIu64 " (+%" PRIu64 ".%09" PRIu64 ") %s%s"
390 "(cpu %d) [%s (%d/%d)] %s (",
391 start.tm_hour, start.tm_min, start.tm_sec,
392 ts_nsec_start, delta / NSEC_PER_SEC,
393 delta % NSEC_PER_SEC, (hostname) ? hostname : "",
394 (hostname) ? " ": "", cpu_id, procname, pid, tid,
395 bt_ctf_event_name(call_data));
396 print_fields(call_data, procname, pid);
397 fprintf(output, ")%s%c", (from_syscall) ? from_syscall : "",
398 (!current_syscall) ? '\n' : ' ');
399
400 free(from_syscall);
401 if (opt_all && (opt_tid || opt_procname || opt_exec_name))
402 fprintf(output, "%c[0m", 27);
403
404 end:
405 return BT_CB_OK;
406 error:
407 return BT_CB_ERROR_STOP;
408 end_stop:
409 return BT_CB_OK_STOP;
410 }
411
412 enum bt_cb_ret handle_kprobes(struct bt_ctf_event *call_data, void *private_data)
413 {
414 int i;
415 struct kprobes *kprobe;
416
417 /* for kprobes */
418 for (i = 0; i < lttngtop.kprobes_table->len; i++) {
419 kprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
420 if (strcmp(bt_ctf_event_name(call_data), kprobe->probe_name) == 0) {
421 kprobe->count++;
422 }
423 }
424
425 return BT_CB_OK;
426 }
427
428 /*
429 * hook on each event to check the timestamp and refresh the display if
430 * necessary
431 */
432 enum bt_cb_ret check_timestamp(struct bt_ctf_event *call_data, void *private_data)
433 {
434 unsigned long timestamp;
435
436 timestamp = bt_ctf_get_timestamp(call_data);
437 if (timestamp == -1ULL)
438 goto error;
439
440 /* can happen in network live when tracing is idle */
441 if (timestamp < last_event_ts)
442 goto end_stop;
443
444 last_event_ts = timestamp;
445
446 if (last_display_update == 0)
447 last_display_update = timestamp;
448
449 if (timestamp - last_display_update >= refresh_display) {
450 sem_wait(&goodtoupdate);
451 g_ptr_array_add(copies, get_copy_lttngtop(last_display_update,
452 timestamp));
453 sem_post(&goodtodisplay);
454 sem_post(&bootstrap);
455 last_display_update = timestamp;
456 }
457 return BT_CB_OK;
458
459 error:
460 fprintf(stderr, "check_timestamp callback error\n");
461 return BT_CB_ERROR_STOP;
462
463 end_stop:
464 return BT_CB_OK_STOP;
465 }
466
467 /*
468 * get_perf_counter : get or create and return a perf_counter struct for
469 * either a process or a cpu (only one of the 2 parameters mandatory)
470 */
471 struct perfcounter *get_perf_counter(const char *name, struct processtop *proc,
472 struct cputime *cpu)
473 {
474 struct perfcounter *ret;
475 GHashTable *table;
476
477 if (proc)
478 table = proc->perf;
479 else if (cpu)
480 table = cpu->perf;
481 else
482 goto error;
483
484 ret = g_hash_table_lookup(table, (gpointer) name);
485 if (ret)
486 goto end;
487
488 ret = g_new0(struct perfcounter, 1);
489 /* by default, make it visible in the UI */
490 ret->visible = 1;
491 g_hash_table_insert(table, (gpointer) strdup(name), ret);
492
493 end:
494 return ret;
495
496 error:
497 return NULL;
498 }
499
500 void update_perf_value(struct processtop *proc, struct cputime *cpu,
501 const char *name, int value)
502 {
503 struct perfcounter *cpu_perf, *process_perf;
504
505 cpu_perf = get_perf_counter(name, NULL, cpu);
506 if (cpu_perf->count < value) {
507 process_perf = get_perf_counter(name, proc, NULL);
508 process_perf->count += value - cpu_perf->count;
509 cpu_perf->count = value;
510 }
511 }
512
513 void extract_perf_counter_scope(const struct bt_ctf_event *event,
514 const struct bt_definition *scope,
515 struct processtop *proc,
516 struct cputime *cpu)
517 {
518 struct bt_definition const * const *list = NULL;
519 const struct bt_definition *field;
520 unsigned int count;
521 struct perfcounter *perfcounter;
522 GHashTableIter iter;
523 gpointer key;
524 int ret;
525
526 if (!scope)
527 goto end;
528
529 ret = bt_ctf_get_field_list(event, scope, &list, &count);
530 if (ret < 0)
531 goto end;
532
533 if (count == 0)
534 goto end;
535
536 g_hash_table_iter_init(&iter, global_perf_liszt);
537 while (g_hash_table_iter_next (&iter, &key, (gpointer) &perfcounter)) {
538 field = bt_ctf_get_field(event, scope, (char *) key);
539 if (field) {
540 int value = bt_ctf_get_uint64(field);
541 if (bt_ctf_field_get_error())
542 continue;
543 update_perf_value(proc, cpu, (char *) key, value);
544 }
545 }
546
547 end:
548 return;
549 }
550
551 void update_perf_counter(struct processtop *proc, const struct bt_ctf_event *event)
552 {
553 struct cputime *cpu;
554 const struct bt_definition *scope;
555
556 cpu = get_cpu(get_cpu_id(event));
557
558 scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
559 extract_perf_counter_scope(event, scope, proc, cpu);
560
561 scope = bt_ctf_get_top_level_scope(event, BT_STREAM_PACKET_CONTEXT);
562 extract_perf_counter_scope(event, scope, proc, cpu);
563
564 scope = bt_ctf_get_top_level_scope(event, BT_EVENT_CONTEXT);
565 extract_perf_counter_scope(event, scope, proc, cpu);
566 }
567
568 enum bt_cb_ret fix_process_table(struct bt_ctf_event *call_data,
569 void *private_data)
570 {
571 int pid, tid, ppid, vpid, vtid, vppid;
572 char *comm, *hostname;
573 struct processtop *parent, *child;
574 unsigned long timestamp;
575
576 timestamp = bt_ctf_get_timestamp(call_data);
577 if (timestamp == -1ULL)
578 goto error;
579
580 pid = get_context_pid(call_data);
581 if (pid == -1ULL) {
582 goto error;
583 }
584
585 tid = get_context_tid(call_data);
586 if (tid == -1ULL) {
587 goto error;
588 }
589 ppid = get_context_ppid(call_data);
590 if (ppid == -1ULL) {
591 goto end;
592 }
593 vpid = get_context_vpid(call_data);
594 if (pid == -1ULL) {
595 vpid = -1;
596 }
597 vtid = get_context_vtid(call_data);
598 if (tid == -1ULL) {
599 vtid = -1;
600 }
601 vppid = get_context_vppid(call_data);
602 if (ppid == -1ULL) {
603 vppid = -1;
604 }
605 comm = get_context_comm(call_data);
606 if (!comm) {
607 goto error;
608 }
609 /* optional */
610 hostname = get_context_hostname(call_data);
611
612 /* find or create the current process */
613 child = find_process_tid(&lttngtop, tid, comm);
614 if (!child)
615 child = add_proc(&lttngtop, tid, comm, timestamp, hostname);
616 if (!child)
617 goto end;
618 update_proc(child, pid, tid, ppid, vpid, vtid, vppid, comm, hostname);
619
620 if (opt_procname && lookup_procname(comm) &&
621 !lookup_filter_tid_list(tid)) {
622 int *tmp_tid;
623
624 tmp_tid = malloc(sizeof(int));
625 *tmp_tid = tid;
626 printf("ADDING %s %d\n", comm, tid);
627 g_hash_table_insert(global_filter_list,
628 (gpointer) tmp_tid, tmp_tid);
629 }
630
631 if (pid != tid) {
632 /* find or create the parent */
633 parent = find_process_tid(&lttngtop, pid, comm);
634 if (!parent) {
635 parent = add_proc(&lttngtop, pid, comm, timestamp, hostname);
636 if (parent)
637 parent->pid = pid;
638 }
639
640 /* attach the parent to the current process */
641 child->threadparent = parent;
642 add_thread(parent, child);
643 }
644
645 update_perf_counter(child, call_data);
646
647 end:
648 return BT_CB_OK;
649
650 error:
651 return BT_CB_ERROR_STOP;
652 }
653
654 void init_lttngtop()
655 {
656 copies = g_ptr_array_new();
657 global_perf_liszt = g_hash_table_new(g_str_hash, g_str_equal);
658 global_filter_list = g_hash_table_new(g_str_hash, g_str_equal);
659 global_host_list = g_hash_table_new(g_str_hash, g_str_equal);
660 global_procname_list = g_hash_table_new(g_str_hash, g_str_equal);
661 tid_filter_list = g_hash_table_new(g_str_hash,
662 g_str_equal);
663
664 sem_init(&goodtodisplay, 0, 0);
665 sem_init(&goodtoupdate, 0, 1);
666 sem_init(&timer, 0, 1);
667 sem_init(&bootstrap, 0, 0);
668 sem_init(&pause_sem, 0, 1);
669 sem_init(&end_trace_sem, 0, 0);
670
671 reset_global_counters();
672 lttngtop.nbproc = 0;
673 lttngtop.nbthreads = 0;
674 lttngtop.nbfiles = 0;
675
676 lttngtop.process_hash_table = g_hash_table_new(g_direct_hash,
677 g_direct_equal);
678 lttngtop.process_table = g_ptr_array_new();
679 lttngtop.files_table = g_ptr_array_new();
680 lttngtop.cpu_table = g_ptr_array_new();
681
682 toggle_filter = -1;
683 }
684
685 void usage(FILE *fp)
686 {
687 fprintf(fp, "LTTngTop %s\n\n", VERSION);
688 fprintf(fp, "Usage : lttngtop [OPTIONS] TRACE\n");
689 fprintf(fp, " TRACE Path to the trace to analyse (-r for network live tracing, nothing for mmap live streaming)\n");
690 fprintf(fp, " -h, --help This help message\n");
691 fprintf(fp, " -t, --textdump Display live events in text-only\n");
692 fprintf(fp, " -p, --pid Comma-separated list of PIDs to display\n");
693 fprintf(fp, " -f, --child Follow threads associated with selected PIDs\n");
694 fprintf(fp, " -n, --procname Comma-separated list of procnames to display (require procname context in trace)\n");
695 fprintf(fp, " -a, --all In textdump mode, display all events but write in bold the processes we are interested in (-f, -p and -n)\n");
696 fprintf(fp, " -k, --kprobes Comma-separated list of kprobes to insert (same format as lttng enable-event)\n");
697 fprintf(fp, " -r, --relay-hostname Network live streaming : hostname of the lttng-relayd (default port)\n");
698 fprintf(fp, " -b, --begin Network live streaming : read the trace for the beginning of the recording\n");
699 fprintf(fp, " -o, --output <filename> In textdump, output the log in <filename>\n");
700 fprintf(fp, " -g, --gui-test Test if the ncurses support is compiled in (return 0 if it is)\n");
701 fprintf(fp, " --create-local-session Setup a LTTng local session with all the right parameters\n");
702 fprintf(fp, " --create-live-session Setup a LTTng live session on localhost with all the right parameters\n");
703 }
704
705 /*
706 * Parse probe options.
707 * Shamelessly stolen from lttng-tools :
708 * src/bin/lttng/commands/enable_events.c
709 */
710 static struct kprobes *parse_probe_opts(char *opt)
711 {
712 char s_hex[19];
713 char name[LTTNG_SYMBOL_NAME_LEN];
714 struct kprobes *kprobe;
715 int ret;
716
717 /*
718 kprobe->probe_addr = 0;
719 kprobe->probe_offset = 0;
720 asprintf(&kprobe->probe_name, "probe_sys_open");
721 asprintf(&kprobe->symbol_name, "sys_open");
722 */
723
724 if (opt == NULL) {
725 kprobe = NULL;
726 goto end;
727 }
728
729 kprobe = g_new0(struct kprobes, 1);
730
731 /* Check for symbol+offset */
732 ret = sscanf(opt, "%[^'+']+%s", name, s_hex);
733 if (ret == 2) {
734 ret = asprintf(&kprobe->probe_name, "probe_%s", name);
735 ret = asprintf(&kprobe->symbol_name, "%s", name);
736
737 if (strlen(s_hex) == 0) {
738 fprintf(stderr, "Invalid probe offset %s", s_hex);
739 ret = -1;
740 goto end;
741 }
742 kprobe->probe_offset = strtoul(s_hex, NULL, 0);
743 kprobe->probe_addr = 0;
744 goto end;
745 }
746
747 /* Check for symbol */
748 if (isalpha(name[0])) {
749 ret = sscanf(opt, "%s", name);
750 if (ret == 1) {
751 ret = asprintf(&kprobe->probe_name, "probe_%s", name);
752 ret = asprintf(&kprobe->symbol_name, "%s", name);
753 kprobe->probe_offset = 0;
754 kprobe->probe_addr = 0;
755 goto end;
756 }
757 }
758
759 /* Check for address */
760 ret = sscanf(opt, "%s", s_hex);
761 if (ret > 0) {
762 if (strlen(s_hex) == 0) {
763 fprintf(stderr, "Invalid probe address %s", s_hex);
764 ret = -1;
765 goto end;
766 }
767 ret = asprintf(&kprobe->probe_name, "probe_%s", s_hex);
768 kprobe->probe_offset = 0;
769 kprobe->probe_addr = strtoul(s_hex, NULL, 0);
770 goto end;
771 }
772
773 /* No match */
774 kprobe = NULL;
775
776 end:
777 return kprobe;
778 }
779
780 /*
781 * Return 0 if caller should continue, < 0 if caller should return
782 * error, > 0 if caller should exit without reporting error.
783 */
784 static int parse_options(int argc, char **argv)
785 {
786 poptContext pc;
787 int opt, ret = 0;
788 char *tmp_str;
789 int *tid;
790 int i;
791
792 remote_live = 0;
793
794 pc = poptGetContext(NULL, argc, (const char **) argv, long_options, 0);
795 poptReadDefaultConfig(pc, 0);
796
797 while ((opt = poptGetNextOpt(pc)) != -1) {
798 switch (opt) {
799 case OPT_HELP:
800 usage(stdout);
801 ret = 1; /* exit cleanly */
802 goto end;
803 case OPT_GUI_TEST:
804 #ifdef HAVE_LIBNCURSES
805 exit(EXIT_SUCCESS);
806 #else
807 exit(EXIT_FAILURE);
808 #endif
809 goto end;
810 case OPT_CREATE_LOCAL_SESSION:
811 ret = create_local_session();
812 exit(ret);
813 case OPT_CREATE_LIVE_SESSION:
814 ret = create_live_local_session(NULL, NULL, 1);
815 exit(ret);
816 case OPT_TEXTDUMP:
817 opt_textdump = 1;
818 break;
819 case OPT_ALL:
820 opt_all = 1;
821 break;
822 case OPT_CHILD:
823 opt_child = 1;
824 break;
825 case OPT_PID:
826 toggle_filter = 1;
827 tmp_str = strtok(opt_tid, ",");
828 while (tmp_str) {
829 tid = malloc(sizeof(int));
830 *tid = atoi(tmp_str);
831 g_hash_table_insert(tid_filter_list,
832 (gpointer) tid, tid);
833 tmp_str = strtok(NULL, ",");
834 }
835 break;
836 case OPT_BEGIN:
837 /* start reading the live trace from the beginning */
838 opt_begin = 1;
839 break;
840 case OPT_PROCNAME:
841 toggle_filter = 1;
842 tmp_str = strtok(opt_procname, ",");
843 while (tmp_str) {
844 add_procname_list(tmp_str, 1);
845 tmp_str = strtok(NULL, ",");
846 }
847 break;
848 case OPT_RELAY_HOSTNAME:
849 remote_live = 1;
850 break;
851 case OPT_KPROBES:
852 lttngtop.kprobes_table = g_ptr_array_new();
853 tmp_str = strtok(opt_kprobes, ",");
854 while (tmp_str) {
855 struct kprobes *kprobe;
856
857 kprobe = parse_probe_opts(tmp_str);
858 if (kprobe) {
859 g_ptr_array_add(
860 lttngtop.kprobes_table,
861 kprobe);
862 } else {
863 ret = -EINVAL;
864 goto end;
865 }
866 tmp_str = strtok(NULL, ",");
867 }
868 break;
869 case OPT_OUTPUT_FILE:
870 break;
871 case OPT_VERBOSE:
872 babeltrace_verbose = 1;
873 break;
874 default:
875 ret = -EINVAL;
876 goto end;
877 }
878 }
879
880 opt_exec_name = NULL;
881 opt_exec_argv = NULL;
882 for (i = 0; i < argc; i++) {
883 if (argv[i][0] == '-' && argv[i][1] == '-') {
884 opt_exec_name = argv[i + 1];
885 opt_exec_argv = &argv[i + 1];
886 break;
887 }
888 }
889 if (!opt_exec_name) {
890 opt_input_path = poptGetArg(pc);
891 }
892 if (!opt_output) {
893 opt_output = strdup("/dev/stdout");
894 }
895 output = fopen(opt_output, "w");
896 if (!output) {
897 perror("Error opening output file");
898 ret = -1;
899 goto end;
900 }
901
902 end:
903 if (pc) {
904 poptFreeContext(pc);
905 }
906 return ret;
907 }
908
909 void iter_trace(struct bt_context *bt_ctx)
910 {
911 struct bt_ctf_iter *iter;
912 struct bt_iter_pos begin_pos;
913 struct kprobes *kprobe;
914 const struct bt_ctf_event *event;
915 int i;
916 int ret = 0;
917
918 begin_pos.type = BT_SEEK_BEGIN;
919 iter = bt_ctf_iter_create(bt_ctx, &begin_pos, NULL);
920
921 /* at each event, verify the status of the process table */
922 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
923 fix_process_table,
924 NULL, NULL, NULL);
925 /* to handle the follow child option */
926 bt_ctf_iter_add_callback(iter,
927 g_quark_from_static_string("sched_process_fork"),
928 NULL, 0, handle_sched_process_fork, NULL, NULL, NULL);
929 /* to clean up the process table */
930 bt_ctf_iter_add_callback(iter,
931 g_quark_from_static_string("sched_process_free"),
932 NULL, 0, handle_sched_process_free, NULL, NULL, NULL);
933 /* to get all the process from the statedumps */
934 bt_ctf_iter_add_callback(iter,
935 g_quark_from_static_string(
936 "lttng_statedump_process_state"),
937 NULL, 0, handle_statedump_process_state,
938 NULL, NULL, NULL);
939 bt_ctf_iter_add_callback(iter,
940 g_quark_from_static_string(
941 "lttng_statedump_file_descriptor"),
942 NULL, 0, handle_statedump_file_descriptor,
943 NULL, NULL, NULL);
944 bt_ctf_iter_add_callback(iter,
945 g_quark_from_static_string("sys_open"),
946 NULL, 0, handle_sys_open, NULL, NULL, NULL);
947 bt_ctf_iter_add_callback(iter,
948 g_quark_from_static_string("syscall_entry_open"),
949 NULL, 0, handle_sys_open, NULL, NULL, NULL);
950
951 bt_ctf_iter_add_callback(iter,
952 g_quark_from_static_string("sys_socket"),
953 NULL, 0, handle_sys_socket, NULL, NULL, NULL);
954 bt_ctf_iter_add_callback(iter,
955 g_quark_from_static_string("syscall_entry_socket"),
956 NULL, 0, handle_sys_socket, NULL, NULL, NULL);
957
958 bt_ctf_iter_add_callback(iter,
959 g_quark_from_static_string("sys_close"),
960 NULL, 0, handle_sys_close, NULL, NULL, NULL);
961 bt_ctf_iter_add_callback(iter,
962 g_quark_from_static_string("syscall_entry_close"),
963 NULL, 0, handle_sys_close, NULL, NULL, NULL);
964
965 bt_ctf_iter_add_callback(iter,
966 g_quark_from_static_string("exit_syscall"),
967 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
968 bt_ctf_iter_add_callback(iter,
969 g_quark_from_static_string("syscall_exit_open"),
970 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
971 bt_ctf_iter_add_callback(iter,
972 g_quark_from_static_string("syscall_exit_socket"),
973 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
974 bt_ctf_iter_add_callback(iter,
975 g_quark_from_static_string("syscall_exit_close"),
976 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
977 if (opt_textdump) {
978 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
979 textdump,
980 NULL, NULL, NULL);
981 } else {
982 /* at each event check if we need to refresh */
983 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
984 check_timestamp,
985 NULL, NULL, NULL);
986 /* to handle the scheduling events */
987 bt_ctf_iter_add_callback(iter,
988 g_quark_from_static_string("sched_switch"),
989 NULL, 0, handle_sched_switch, NULL, NULL, NULL);
990 /* for IO top */
991 bt_ctf_iter_add_callback(iter,
992 g_quark_from_static_string("sys_write"),
993 NULL, 0, handle_sys_write, NULL, NULL, NULL);
994 bt_ctf_iter_add_callback(iter,
995 g_quark_from_static_string("syscall_entry_write"),
996 NULL, 0, handle_sys_write, NULL, NULL, NULL);
997 bt_ctf_iter_add_callback(iter,
998 g_quark_from_static_string("syscall_exit_write"),
999 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
1000
1001 bt_ctf_iter_add_callback(iter,
1002 g_quark_from_static_string("sys_read"),
1003 NULL, 0, handle_sys_read, NULL, NULL, NULL);
1004 bt_ctf_iter_add_callback(iter,
1005 g_quark_from_static_string("syscall_entry_read"),
1006 NULL, 0, handle_sys_read, NULL, NULL, NULL);
1007 bt_ctf_iter_add_callback(iter,
1008 g_quark_from_static_string("syscall_exit_read"),
1009 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
1010
1011 /* for kprobes */
1012 if (lttngtop.kprobes_table) {
1013 for (i = 0; i < lttngtop.kprobes_table->len; i++) {
1014 kprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
1015 bt_ctf_iter_add_callback(iter,
1016 g_quark_from_static_string(
1017 kprobe->probe_name),
1018 NULL, 0, handle_kprobes,
1019 NULL, NULL, NULL);
1020 }
1021 }
1022 }
1023
1024 if (opt_exec_name) {
1025 pid_t pid;
1026
1027 pid = fork();
1028 if (pid == 0) {
1029 execvpe(opt_exec_name, opt_exec_argv, opt_exec_env);
1030 exit(EXIT_SUCCESS);
1031 } else if (pid > 0) {
1032 opt_exec_pid = pid;
1033 g_hash_table_insert(tid_filter_list,
1034 (gpointer) &pid,
1035 &pid);
1036 } else {
1037 perror("fork");
1038 exit(EXIT_FAILURE);
1039 }
1040 }
1041
1042 while ((event = bt_ctf_iter_read_event(iter)) != NULL) {
1043 if (quit || reload_trace)
1044 goto end_iter;
1045 ret = bt_iter_next(bt_ctf_get_iter(iter));
1046 if (ret < 0)
1047 goto end_iter;
1048 }
1049
1050 /* block until quit, we reached the end of the trace */
1051 sem_wait(&end_trace_sem);
1052
1053 end_iter:
1054 bt_ctf_iter_destroy(iter);
1055 }
1056
1057 /*
1058 * bt_context_add_traces_recursive: Open a trace recursively
1059 * (copied from BSD code in converter/babeltrace.c)
1060 *
1061 * Find each trace present in the subdirectory starting from the given
1062 * path, and add them to the context. The packet_seek parameter can be
1063 * NULL: this specify to use the default format packet_seek.
1064 *
1065 * Return: 0 on success, nonzero on failure.
1066 * Unable to open toplevel: failure.
1067 * Unable to open some subdirectory or file: warn and continue;
1068 */
1069 int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
1070 const char *format_str,
1071 void (*packet_seek)(struct bt_stream_pos *pos,
1072 size_t offset, int whence))
1073 {
1074 FTS *tree;
1075 FTSENT *node;
1076 GArray *trace_ids;
1077 char lpath[PATH_MAX];
1078 char * const paths[2] = { lpath, NULL };
1079 int ret = -1;
1080
1081 if ((strncmp(path, NET4_URL_PREFIX, sizeof(NET4_URL_PREFIX) - 1)) == 0 ||
1082 (strncmp(path, NET6_URL_PREFIX, sizeof(NET6_URL_PREFIX) - 1)) == 0 ||
1083 (strncmp(path, NET_URL_PREFIX, sizeof(NET_URL_PREFIX) - 1)) == 0) {
1084 ret = bt_context_add_trace(ctx,
1085 path, format_str, packet_seek, NULL, NULL);
1086 if (ret < 0) {
1087 fprintf(stderr, "[warning] [Context] cannot open trace \"%s\" "
1088 "for reading.\n", path);
1089 /* Allow to skip erroneous traces. */
1090 ret = 1; /* partial error */
1091 }
1092 return ret;
1093 }
1094 /*
1095 * Need to copy path, because fts_open can change it.
1096 * It is the pointer array, not the strings, that are constant.
1097 */
1098 strncpy(lpath, path, PATH_MAX);
1099 lpath[PATH_MAX - 1] = '\0';
1100
1101 tree = fts_open(paths, FTS_NOCHDIR | FTS_LOGICAL, 0);
1102 if (tree == NULL) {
1103 fprintf(stderr, "[error] [Context] Cannot traverse \"%s\" for reading.\n",
1104 path);
1105 return -EINVAL;
1106 }
1107
1108 trace_ids = g_array_new(FALSE, TRUE, sizeof(int));
1109
1110 while ((node = fts_read(tree))) {
1111 int dirfd, metafd;
1112
1113 if (!(node->fts_info & FTS_D))
1114 continue;
1115
1116 dirfd = open(node->fts_accpath, 0);
1117 if (dirfd < 0) {
1118 fprintf(stderr, "[error] [Context] Unable to open trace "
1119 "directory file descriptor.\n");
1120 ret = dirfd;
1121 goto error;
1122 }
1123 metafd = openat(dirfd, "metadata", O_RDONLY);
1124 if (metafd < 0) {
1125 close(dirfd);
1126 continue;
1127 } else {
1128 int trace_id;
1129
1130 ret = close(metafd);
1131 if (ret < 0) {
1132 perror("close");
1133 goto error;
1134 }
1135 ret = close(dirfd);
1136 if (ret < 0) {
1137 perror("close");
1138 goto error;
1139 }
1140
1141 trace_id = bt_context_add_trace(ctx,
1142 node->fts_accpath, format_str,
1143 packet_seek, NULL, NULL);
1144 if (trace_id < 0) {
1145 fprintf(stderr, "[warning] [Context] opening trace \"%s\" from %s "
1146 "for reading.\n", node->fts_accpath, path);
1147 /* Allow to skip erroneous traces. */
1148 continue;
1149 }
1150 g_array_append_val(trace_ids, trace_id);
1151 }
1152 }
1153
1154 g_array_free(trace_ids, TRUE);
1155 return ret;
1156
1157 error:
1158 return ret;
1159 }
1160
1161 static int check_field_requirements(const struct bt_ctf_field_decl *const * field_list,
1162 int field_cnt, int *tid_check, int *pid_check,
1163 int *procname_check, int *ppid_check)
1164 {
1165 int j;
1166 struct perfcounter *global;
1167 const char *name;
1168
1169 for (j = 0; j < field_cnt; j++) {
1170 name = bt_ctf_get_decl_field_name(field_list[j]);
1171 if (*tid_check == 0) {
1172 if (strncmp(name, "tid", 3) == 0)
1173 (*tid_check)++;
1174 }
1175 if (*pid_check == 0) {
1176 if (strncmp(name, "pid", 3) == 0)
1177 (*pid_check)++;
1178 }
1179 if (*ppid_check == 0) {
1180 if (strncmp(name, "ppid", 4) == 0)
1181 (*ppid_check)++;
1182 }
1183 if (*procname_check == 0) {
1184 if (strncmp(name, "procname", 8) == 0)
1185 (*procname_check)++;
1186 }
1187 if (strncmp(name, "perf_", 5) == 0) {
1188 global = g_hash_table_lookup(global_perf_liszt, (gpointer) name);
1189 if (!global) {
1190 global = g_new0(struct perfcounter, 1);
1191 /* by default, sort on the first perf context */
1192 if (g_hash_table_size(global_perf_liszt) == 0)
1193 global->sort = 1;
1194 global->visible = 1;
1195 g_hash_table_insert(global_perf_liszt, (gpointer) strdup(name), global);
1196 }
1197 }
1198 }
1199
1200 if (*tid_check == 1 && *pid_check == 1 && *ppid_check == 1 &&
1201 *procname_check == 1)
1202 return 0;
1203
1204 return -1;
1205 }
1206
1207 /*
1208 * check_requirements: check if the required context informations are available
1209 *
1210 * If each mandatory context information is available for at least in one
1211 * event, return 0 otherwise return -1.
1212 */
1213 int check_requirements(struct bt_context *ctx)
1214 {
1215 unsigned int i, evt_cnt, field_cnt;
1216 struct bt_ctf_event_decl *const * evt_list;
1217 const struct bt_ctf_field_decl *const * field_list;
1218 int tid_check = 0;
1219 int pid_check = 0;
1220 int procname_check = 0;
1221 int ppid_check = 0;
1222 int ret = 0;
1223
1224 ret = bt_ctf_get_event_decl_list(0, ctx, &evt_list, &evt_cnt);
1225 if (ret < 0) {
1226 goto end;
1227 }
1228
1229 for (i = 0; i < evt_cnt; i++) {
1230 bt_ctf_get_decl_fields(evt_list[i], BT_STREAM_EVENT_CONTEXT,
1231 &field_list, &field_cnt);
1232 ret = check_field_requirements(field_list, field_cnt,
1233 &tid_check, &pid_check, &procname_check,
1234 &ppid_check);
1235
1236 bt_ctf_get_decl_fields(evt_list[i], BT_EVENT_CONTEXT,
1237 &field_list, &field_cnt);
1238 ret = check_field_requirements(field_list, field_cnt,
1239 &tid_check, &pid_check, &procname_check,
1240 &ppid_check);
1241
1242 bt_ctf_get_decl_fields(evt_list[i], BT_STREAM_PACKET_CONTEXT,
1243 &field_list, &field_cnt);
1244 ret = check_field_requirements(field_list, field_cnt,
1245 &tid_check, &pid_check, &procname_check,
1246 &ppid_check);
1247 }
1248
1249 if (tid_check == 0) {
1250 ret = -1;
1251 fprintf(stderr, "[error] missing tid context information\n");
1252 }
1253 if (pid_check == 0) {
1254 ret = -1;
1255 fprintf(stderr, "[error] missing pid context information\n");
1256 }
1257 if (ppid_check == 0) {
1258 ret = -1;
1259 fprintf(stderr, "[error] missing ppid context information\n");
1260 }
1261 if (procname_check == 0) {
1262 ret = -1;
1263 fprintf(stderr, "[error] missing procname context information\n");
1264 }
1265 if (ret == 0) {
1266 valid_trace = 1;
1267 }
1268
1269 end:
1270 return ret;
1271 }
1272
1273 static void handle_sigchild(int signal)
1274 {
1275 int status;
1276
1277 waitpid(opt_exec_pid, &status, 0);
1278 }
1279
1280 int main(int argc, char **argv, char **envp)
1281 {
1282 int ret;
1283 struct bt_context *bt_ctx = NULL;
1284 char *live_session_name = NULL;
1285
1286 init_lttngtop();
1287 ret = parse_options(argc, argv);
1288 if (ret < 0) {
1289 fprintf(stdout, "Error parsing options.\n\n");
1290 usage(stdout);
1291 exit(EXIT_FAILURE);
1292 } else if (ret > 0) {
1293 exit(EXIT_SUCCESS);
1294 }
1295
1296 if (opt_exec_name) {
1297 opt_exec_env = envp;
1298 signal(SIGCHLD, handle_sigchild);
1299 }
1300
1301 if (!opt_input_path && !remote_live && !opt_exec_name) {
1302 /* mmap live */
1303 ret = create_live_local_session(&opt_relay_hostname,
1304 &live_session_name, 0);
1305 if (ret < 0)
1306 goto end;
1307 remote_live = 1;
1308 }
1309 if (!opt_input_path && remote_live) {
1310 /* network live */
1311 bt_ctx = bt_context_create();
1312 ret = bt_context_add_traces_recursive(bt_ctx, opt_relay_hostname,
1313 "lttng-live", NULL);
1314 if (ret < 0) {
1315 fprintf(stderr, "[error] Opening the trace\n");
1316 goto end;
1317 }
1318 } else {
1319 bt_ctx = bt_context_create();
1320 ret = bt_context_add_traces_recursive(bt_ctx, opt_input_path, "ctf", NULL);
1321 if (ret < 0) {
1322 fprintf(stderr, "[error] Opening the trace\n");
1323 goto end;
1324 }
1325
1326 ret = check_requirements(bt_ctx);
1327 if (ret < 0 && !valid_trace) {
1328 fprintf(stderr, "[error] some mandatory contexts "
1329 "were missing, exiting.\n");
1330 //goto end;
1331 }
1332
1333 if (!opt_textdump) {
1334 #ifdef HAVE_LIBNCURSES
1335 pthread_create(&display_thread, NULL, ncurses_display,
1336 (void *) NULL);
1337 pthread_create(&timer_thread, NULL, refresh_thread,
1338 (void *) NULL);
1339 #else
1340 printf("Ncurses support not compiled, please install "
1341 "the missing dependencies and recompile\n");
1342 goto end;
1343 #endif
1344 }
1345
1346 iter_trace(bt_ctx);
1347 }
1348
1349
1350 pthread_join(display_thread, NULL);
1351 quit = 1;
1352 pthread_join(timer_thread, NULL);
1353
1354 ret = 0;
1355
1356 end:
1357 if (bt_ctx)
1358 bt_context_put(bt_ctx);
1359
1360 if (live_session_name) {
1361 ret = destroy_live_local_session(live_session_name);
1362 if (ret < 0) {
1363 fprintf(stderr, "Error destroying %s\n", live_session_name);
1364 }
1365 }
1366
1367 return ret;
1368 }
This page took 0.090552 seconds and 3 git commands to generate.