+void print_fields(struct bt_ctf_event *event, const char *procname,
+ int pid)
+{
+ unsigned int cnt, i;
+ const struct bt_definition *const * list;
+ const struct bt_declaration *l;
+ const struct bt_definition *scope;
+ enum ctf_type_id type;
+ const char *str;
+ struct processtop *current_proc;
+ struct files *current_file;
+ int fd, fd_value = -1;
+
+ scope = bt_ctf_get_top_level_scope(event, BT_EVENT_FIELDS);
+
+ bt_ctf_get_field_list(event, scope, &list, &cnt);
+ for (i = 0; i < cnt; i++) {
+ if (i != 0)
+ fprintf(output, ", ");
+ fprintf(output, "%s = ", bt_ctf_field_name(list[i]));
+ l = bt_ctf_get_decl_from_def(list[i]);
+ if (strncmp(bt_ctf_field_name(list[i]), "fd", 2) == 0)
+ fd = 1;
+ else
+ fd = 0;
+ type = bt_ctf_field_type(l);
+ if (type == CTF_TYPE_INTEGER) {
+ if (bt_ctf_get_int_signedness(l) == 0) {
+ fd_value = bt_ctf_get_uint64(list[i]);
+ fprintf(output, "%" PRIu64, bt_ctf_get_uint64(list[i]));
+ } else {
+ fd_value = bt_ctf_get_int64(list[i]);
+ fprintf(output, "%" PRId64, bt_ctf_get_int64(list[i]));
+ }
+ } else if (type == CTF_TYPE_STRING) {
+ fprintf(output, "%s", bt_ctf_get_string(list[i]));
+ } else if (type == CTF_TYPE_ARRAY) {
+ str = bt_ctf_get_char_array(list[i]);
+ if (!bt_ctf_field_get_error() && str)
+ fprintf(output, "%s", str);
+ }
+ if (fd) {
+ current_proc = find_process_tid(<tngtop, pid, procname);
+ if (!current_proc)
+ continue;
+ current_file = get_file(current_proc, fd_value);
+ if (!current_file || !current_file->name)
+ continue;
+ fprintf(output, "<%s>", current_file->name);
+ }
+ }
+}
+
+/*
+ * hook on each event to check the timestamp and refresh the display if
+ * necessary
+ */
+enum bt_cb_ret textdump(struct bt_ctf_event *call_data, void *private_data)
+{
+ unsigned long timestamp;
+ uint64_t delta;
+ struct tm start;
+ uint64_t ts_nsec_start;
+ int pid, cpu_id, tid, ret, lookup, current_syscall = 0;
+ const struct bt_definition *scope;
+ const char *hostname, *procname;
+ struct cputime *cpu;
+ char *from_syscall = NULL;
+
+ timestamp = bt_ctf_get_timestamp(call_data);
+
+ /* can happen in network live when tracing is idle */
+ if (timestamp < last_event_ts)
+ goto end_stop;
+
+ last_event_ts = timestamp;
+
+ start = format_timestamp(timestamp);
+ ts_nsec_start = timestamp % NSEC_PER_SEC;
+
+ pid = get_context_pid(call_data);
+ if (pid == -1ULL && opt_tid) {
+ goto error;
+ }
+
+ tid = get_context_tid(call_data);
+
+ hostname = get_context_hostname(call_data);
+ if (opt_child)
+ lookup = pid;
+ else
+ lookup = tid;
+ if (opt_tid || opt_hostname || opt_exec_name) {
+ if (!lookup_filter_tid_list(lookup)) {
+ /* To display when a process of ours in getting scheduled in */
+ if (strcmp(bt_ctf_event_name(call_data), "sched_switch") == 0) {
+ int next_tid;
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ next_tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_next_tid"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing next_tid field\n");
+ goto error;
+ }
+ if (!lookup_filter_tid_list(next_tid)) {
+ if (!opt_all)
+ goto end;
+ } else {
+ if (opt_all)
+ fprintf(output, "%c[1m", 27);
+ }
+ } else if (!opt_all) {
+ goto end;
+ }
+ } else {
+ if (opt_all)
+ fprintf(output, "%c[1m", 27);