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