+ if (strncmp(bt_ctf_event_name(call_data), "sys_", 4) == 0) {
+ cpu = get_cpu(cpu_id);
+ cpu->current_syscall = g_new0(struct syscall, 1);
+ cpu->current_syscall->name = strdup(bt_ctf_event_name(call_data));
+ cpu->current_syscall->ts_start = timestamp;
+ cpu->current_syscall->cpu_id = cpu_id;
+ last_syscall = cpu->current_syscall;
+ current_syscall = 1;
+ } else if ((strncmp(bt_ctf_event_name(call_data), "exit_syscall", 12)) == 0) {
+ struct tm start_ts;
+
+ /* Return code of a syscall if it was the last displayed event. */
+ if (last_syscall && last_syscall->ts_start == prev_ts) {
+ if (last_syscall->cpu_id == cpu_id) {
+ int64_t syscall_ret;
+
+ delta = timestamp - last_syscall->ts_start;
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ syscall_ret = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_ret"));
+
+ fprintf(output, "= %" PRId64 " (%" PRIu64 ".%09" PRIu64 "s)\n",
+ syscall_ret, delta / NSEC_PER_SEC,
+ delta % NSEC_PER_SEC);
+ last_syscall = NULL;
+ goto end;
+ } else {
+ last_syscall = NULL;
+ fprintf(output, " ...interrupted...\n");
+ }
+ }
+
+ cpu = get_cpu(cpu_id);
+ if (cpu->current_syscall) {
+ delta = timestamp - cpu->current_syscall->ts_start;
+ start_ts = format_timestamp(cpu->current_syscall->ts_start);
+ ret = asprintf(&from_syscall, " [from %02d:%02d:%02d.%09" PRIu64
+ " (+%" PRIu64 ".%09" PRIu64 ") (cpu %d) %s]",
+ start_ts.tm_hour, start_ts.tm_min, start_ts.tm_sec,
+ cpu->current_syscall->ts_start % NSEC_PER_SEC,
+ delta / NSEC_PER_SEC, delta % NSEC_PER_SEC,
+ cpu_id, cpu->current_syscall->name);
+ if (ret < 0) {
+ goto error;
+ }
+ free(cpu->current_syscall->name);
+ g_free(cpu->current_syscall);
+ cpu->current_syscall = NULL;
+ last_syscall = NULL;
+ }
+ }
+