* Babeltrace CTF Text Output Plugin Event Printing
*
* Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
return;
}
fprintf(text->out, "%020" PRIu64, cycles);
+
+ if (text->last_cycles_timestamp != -1ULL) {
+ text->delta_cycles = cycles - text->last_cycles_timestamp;
+ }
+ text->last_cycles_timestamp = cycles;
}
static
return;
}
+ if (text->last_real_timestamp != -1ULL) {
+ text->delta_real_timestamp = ts_nsec - text->last_real_timestamp;
+ }
+ text->last_real_timestamp = ts_nsec;
+
ts_sec += ts_nsec / NSEC_PER_SEC;
ts_nsec = ts_nsec % NSEC_PER_SEC;
if (ts_sec >= 0 && ts_nsec >= 0) {
ts_nsec_abs = -ts_nsec;
}
- if (/*!opt_clock_seconds*/true) {
+ if (!text->options.clock_seconds) {
struct tm tm;
time_t time_s = (time_t) ts_sec_abs;
goto seconds;
}
- if (/*!opt_clock_gmt*/true) {
+ if (!text->options.clock_gmt) {
struct tm *res;
res = localtime_r(&time_s, &tm);
goto seconds;
}
}
- if (/*opt_clock_date*/false) {
+ if (text->options.clock_date) {
char timestr[26];
size_t res;
struct bt_ctf_trace *trace = NULL;
struct bt_ctf_clock *clock = NULL;
FILE *out = text->out;
- FILE *err = text->err;
- uint64_t real_timestamp;
stream = bt_ctf_event_get_stream(event);
if (!stream) {
goto end;
}
- /* FIXME - error checking */
stream_class = bt_ctf_stream_get_class(stream);
+ if (!stream_class) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
trace = bt_ctf_stream_class_get_trace(stream_class);
+ if (!trace) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
clock = bt_ctf_trace_get_clock(trace, 0);
+ if (!clock) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
fputs(print_names ? "timestamp = " : "[", out);
if (text->options.print_timestamp_cycles) {
if (!print_names)
fputs("] ", out);
- *start_line = !print_names;
- if (!text->options.print_delta_field) {
- goto end;
+ if (text->options.print_delta_field) {
+ if (print_names)
+ fputs(", delta = ", text->out);
+ else
+ fputs("(", text->out);
+ if (text->options.print_timestamp_cycles) {
+ if (text->delta_cycles == -1ULL) {
+ fputs("+??????????\?\?) ", text->out); /* Not a trigraph. */
+ } else {
+ fprintf(text->out, "+%012" PRIu64, text->delta_cycles);
+ }
+ } else {
+ if (text->delta_real_timestamp != -1ULL) {
+ uint64_t delta_sec, delta_nsec, delta;
+
+ delta = text->delta_real_timestamp;
+ delta_sec = delta / NSEC_PER_SEC;
+ delta_nsec = delta % NSEC_PER_SEC;
+ fprintf(text->out, "+%" PRIu64 ".%09" PRIu64,
+ delta_sec, delta_nsec);
+ } else {
+ fputs("+?.?????????", text->out);
+ }
+ }
+ if (!print_names) {
+ fputs(") ", text->out);
+ }
}
+ *start_line = !print_names;
+
end:
bt_put(stream);
bt_put(clock);
bt_put(uri_str);
}
}
- if (text->options.print_callsite_field) {
- if (!text->start_line) {
- fputs(", ", text->out);
- }
- text->start_line = false;
- if (print_names) {
- fputs("callsite = ", text->out);
- }
- /* TODO */
- }
if (!text->start_line) {
fputs(", ", text->out);
}
}
main_field = bt_ctf_packet_get_context(packet);
if (!main_field) {
- ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
if (!text->start_line) {
main_field = bt_ctf_event_get_header(event);
if (!main_field) {
- ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
if (!text->start_line) {
main_field = bt_ctf_event_get_stream_event_context(event);
if (!main_field) {
- ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
if (!text->start_line) {
main_field = bt_ctf_event_get_event_context(event);
if (!main_field) {
- ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
if (!text->start_line) {
main_field = bt_ctf_event_get_payload_field(event);
if (!main_field) {
- ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
if (!text->start_line) {