#include <babeltrace/ctf-ir/packet.h>
#include <babeltrace/ctf-ir/stream.h>
#include <babeltrace/ctf-ir/stream-class.h>
-#include <babeltrace/ctf-ir/clock.h>
+#include <babeltrace/ctf-ir/clock-class.h>
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/trace.h>
static
void print_timestamp_cycles(struct text_component *text,
- struct bt_ctf_clock *clock,
+ struct bt_ctf_clock_class *clock_class,
struct bt_ctf_event *event)
{
int ret;
struct bt_ctf_clock_value *clock_value;
uint64_t cycles;
- clock_value = bt_ctf_event_get_clock_value(event, clock);
+ clock_value = bt_ctf_event_get_clock_value(event, clock_class);
if (!clock_value) {
fputs("????????????????????", text->out);
return;
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
void print_timestamp_wall(struct text_component *text,
- struct bt_ctf_clock *clock,
+ struct bt_ctf_clock_class *clock_class,
struct bt_ctf_event *event)
{
int ret;
uint64_t ts_sec_abs, ts_nsec_abs;
bool is_negative;
- clock_value = bt_ctf_event_get_clock_value(event, clock);
+ clock_value = bt_ctf_event_get_clock_value(event, clock_class);
if (!clock_value) {
fputs("??:??:??.?????????", text->out);
return;
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) {
struct bt_ctf_stream *stream = NULL;
struct bt_ctf_stream_class *stream_class = NULL;
struct bt_ctf_trace *trace = NULL;
- struct bt_ctf_clock *clock = NULL;
+ struct bt_ctf_clock_class *clock_class = NULL;
FILE *out = text->out;
- FILE *err = text->err;
- uint64_t real_timestamp;
stream = bt_ctf_event_get_stream(event);
if (!stream) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- clock = bt_ctf_trace_get_clock(trace, 0);
- if (!clock) {
+ clock_class = bt_ctf_trace_get_clock_class(trace, 0);
+ if (!clock_class) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
fputs(print_names ? "timestamp = " : "[", out);
if (text->options.print_timestamp_cycles) {
- print_timestamp_cycles(text, clock, event);
+ print_timestamp_cycles(text, clock_class, event);
} else {
- print_timestamp_wall(text, clock, event);
+ print_timestamp_wall(text, clock_class, event);
}
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);
+ }
}
-
- //TODO delta
+ *start_line = !print_names;
end:
bt_put(stream);
- bt_put(clock);
+ bt_put(clock_class);
bt_put(stream_class);
bt_put(trace);
return ret;
}
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) {