bugfix pretty-printing and begin kprobes
[lttngtop.git] / src / lttngtop.c
CommitLineData
1fc22eb4 1/*
aa15ac1c 2 * Copyright (C) 2011-2012 Julien Desfossez
1fc22eb4
JD
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 *
71bd7ce1
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1fc22eb4
JD
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>
3ba84bed 25#include <babeltrace/ctf/iterator.h>
1fc22eb4
JD
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>
85db4618 39#include <assert.h>
16b22a0f
JD
40#include <sys/mman.h>
41#include <lttng/lttng.h>
42#include <lttng/lttngtop-helper.h>
c78f2cdc 43#include <babeltrace/lttngtopmmappacketseek.h>
1fc22eb4
JD
44
45#include "lttngtoptypes.h"
46#include "cputop.h"
47#include "iostreamtop.h"
48#include "cursesdisplay.h"
49#include "common.h"
50
51#define DEFAULT_FILE_ARRAY_SIZE 1
52
53const char *opt_input_path;
32b70e07 54static int opt_textdump;
32b70e07 55static int opt_child;
1fc22eb4 56
ae9e85c7
JD
57int quit = 0;
58
1fc22eb4
JD
59struct lttngtop *copy;
60pthread_t display_thread;
61pthread_t timer_thread;
62
63unsigned long refresh_display = 1 * NSEC_PER_SEC;
64unsigned long last_display_update = 0;
1fc22eb4 65
16b22a0f
JD
66/* list of FDs available for being read with snapshots */
67struct mmap_stream_list mmap_list;
68GPtrArray *lttng_consumer_stream_array;
69int sessiond_metadata, consumerd_metadata;
4e6aeb3d
JD
70struct lttng_consumer_local_data *ctx = NULL;
71/* list of snapshots currently not consumed */
72GPtrArray *available_snapshots;
73sem_t metadata_available;
050f9cf9 74int reload_trace = 0;
16b22a0f 75
57bff788
JD
76int last_textdump_print_newline = 1;
77
1fc22eb4
JD
78enum {
79 OPT_NONE = 0,
80 OPT_HELP,
6777529d 81 OPT_TEXTDUMP,
32b70e07
JD
82 OPT_PID,
83 OPT_CHILD,
c8d75a13 84 OPT_HOSTNAME,
1fc22eb4
JD
85};
86
87static struct poptOption long_options[] = {
88 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
89 { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
6777529d 90 { "textdump", 't', POPT_ARG_NONE, NULL, OPT_TEXTDUMP, NULL, NULL },
32b70e07 91 { "child", 'f', POPT_ARG_NONE, NULL, OPT_CHILD, NULL, NULL },
57bff788 92 { "pid", 'p', POPT_ARG_STRING, &opt_tid, OPT_PID, NULL, NULL },
c8d75a13 93 { "hostname", 'n', POPT_ARG_STRING, &opt_hostname, OPT_HOSTNAME, NULL, NULL },
1fc22eb4
JD
94 { NULL, 0, 0, NULL, 0, NULL, NULL },
95};
96
24797198
JD
97static void handle_textdump_sigterm(int signal)
98{
99 quit = 1;
100 lttng_destroy_session("test");
101}
102
1fc22eb4
JD
103void *refresh_thread(void *p)
104{
cade3418
JD
105 struct mmap_stream *mmap_info;
106
1fc22eb4 107 while (1) {
ae9e85c7
JD
108 if (quit) {
109 sem_post(&pause_sem);
110 sem_post(&timer);
1402044a 111 sem_post(&end_trace_sem);
ae9e85c7 112 sem_post(&goodtodisplay);
1402044a 113 sem_post(&goodtoupdate);
ae9e85c7
JD
114 pthread_exit(0);
115 }
1402044a 116 if (!opt_input_path) {
d2d680e0
JD
117 bt_list_for_each_entry(mmap_info, &mmap_list.head, list)
118 helper_kernctl_buffer_flush(mmap_info->fd);
1402044a 119 }
1fc22eb4
JD
120 sem_wait(&pause_sem);
121 sem_post(&pause_sem);
122 sem_post(&timer);
123 sleep(refresh_display/NSEC_PER_SEC);
124 }
125}
126
127void *ncurses_display(void *p)
128{
129 unsigned int current_display_index = 0;
130
131 sem_wait(&bootstrap);
b332d28f
JD
132 /*
133 * Prevent the 1 second delay when we hit ESC
134 */
135 ESCDELAY = 0;
1fc22eb4
JD
136 init_ncurses();
137
138 while (1) {
139 sem_wait(&timer);
140 sem_wait(&goodtodisplay);
141 sem_wait(&pause_sem);
142
ae9e85c7 143 if (quit) {
33572a17
JD
144 sem_post(&pause_sem);
145 sem_post(&timer);
ae9e85c7
JD
146 reset_ncurses();
147 pthread_exit(0);
148 }
149
1fc22eb4 150 copy = g_ptr_array_index(copies, current_display_index);
85db4618
JD
151 assert(copy);
152 display(current_display_index++);
1fc22eb4
JD
153
154 sem_post(&goodtoupdate);
155 sem_post(&pause_sem);
1fc22eb4
JD
156 }
157}
158
575cc4fd
JD
159void print_fields(struct bt_ctf_event *event)
160{
161 unsigned int cnt, i;
162 const struct definition *const * list;
163 const struct definition *scope;
164 enum ctf_type_id type;
165 const char *str;
166
167 scope = bt_ctf_get_top_level_scope(event, BT_EVENT_FIELDS);
168
169 bt_ctf_get_field_list(event, scope, &list, &cnt);
170 for (i = 0; i < cnt; i++) {
171 if (i != 0)
172 printf(", ");
173 printf("%s = ", bt_ctf_field_name(list[i]));
174 type = bt_ctf_field_type(list[i]);
175 if (type == CTF_TYPE_INTEGER) {
176 if (bt_ctf_get_int_signedness(list[i]) == 0)
177 printf("%" PRIu64 "", bt_ctf_get_uint64(list[i]));
178 else
179 printf("%" PRId64 "", bt_ctf_get_int64(list[i]));
180 } else if (type == CTF_TYPE_STRING) {
181 printf("%s", bt_ctf_get_string(list[i]));
182 } else if (type == CTF_TYPE_ARRAY) {
183 str = bt_ctf_get_char_array(list[i]);
fbbda4da 184 if (!bt_ctf_field_get_error() && str)
575cc4fd
JD
185 printf("%s", str);
186 }
187 }
188}
189
6112d0d4
JD
190/*
191 * hook on each event to check the timestamp and refresh the display if
192 * necessary
193 */
194enum bt_cb_ret print_timestamp(struct bt_ctf_event *call_data, void *private_data)
195{
196 unsigned long timestamp;
197 struct tm start;
b520ab45 198 uint64_t ts_nsec_start;
575cc4fd 199 int pid, cpu_id;
d2d680e0
JD
200 int64_t syscall_ret;
201 const struct definition *scope;
575cc4fd 202 const char *hostname, *procname;
6112d0d4 203
6112d0d4
JD
204 timestamp = bt_ctf_get_timestamp(call_data);
205
b520ab45 206 start = format_timestamp(timestamp);
6112d0d4
JD
207 ts_nsec_start = timestamp % NSEC_PER_SEC;
208
32b70e07 209 pid = get_context_pid(call_data);
57bff788 210 if (pid == -1ULL && opt_tid) {
32b70e07
JD
211 goto error;
212 }
213
c8d75a13
JD
214 hostname = get_context_hostname(call_data);
215 if (!opt_tid && (opt_hostname && !lookup_hostname_list(hostname)))
216 goto end;
217 if (!opt_hostname && (opt_tid && !lookup_tid_list(pid)))
218 goto end;
219 if ((opt_tid && !lookup_tid_list(pid)) &&
220 (opt_hostname && !lookup_hostname_list(hostname)))
32b70e07
JD
221 goto end;
222
575cc4fd
JD
223 cpu_id = get_cpu_id(call_data);
224 procname = get_context_comm(call_data);
225
fbbda4da 226 if ((strcmp(bt_ctf_event_name(call_data), "exit_syscall") == 0) && !last_textdump_print_newline) {
d2d680e0
JD
227 scope = bt_ctf_get_top_level_scope(call_data,
228 BT_EVENT_FIELDS);
229 syscall_ret = bt_ctf_get_int64(bt_ctf_get_field(call_data,
230 scope, "_ret"));
231 printf("= %ld\n", syscall_ret);
57bff788 232 last_textdump_print_newline = 1;
d2d680e0 233 } else {
57bff788
JD
234 /* we might have lost the exit_syscall event, so need to
235 * print the newline in this case */
236 if (last_textdump_print_newline == 0)
237 printf("\n");
575cc4fd
JD
238 printf("%02d:%02d:%02d.%09" PRIu64 " (%s) (cpu %d) [%s (%d)] %s (",
239 start.tm_hour, start.tm_min, start.tm_sec,
240 ts_nsec_start, hostname, cpu_id, procname, pid,
241 bt_ctf_event_name(call_data));
242 print_fields(call_data);
243 printf(") ");
fbbda4da 244 if (strncmp(bt_ctf_event_name(call_data), "sys_", 4) != 0) {
575cc4fd 245 printf("\n");
fbbda4da
JD
246 last_textdump_print_newline = 1;
247 } else {
248 last_textdump_print_newline = 0;
575cc4fd 249 }
d2d680e0 250 }
6112d0d4 251
32b70e07 252end:
6112d0d4 253 return BT_CB_OK;
32b70e07
JD
254error:
255 return BT_CB_ERROR_STOP;
6112d0d4
JD
256}
257
1fc22eb4
JD
258/*
259 * hook on each event to check the timestamp and refresh the display if
260 * necessary
261 */
4adc8274 262enum bt_cb_ret check_timestamp(struct bt_ctf_event *call_data, void *private_data)
1fc22eb4
JD
263{
264 unsigned long timestamp;
265
c78f2cdc 266 timestamp = bt_ctf_get_timestamp(call_data);
1fc22eb4
JD
267 if (timestamp == -1ULL)
268 goto error;
269
270 if (last_display_update == 0)
271 last_display_update = timestamp;
272
273 if (timestamp - last_display_update >= refresh_display) {
274 sem_wait(&goodtoupdate);
275 g_ptr_array_add(copies, get_copy_lttngtop(last_display_update,
276 timestamp));
277 sem_post(&goodtodisplay);
278 sem_post(&bootstrap);
279 last_display_update = timestamp;
280 }
281 return BT_CB_OK;
282
283error:
284 fprintf(stderr, "check_timestamp callback error\n");
285 return BT_CB_ERROR_STOP;
286}
287
288/*
289 * get_perf_counter : get or create and return a perf_counter struct for
290 * either a process or a cpu (only one of the 2 parameters mandatory)
291 */
292struct perfcounter *get_perf_counter(const char *name, struct processtop *proc,
293 struct cputime *cpu)
294{
bb6d72a2 295 struct perfcounter *ret;
1fc22eb4
JD
296 GHashTable *table;
297
298 if (proc)
299 table = proc->perf;
300 else if (cpu)
301 table = cpu->perf;
302 else
303 goto error;
304
305 ret = g_hash_table_lookup(table, (gpointer) name);
306 if (ret)
307 goto end;
308
559c9f86 309 ret = g_new0(struct perfcounter, 1);
1fc22eb4
JD
310 /* by default, make it visible in the UI */
311 ret->visible = 1;
85db4618 312 g_hash_table_insert(table, (gpointer) strdup(name), ret);
1fc22eb4 313
1fc22eb4
JD
314end:
315 return ret;
316
317error:
318 return NULL;
319}
320
321void update_perf_value(struct processtop *proc, struct cputime *cpu,
322 const char *name, int value)
323{
324 struct perfcounter *cpu_perf, *process_perf;
325
326 cpu_perf = get_perf_counter(name, NULL, cpu);
327 if (cpu_perf->count < value) {
328 process_perf = get_perf_counter(name, proc, NULL);
329 process_perf->count += value - cpu_perf->count;
330 cpu_perf->count = value;
331 }
332}
333
4adc8274 334void extract_perf_counter_scope(const struct bt_ctf_event *event,
2e0a1190 335 const struct bt_definition *scope,
1fc22eb4
JD
336 struct processtop *proc,
337 struct cputime *cpu)
338{
2e0a1190
JD
339 struct bt_definition const * const *list = NULL;
340 const struct bt_definition *field;
1fc22eb4 341 unsigned int count;
bb6d72a2
JD
342 struct perfcounter *perfcounter;
343 GHashTableIter iter;
344 gpointer key;
345 int ret;
1fc22eb4
JD
346
347 if (!scope)
348 goto end;
349
350 ret = bt_ctf_get_field_list(event, scope, &list, &count);
351 if (ret < 0)
352 goto end;
353
bb6d72a2
JD
354 if (count == 0)
355 goto end;
356
357 g_hash_table_iter_init(&iter, global_perf_liszt);
358 while (g_hash_table_iter_next (&iter, &key, (gpointer) &perfcounter)) {
359 field = bt_ctf_get_field(event, scope, (char *) key);
360 if (field) {
361 int value = bt_ctf_get_uint64(field);
1fc22eb4
JD
362 if (bt_ctf_field_get_error())
363 continue;
bb6d72a2 364 update_perf_value(proc, cpu, (char *) key, value);
1fc22eb4
JD
365 }
366 }
367
368end:
369 return;
370}
371
4adc8274 372void update_perf_counter(struct processtop *proc, const struct bt_ctf_event *event)
1fc22eb4 373{
1fc22eb4 374 struct cputime *cpu;
2e0a1190 375 const struct bt_definition *scope;
1fc22eb4 376
d67167cd 377 cpu = get_cpu(get_cpu_id(event));
1fc22eb4
JD
378
379 scope = bt_ctf_get_top_level_scope(event, BT_STREAM_EVENT_CONTEXT);
380 extract_perf_counter_scope(event, scope, proc, cpu);
381
382 scope = bt_ctf_get_top_level_scope(event, BT_STREAM_PACKET_CONTEXT);
383 extract_perf_counter_scope(event, scope, proc, cpu);
384
385 scope = bt_ctf_get_top_level_scope(event, BT_EVENT_CONTEXT);
386 extract_perf_counter_scope(event, scope, proc, cpu);
1fc22eb4
JD
387}
388
4adc8274 389enum bt_cb_ret fix_process_table(struct bt_ctf_event *call_data,
1fc22eb4
JD
390 void *private_data)
391{
1402044a 392 int pid, tid, ppid, vpid, vtid, vppid;
c8d75a13 393 char *comm, *hostname;
1fc22eb4 394 struct processtop *parent, *child;
1fc22eb4
JD
395 unsigned long timestamp;
396
c78f2cdc 397 timestamp = bt_ctf_get_timestamp(call_data);
1fc22eb4
JD
398 if (timestamp == -1ULL)
399 goto error;
400
1dec520a
JD
401 pid = get_context_pid(call_data);
402 if (pid == -1ULL) {
1fc22eb4
JD
403 goto error;
404 }
96aa77de 405
1dec520a
JD
406 tid = get_context_tid(call_data);
407 if (tid == -1ULL) {
1fc22eb4
JD
408 goto error;
409 }
1dec520a
JD
410 ppid = get_context_ppid(call_data);
411 if (ppid == -1ULL) {
1fc22eb4
JD
412 goto error;
413 }
1402044a
JD
414 vpid = get_context_vpid(call_data);
415 if (pid == -1ULL) {
416 vpid = -1;
417 }
418 vtid = get_context_vtid(call_data);
419 if (tid == -1ULL) {
420 vtid = -1;
421 }
422 vppid = get_context_vppid(call_data);
423 if (ppid == -1ULL) {
424 vppid = -1;
425 }
1dec520a
JD
426 comm = get_context_comm(call_data);
427 if (!comm) {
1fc22eb4
JD
428 goto error;
429 }
c8d75a13
JD
430 /* optional */
431 hostname = get_context_hostname(call_data);
1fc22eb4
JD
432
433 /* find or create the current process */
434 child = find_process_tid(&lttngtop, tid, comm);
435 if (!child)
436 child = add_proc(&lttngtop, tid, comm, timestamp);
96aa77de
JD
437 if (!child)
438 goto end;
c8d75a13 439 update_proc(child, pid, tid, ppid, vpid, vtid, vppid, comm, hostname);
1fc22eb4
JD
440
441 if (pid != tid) {
442 /* find or create the parent */
443 parent = find_process_tid(&lttngtop, pid, comm);
444 if (!parent) {
445 parent = add_proc(&lttngtop, pid, comm, timestamp);
96aa77de
JD
446 if (parent)
447 parent->pid = pid;
1fc22eb4
JD
448 }
449
450 /* attach the parent to the current process */
451 child->threadparent = parent;
452 add_thread(parent, child);
453 }
454
455 update_perf_counter(child, call_data);
456
96aa77de 457end:
1fc22eb4
JD
458 return BT_CB_OK;
459
460error:
461 return BT_CB_ERROR_STOP;
462}
463
464void init_lttngtop()
465{
466 copies = g_ptr_array_new();
0d91c12a 467 global_perf_liszt = g_hash_table_new(g_str_hash, g_str_equal);
1fc22eb4
JD
468
469 sem_init(&goodtodisplay, 0, 0);
470 sem_init(&goodtoupdate, 0, 1);
471 sem_init(&timer, 0, 1);
472 sem_init(&bootstrap, 0, 0);
473 sem_init(&pause_sem, 0, 1);
474 sem_init(&end_trace_sem, 0, 0);
475
e05a35a6
JD
476 reset_global_counters();
477 lttngtop.nbproc = 0;
478 lttngtop.nbthreads = 0;
479 lttngtop.nbfiles = 0;
480
30b646c4
JD
481 lttngtop.process_hash_table = g_hash_table_new(g_direct_hash,
482 g_direct_equal);
1fc22eb4
JD
483 lttngtop.process_table = g_ptr_array_new();
484 lttngtop.files_table = g_ptr_array_new();
485 lttngtop.cpu_table = g_ptr_array_new();
486}
487
c263c4eb 488void usage(FILE *fp)
1fc22eb4 489{
c263c4eb 490 fprintf(fp, "LTTngTop %s\n\n", VERSION);
c8d75a13
JD
491 fprintf(fp, "Usage : lttngtop [OPTIONS] [TRACE]\n");
492 fprintf(fp, " TRACE Path to the trace to analyse (no trace path for live tracing)\n");
493 fprintf(fp, " -h, --help This help message\n");
494 fprintf(fp, " -t, --textdump Display live events in text-only\n");
495 fprintf(fp, " -p, --pid Comma-separated list of PIDs to display\n");
496 fprintf(fp, " -f, --child Follow threads associated with selected PIDs\n");
497 fprintf(fp, " -n, --hostname Comma-separated list of hostnames to display (require hostname context in trace)\n");
1fc22eb4
JD
498}
499
500/*
501 * Return 0 if caller should continue, < 0 if caller should return
502 * error, > 0 if caller should exit without reporting error.
503 */
504static int parse_options(int argc, char **argv)
505{
506 poptContext pc;
507 int opt, ret = 0;
57bff788
JD
508 char *tmp_str;
509 int *tid;
1fc22eb4 510
1fc22eb4
JD
511 pc = poptGetContext(NULL, argc, (const char **) argv, long_options, 0);
512 poptReadDefaultConfig(pc, 0);
513
514 while ((opt = poptGetNextOpt(pc)) != -1) {
515 switch (opt) {
516 case OPT_HELP:
517 usage(stdout);
518 ret = 1; /* exit cleanly */
519 goto end;
6777529d
JD
520 case OPT_TEXTDUMP:
521 opt_textdump = 1;
32b70e07
JD
522 break;
523 case OPT_CHILD:
524 opt_textdump = 1;
525 opt_child = 1;
526 break;
527 case OPT_PID:
c8d75a13
JD
528 tid_list = g_hash_table_new(g_str_hash,
529 g_str_equal);
57bff788
JD
530 tmp_str = strtok(opt_tid, ",");
531 while (tmp_str) {
532 tid = malloc(sizeof(int));
533 *tid = atoi(tmp_str);
c8d75a13
JD
534 g_hash_table_insert(tid_list,
535 (gpointer) tid, tid);
536 tmp_str = strtok(NULL, ",");
537 }
538 break;
539 case OPT_HOSTNAME:
540 hostname_list = g_hash_table_new(g_str_hash,
541 g_str_equal);
542 tmp_str = strtok(opt_hostname, ",");
543 while (tmp_str) {
544 char *new_str = strdup(tmp_str);
545 g_hash_table_insert(hostname_list,
546 (gpointer) new_str,
547 (gpointer) new_str);
57bff788
JD
548 tmp_str = strtok(NULL, ",");
549 }
32b70e07 550 break;
1fc22eb4
JD
551 default:
552 ret = -EINVAL;
553 goto end;
554 }
555 }
556
557 opt_input_path = poptGetArg(pc);
16b22a0f 558
1fc22eb4
JD
559end:
560 if (pc) {
561 poptFreeContext(pc);
562 }
563 return ret;
564}
565
566void iter_trace(struct bt_context *bt_ctx)
567{
568 struct bt_ctf_iter *iter;
569 struct bt_iter_pos begin_pos;
4adc8274 570 const struct bt_ctf_event *event;
1fc22eb4
JD
571 int ret = 0;
572
573 begin_pos.type = BT_SEEK_BEGIN;
574 iter = bt_ctf_iter_create(bt_ctx, &begin_pos, NULL);
575
6777529d
JD
576 if (opt_textdump) {
577 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
578 print_timestamp,
579 NULL, NULL, NULL);
580 } else {
581 /* at each event check if we need to refresh */
582 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
583 check_timestamp,
584 NULL, NULL, NULL);
585 /* at each event, verify the status of the process table */
586 bt_ctf_iter_add_callback(iter, 0, NULL, 0,
587 fix_process_table,
588 NULL, NULL, NULL);
589 /* to handle the scheduling events */
590 bt_ctf_iter_add_callback(iter,
591 g_quark_from_static_string("sched_switch"),
592 NULL, 0, handle_sched_switch, NULL, NULL, NULL);
593 /* to clean up the process table */
594 bt_ctf_iter_add_callback(iter,
595 g_quark_from_static_string("sched_process_free"),
596 NULL, 0, handle_sched_process_free, NULL, NULL, NULL);
597 /* to get all the process from the statedumps */
598 bt_ctf_iter_add_callback(iter,
599 g_quark_from_static_string(
600 "lttng_statedump_process_state"),
601 NULL, 0, handle_statedump_process_state,
602 NULL, NULL, NULL);
603
604 /* for IO top */
605 bt_ctf_iter_add_callback(iter,
606 g_quark_from_static_string("exit_syscall"),
607 NULL, 0, handle_exit_syscall, NULL, NULL, NULL);
608 bt_ctf_iter_add_callback(iter,
609 g_quark_from_static_string("sys_write"),
610 NULL, 0, handle_sys_write, NULL, NULL, NULL);
611 bt_ctf_iter_add_callback(iter,
612 g_quark_from_static_string("sys_read"),
613 NULL, 0, handle_sys_read, NULL, NULL, NULL);
614 bt_ctf_iter_add_callback(iter,
615 g_quark_from_static_string("sys_open"),
616 NULL, 0, handle_sys_open, NULL, NULL, NULL);
617 bt_ctf_iter_add_callback(iter,
618 g_quark_from_static_string("sys_close"),
619 NULL, 0, handle_sys_close, NULL, NULL, NULL);
620 bt_ctf_iter_add_callback(iter,
621 g_quark_from_static_string(
ceb3a221 622 "lttng_statedump_file_descriptor"),
6777529d
JD
623 NULL, 0, handle_statedump_file_descriptor,
624 NULL, NULL, NULL);
625 }
626
fbbda4da 627 while ((event = bt_ctf_iter_read_event(iter)) != NULL) {
050f9cf9 628 if (quit || reload_trace)
ae9e85c7 629 goto end_iter;
1fc22eb4
JD
630 ret = bt_iter_next(bt_ctf_get_iter(iter));
631 if (ret < 0)
632 goto end_iter;
633 }
634
635 /* block until quit, we reached the end of the trace */
636 sem_wait(&end_trace_sem);
637
638end_iter:
06570214 639 bt_ctf_iter_destroy(iter);
1fc22eb4
JD
640}
641
642/*
643 * bt_context_add_traces_recursive: Open a trace recursively
644 * (copied from BSD code in converter/babeltrace.c)
645 *
646 * Find each trace present in the subdirectory starting from the given
647 * path, and add them to the context. The packet_seek parameter can be
648 * NULL: this specify to use the default format packet_seek.
649 *
650 * Return: 0 on success, nonzero on failure.
651 * Unable to open toplevel: failure.
652 * Unable to open some subdirectory or file: warn and continue;
653 */
654int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
655 const char *format_str,
2e0a1190 656 void (*packet_seek)(struct bt_stream_pos *pos,
1fc22eb4
JD
657 size_t offset, int whence))
658{
659 FTS *tree;
660 FTSENT *node;
661 GArray *trace_ids;
662 char lpath[PATH_MAX];
663 char * const paths[2] = { lpath, NULL };
0d567cf1 664 int ret = -1;
1fc22eb4
JD
665
666 /*
667 * Need to copy path, because fts_open can change it.
668 * It is the pointer array, not the strings, that are constant.
669 */
670 strncpy(lpath, path, PATH_MAX);
671 lpath[PATH_MAX - 1] = '\0';
672
673 tree = fts_open(paths, FTS_NOCHDIR | FTS_LOGICAL, 0);
674 if (tree == NULL) {
675 fprintf(stderr, "[error] [Context] Cannot traverse \"%s\" for reading.\n",
676 path);
677 return -EINVAL;
678 }
679
680 trace_ids = g_array_new(FALSE, TRUE, sizeof(int));
681
682 while ((node = fts_read(tree))) {
683 int dirfd, metafd;
684
685 if (!(node->fts_info & FTS_D))
686 continue;
687
688 dirfd = open(node->fts_accpath, 0);
689 if (dirfd < 0) {
690 fprintf(stderr, "[error] [Context] Unable to open trace "
691 "directory file descriptor.\n");
692 ret = dirfd;
693 goto error;
694 }
695 metafd = openat(dirfd, "metadata", O_RDONLY);
696 if (metafd < 0) {
7314c855
JD
697 close(dirfd);
698 ret = -1;
699 continue;
1fc22eb4
JD
700 } else {
701 int trace_id;
702
703 ret = close(metafd);
704 if (ret < 0) {
705 perror("close");
706 goto error;
707 }
708 ret = close(dirfd);
709 if (ret < 0) {
710 perror("close");
711 goto error;
712 }
713
714 trace_id = bt_context_add_trace(ctx,
715 node->fts_accpath, format_str,
716 packet_seek, NULL, NULL);
717 if (trace_id < 0) {
0d567cf1 718 fprintf(stderr, "[warning] [Context] opening trace \"%s\" from %s "
1fc22eb4 719 "for reading.\n", node->fts_accpath, path);
0d567cf1
JD
720 /* Allow to skip erroneous traces. */
721 continue;
1fc22eb4
JD
722 }
723 g_array_append_val(trace_ids, trace_id);
724 }
725 }
726
727 g_array_free(trace_ids, TRUE);
0d567cf1 728 return ret;
1fc22eb4
JD
729
730error:
731 return ret;
732}
733
4553b4d1 734static int check_field_requirements(const struct bt_ctf_field_decl *const * field_list,
a54d0d2c
JD
735 int field_cnt, int *tid_check, int *pid_check,
736 int *procname_check, int *ppid_check)
737{
738 int j;
bb6d72a2
JD
739 struct perfcounter *global;
740 const char *name;
a54d0d2c
JD
741
742 for (j = 0; j < field_cnt; j++) {
bb6d72a2 743 name = bt_ctf_get_decl_field_name(field_list[j]);
a54d0d2c 744 if (*tid_check == 0) {
bb6d72a2 745 if (strncmp(name, "tid", 3) == 0)
a54d0d2c 746 (*tid_check)++;
a54d0d2c
JD
747 }
748 if (*pid_check == 0) {
da401e9c 749 if (strncmp(name, "pid", 3) == 0)
a54d0d2c
JD
750 (*pid_check)++;
751 }
752 if (*ppid_check == 0) {
bb6d72a2 753 if (strncmp(name, "ppid", 4) == 0)
a54d0d2c
JD
754 (*ppid_check)++;
755 }
756 if (*procname_check == 0) {
bb6d72a2 757 if (strncmp(name, "procname", 8) == 0)
a54d0d2c
JD
758 (*procname_check)++;
759 }
bb6d72a2
JD
760 if (strncmp(name, "perf_", 5) == 0) {
761 global = g_hash_table_lookup(global_perf_liszt, (gpointer) name);
762 if (!global) {
763 global = g_new0(struct perfcounter, 1);
764 /* by default, sort on the first perf context */
765 if (g_hash_table_size(global_perf_liszt) == 0)
766 global->sort = 1;
767 global->visible = 1;
768 g_hash_table_insert(global_perf_liszt, (gpointer) strdup(name), global);
769 }
770 }
a54d0d2c 771 }
bb6d72a2 772
a54d0d2c
JD
773 if (*tid_check == 1 && *pid_check == 1 && *ppid_check == 1 &&
774 *procname_check == 1)
775 return 0;
776
777 return -1;
778}
779
780/*
781 * check_requirements: check if the required context informations are available
782 *
783 * If each mandatory context information is available for at least in one
784 * event, return 0 otherwise return -1.
a54d0d2c
JD
785 */
786int check_requirements(struct bt_context *ctx)
787{
788 unsigned int i, evt_cnt, field_cnt;
789 struct bt_ctf_event_decl *const * evt_list;
790 const struct bt_ctf_field_decl *const * field_list;
791 int tid_check = 0;
792 int pid_check = 0;
793 int procname_check = 0;
794 int ppid_check = 0;
795 int ret = 0;
796
797 bt_ctf_get_event_decl_list(0, ctx, &evt_list, &evt_cnt);
798 for (i = 0; i < evt_cnt; i++) {
799 bt_ctf_get_decl_fields(evt_list[i], BT_STREAM_EVENT_CONTEXT,
800 &field_list, &field_cnt);
801 ret = check_field_requirements(field_list, field_cnt,
802 &tid_check, &pid_check, &procname_check,
803 &ppid_check);
a54d0d2c
JD
804
805 bt_ctf_get_decl_fields(evt_list[i], BT_EVENT_CONTEXT,
806 &field_list, &field_cnt);
807 ret = check_field_requirements(field_list, field_cnt,
808 &tid_check, &pid_check, &procname_check,
809 &ppid_check);
a54d0d2c
JD
810
811 bt_ctf_get_decl_fields(evt_list[i], BT_STREAM_PACKET_CONTEXT,
812 &field_list, &field_cnt);
813 ret = check_field_requirements(field_list, field_cnt,
814 &tid_check, &pid_check, &procname_check,
815 &ppid_check);
a54d0d2c
JD
816 }
817
818 if (tid_check == 0) {
819 ret = -1;
820 fprintf(stderr, "[error] missing tid context information\n");
821 }
822 if (pid_check == 0) {
823 ret = -1;
824 fprintf(stderr, "[error] missing pid context information\n");
825 }
826 if (ppid_check == 0) {
827 ret = -1;
828 fprintf(stderr, "[error] missing ppid context information\n");
829 }
830 if (procname_check == 0) {
831 ret = -1;
832 fprintf(stderr, "[error] missing procname context information\n");
833 }
834
a54d0d2c
JD
835 return ret;
836}
837
16b22a0f
JD
838ssize_t read_subbuffer(struct lttng_consumer_stream *kconsumerd_fd,
839 struct lttng_consumer_local_data *ctx)
840{
841 unsigned long len;
842 int err;
843 long ret = 0;
844 int infd = helper_get_lttng_consumer_stream_wait_fd(kconsumerd_fd);
845
846 if (helper_get_lttng_consumer_stream_output(kconsumerd_fd) == LTTNG_EVENT_SPLICE) {
847 /* Get the next subbuffer */
16b22a0f
JD
848 err = helper_kernctl_get_next_subbuf(infd);
849 if (err != 0) {
850 ret = errno;
851 perror("Reserving sub buffer failed (everything is normal, "
852 "it is due to concurrency)");
853 goto end;
854 }
855 /* read the whole subbuffer */
856 err = helper_kernctl_get_padded_subbuf_size(infd, &len);
857 if (err != 0) {
858 ret = errno;
859 perror("Getting sub-buffer len failed.");
860 goto end;
861 }
16b22a0f
JD
862
863 /* splice the subbuffer to the tracefile */
864 ret = helper_lttng_consumer_on_read_subbuffer_splice(ctx, kconsumerd_fd, len);
865 if (ret < 0) {
866 /*
867 * display the error but continue processing to try
868 * to release the subbuffer
869 */
870 fprintf(stderr,"Error splicing to tracefile\n");
871 }
16b22a0f
JD
872 err = helper_kernctl_put_next_subbuf(infd);
873 if (err != 0) {
874 ret = errno;
875 perror("Reserving sub buffer failed (everything is normal, "
876 "it is due to concurrency)");
877 goto end;
878 }
4e6aeb3d 879 sem_post(&metadata_available);
16b22a0f
JD
880 }
881
882end:
883 return 0;
884}
885
886int on_update_fd(int key, uint32_t state)
887{
888 /* let the lib handle the metadata FD */
889 if (key == sessiond_metadata)
890 return 0;
891 return 1;
892}
893
894int on_recv_fd(struct lttng_consumer_stream *kconsumerd_fd)
895{
896 int ret;
b520ab45 897 struct mmap_stream *new_mmap_stream;
16b22a0f 898
16b22a0f
JD
899 /* Opening the tracefile in write mode */
900 if (helper_get_lttng_consumer_stream_path_name(kconsumerd_fd) != NULL) {
901 ret = open(helper_get_lttng_consumer_stream_path_name(kconsumerd_fd),
902 O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU|S_IRWXG|S_IRWXO);
903 if (ret < 0) {
904 perror("open");
905 goto end;
906 }
907 helper_set_lttng_consumer_stream_out_fd(kconsumerd_fd, ret);
908 }
909
910 if (helper_get_lttng_consumer_stream_output(kconsumerd_fd) == LTTNG_EVENT_MMAP) {
b520ab45
JD
911 new_mmap_stream = malloc(sizeof(struct mmap_stream));
912 new_mmap_stream->fd = helper_get_lttng_consumer_stream_wait_fd(
913 kconsumerd_fd);
914 bt_list_add(&new_mmap_stream->list, &mmap_list.head);
16b22a0f
JD
915
916 g_ptr_array_add(lttng_consumer_stream_array, kconsumerd_fd);
6112d0d4
JD
917 /* keep mmap FDs internally */
918 ret = 1;
16b22a0f
JD
919 } else {
920 consumerd_metadata = helper_get_lttng_consumer_stream_wait_fd(kconsumerd_fd);
921 sessiond_metadata = helper_get_lttng_consumer_stream_key(kconsumerd_fd);
922 ret = 0;
923 }
924
050f9cf9
JD
925 reload_trace = 1;
926
16b22a0f
JD
927end:
928 return ret;
929}
930
eb677852 931void live_consume(struct bt_context **bt_ctx)
e91044a8 932{
e91044a8 933 int ret;
050f9cf9 934 FILE *metadata_fp;
e91044a8 935
050f9cf9
JD
936 sem_wait(&metadata_available);
937 if (access("/tmp/livesession/kernel/metadata", F_OK) != 0) {
938 fprintf(stderr,"no metadata\n");
939 goto end;
71c74ca6 940 }
050f9cf9 941 metadata_fp = fopen("/tmp/livesession/kernel/metadata", "r");
c78f2cdc 942
050f9cf9
JD
943 *bt_ctx = bt_context_create();
944 ret = bt_context_add_trace(*bt_ctx, NULL, "ctf",
945 lttngtop_ctf_packet_seek, &mmap_list, metadata_fp);
946 if (ret < 0) {
947 printf("Error adding trace\n");
948 goto end;
e91044a8 949 }
b520ab45 950
eb677852
JD
951end:
952 return;
e91044a8 953}
16b22a0f
JD
954
955int setup_consumer(char *command_sock_path, pthread_t *threads,
956 struct lttng_consumer_local_data *ctx)
957{
958 int ret = 0;
959
960 ctx = helper_lttng_consumer_create(HELPER_LTTNG_CONSUMER_KERNEL,
961 read_subbuffer, NULL, on_recv_fd, on_update_fd);
962 if (!ctx)
963 goto end;
964
965 unlink(command_sock_path);
966 helper_lttng_consumer_set_command_sock_path(ctx, command_sock_path);
967 helper_lttng_consumer_init();
968
969 /* Create the thread to manage the receive of fd */
970 ret = pthread_create(&threads[0], NULL, helper_lttng_consumer_thread_receive_fds,
971 (void *) ctx);
972 if (ret != 0) {
c78f2cdc 973 perror("pthread_create receive fd");
16b22a0f
JD
974 goto end;
975 }
e91044a8
JD
976 /* Create thread to manage the polling/writing of traces */
977 ret = pthread_create(&threads[1], NULL, helper_lttng_consumer_thread_poll_fds,
978 (void *) ctx);
979 if (ret != 0) {
c78f2cdc 980 perror("pthread_create poll fd");
e91044a8
JD
981 goto end;
982 }
983
16b22a0f
JD
984end:
985 return ret;
986}
987
1a70b8ac 988int setup_live_tracing()
16b22a0f
JD
989{
990 struct lttng_domain dom;
991 struct lttng_channel chan;
992 char *channel_name = "mmapchan";
16b22a0f
JD
993 struct lttng_event ev;
994 int ret = 0;
995 char *command_sock_path = "/tmp/consumerd_sock";
996 static pthread_t threads[2]; /* recv_fd, poll */
997 struct lttng_event_context kctxpid, kctxcomm, kctxppid, kctxtid;
16b22a0f
JD
998
999 struct lttng_handle *handle;
1000
1001 BT_INIT_LIST_HEAD(&mmap_list.head);
1002
1003 lttng_consumer_stream_array = g_ptr_array_new();
1004
1005 if ((ret = setup_consumer(command_sock_path, threads, ctx)) < 0) {
1006 fprintf(stderr,"error setting up consumer\n");
1a70b8ac 1007 goto error;
16b22a0f
JD
1008 }
1009
1010 available_snapshots = g_ptr_array_new();
1011
1012 /* setup the session */
1013 dom.type = LTTNG_DOMAIN_KERNEL;
1014
eb677852 1015 ret = unlink("/tmp/livesession");
16b22a0f 1016
71c74ca6 1017 lttng_destroy_session("test");
16b22a0f
JD
1018 if ((ret = lttng_create_session("test", "/tmp/livesession")) < 0) {
1019 fprintf(stderr,"error creating the session : %s\n",
1020 helper_lttcomm_get_readable_code(ret));
1a70b8ac 1021 goto error;
16b22a0f
JD
1022 }
1023
1024 if ((handle = lttng_create_handle("test", &dom)) == NULL) {
1025 fprintf(stderr,"error creating handle\n");
1a70b8ac 1026 goto error_session;
16b22a0f
JD
1027 }
1028
050f9cf9
JD
1029 /*
1030 * FIXME : need to let the
1031 * helper_lttng_consumer_thread_receive_fds create the
1032 * socket.
1033 * Cleaner solution ?
1034 */
1035 while (access(command_sock_path, F_OK)) {
1036 sleep(0.1);
1037 }
1038
16b22a0f
JD
1039 if ((ret = lttng_register_consumer(handle, command_sock_path)) < 0) {
1040 fprintf(stderr,"error registering consumer : %s\n",
1041 helper_lttcomm_get_readable_code(ret));
1a70b8ac 1042 goto error_session;
16b22a0f
JD
1043 }
1044
1045 strcpy(chan.name, channel_name);
c78f2cdc 1046 chan.attr.overwrite = 0;
57bff788 1047 if (opt_tid && opt_textdump) {
d2d680e0
JD
1048 chan.attr.subbuf_size = 32768;
1049 chan.attr.num_subbuf = 8;
1050 } else {
1051 chan.attr.subbuf_size = 1048576; /* 1MB */
1052 chan.attr.num_subbuf = 4;
1053 }
16b22a0f
JD
1054 chan.attr.switch_timer_interval = 0;
1055 chan.attr.read_timer_interval = 200;
1056 chan.attr.output = LTTNG_EVENT_MMAP;
1057
1058 if ((ret = lttng_enable_channel(handle, &chan)) < 0) {
b872c906
JD
1059 fprintf(stderr,"error creating channel : %s\n",
1060 helper_lttcomm_get_readable_code(ret));
1a70b8ac 1061 goto error_session;
16b22a0f
JD
1062 }
1063
b872c906
JD
1064 memset(&ev, '\0', sizeof(struct lttng_event));
1065 //sprintf(ev.name, "sched_switch");
57bff788
JD
1066 ev.type = LTTNG_EVENT_TRACEPOINT;
1067 if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) {
1068 fprintf(stderr,"error enabling event : %s\n",
1069 helper_lttcomm_get_readable_code(ret));
1070 goto error_session;
1071 }
16b22a0f 1072
fbbda4da 1073 memset(&ev, '\0', sizeof(struct lttng_event));
6777529d
JD
1074 ev.type = LTTNG_EVENT_SYSCALL;
1075 if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) {
1076 fprintf(stderr,"error enabling syscalls : %s\n",
1077 helper_lttcomm_get_readable_code(ret));
1a70b8ac 1078 goto error_session;
6777529d
JD
1079 }
1080
fbbda4da
JD
1081 /*
1082 memset(&ev, '\0', sizeof(struct lttng_event));
1083 ev.type = LTTNG_EVENT_PROBE;
1084 sprintf(ev.attr.probe.symbol_name, "sys_open");
1085 sprintf(ev.name, "probe_sys_open");
1086 ev.attr.probe.addr = 0;
1087 ev.attr.probe.offset = 0;
1088 if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) {
1089 fprintf(stderr,"error enabling kprobes : %s\n",
1090 helper_lttcomm_get_readable_code(ret));
1091 goto error_session;
1092 }
1093 */
1094
16b22a0f
JD
1095 kctxpid.ctx = LTTNG_EVENT_CONTEXT_PID;
1096 lttng_add_context(handle, &kctxpid, NULL, NULL);
16b22a0f
JD
1097 kctxtid.ctx = LTTNG_EVENT_CONTEXT_TID;
1098 lttng_add_context(handle, &kctxtid, NULL, NULL);
57bff788
JD
1099 kctxppid.ctx = LTTNG_EVENT_CONTEXT_PPID;
1100 lttng_add_context(handle, &kctxppid, NULL, NULL);
1101 kctxcomm.ctx = LTTNG_EVENT_CONTEXT_PROCNAME;
1102 lttng_add_context(handle, &kctxcomm, NULL, NULL);
1103 kctxpid.ctx = LTTNG_EVENT_CONTEXT_VPID;
1104 lttng_add_context(handle, &kctxpid, NULL, NULL);
1105 kctxtid.ctx = LTTNG_EVENT_CONTEXT_VTID;
1106 lttng_add_context(handle, &kctxtid, NULL, NULL);
c8d75a13
JD
1107 kctxtid.ctx = LTTNG_EVENT_CONTEXT_HOSTNAME;
1108 lttng_add_context(handle, &kctxtid, NULL, NULL);
16b22a0f
JD
1109
1110 if ((ret = lttng_start_tracing("test")) < 0) {
b872c906
JD
1111 fprintf(stderr,"error starting tracing : %s\n",
1112 helper_lttcomm_get_readable_code(ret));
1a70b8ac 1113 goto error_session;
16b22a0f
JD
1114 }
1115
1116 helper_kernctl_buffer_flush(consumerd_metadata);
e91044a8 1117
16b22a0f 1118 /* block until metadata is ready */
4e6aeb3d 1119 sem_init(&metadata_available, 0, 0);
16b22a0f 1120
1a70b8ac
JD
1121 return 0;
1122
1123error_session:
1124 lttng_destroy_session("test");
1125error:
1126 return -1;
16b22a0f
JD
1127}
1128
1fc22eb4
JD
1129int main(int argc, char **argv)
1130{
1131 int ret;
1132 struct bt_context *bt_ctx = NULL;
050f9cf9
JD
1133 struct mmap_stream *mmap_info;
1134 unsigned long mmap_len;
1fc22eb4
JD
1135
1136 ret = parse_options(argc, argv);
1137 if (ret < 0) {
1138 fprintf(stdout, "Error parsing options.\n\n");
1139 usage(stdout);
1140 exit(EXIT_FAILURE);
1141 } else if (ret > 0) {
1142 exit(EXIT_SUCCESS);
1143 }
1144
16b22a0f 1145 if (!opt_input_path) {
24797198
JD
1146 if (opt_textdump) {
1147 signal(SIGTERM, handle_textdump_sigterm);
1148 signal(SIGINT, handle_textdump_sigterm);
1149 }
1a70b8ac
JD
1150 ret = setup_live_tracing();
1151 if (ret < 0) {
1152 goto end;
1153 }
6777529d
JD
1154 init_lttngtop();
1155 if (!opt_textdump) {
1156 pthread_create(&display_thread, NULL, ncurses_display, (void *) NULL);
1157 pthread_create(&timer_thread, NULL, refresh_thread, (void *) NULL);
1158 }
050f9cf9
JD
1159 while (!quit) {
1160 reload_trace = 0;
1161 live_consume(&bt_ctx);
1162 iter_trace(bt_ctx);
1163 ret = bt_context_remove_trace(bt_ctx, 0);
1164 if (ret != 0)
1165 fprintf(stderr, "error removing trace\n");
1166 if (bt_ctx) {
1167 bt_context_put(bt_ctx);
1168 }
1169
1170 /*
1171 * since we receive all FDs every time there is an
1172 * update and the FD number is different every time,
1173 * we don't know which one are valid.
1174 * so we check if all FDs are usable with a simple
1175 * ioctl call.
1176 */
1177 bt_list_for_each_entry(mmap_info, &mmap_list.head, list) {
1178 ret = helper_kernctl_get_mmap_len(mmap_info->fd, &mmap_len);
1179 if (ret != 0) {
050f9cf9
JD
1180 bt_list_del(&mmap_info->list);
1181 }
1182 }
1183 sem_post(&metadata_available);
1184 }
eb677852 1185
ae9e85c7 1186 pthread_join(timer_thread, NULL);
eb677852
JD
1187 quit = 1;
1188 pthread_join(display_thread, NULL);
6777529d 1189
c78f2cdc 1190 lttng_stop_tracing("test");
c78f2cdc
JD
1191 lttng_destroy_session("test");
1192
1fc22eb4 1193 goto end;
16b22a0f
JD
1194 } else {
1195 init_lttngtop();
1196
1197 bt_ctx = bt_context_create();
1198 ret = bt_context_add_traces_recursive(bt_ctx, opt_input_path, "ctf", NULL);
1199 if (ret < 0) {
1200 fprintf(stderr, "[error] Opening the trace\n");
1201 goto end;
1202 }
1fc22eb4 1203
16b22a0f
JD
1204 ret = check_requirements(bt_ctx);
1205 if (ret < 0) {
1206 fprintf(stderr, "[error] some mandatory contexts were missing, exiting.\n");
1207 goto end;
1208 }
1209 pthread_create(&display_thread, NULL, ncurses_display, (void *) NULL);
1210 pthread_create(&timer_thread, NULL, refresh_thread, (void *) NULL);
1fc22eb4 1211
16b22a0f 1212 iter_trace(bt_ctx);
1fc22eb4 1213
16b22a0f 1214 pthread_join(display_thread, NULL);
ae9e85c7 1215 quit = 1;
16b22a0f
JD
1216 pthread_join(timer_thread, NULL);
1217 }
1fc22eb4
JD
1218
1219end:
16b22a0f
JD
1220 if (bt_ctx)
1221 bt_context_put(bt_ctx);
1222
1fc22eb4
JD
1223 return 0;
1224}
This page took 0.0820380000000001 seconds and 4 git commands to generate.