4 * Babeltrace CTF Text Output Plugin Event Printing
6 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include <babeltrace/ctf-ir/event.h>
30 #include <babeltrace/ctf-ir/event-class.h>
31 #include <babeltrace/ctf-ir/stream.h>
32 #include <babeltrace/ctf-ir/stream-class.h>
33 #include <babeltrace/ctf-ir/clock.h>
37 int64_t real_timestamp
; /* Relative to UNIX epoch. */
38 uint64_t clock_value
; /* In cycles. */
42 void print_timestamp_cycles(struct text_component
*text
,
43 struct bt_ctf_clock
*clock
,
44 struct bt_ctf_event
*event
)
46 fputs("00000000000000000000", text
->out
);
50 void print_timestamp_wall(struct text_component
*text
,
51 struct bt_ctf_clock
*clock
,
52 struct bt_ctf_event
*event
)
54 fputs("??:??:??.?????????", text
->out
);
58 enum bt_component_status
get_event_timestamp(struct bt_ctf_event
*event
)
61 uint64_t value, frequency;
62 int64_t offset_s, offset;
64 return BT_COMPONENT_STATUS_OK
;
68 enum bt_component_status
print_event_timestamp(struct text_component
*text
,
69 struct bt_ctf_event
*event
)
71 bool print_names
= text
->options
.print_header_field_names
;
72 enum bt_component_status ret
= BT_COMPONENT_STATUS_OK
;
73 struct bt_ctf_stream
*stream
;
74 struct bt_ctf_clock
*clock
= NULL
;
75 FILE *out
= text
->out
;
76 FILE *err
= text
->err
;
77 uint64_t real_timestamp
;
79 stream
= bt_ctf_event_get_stream(event
);
81 ret
= BT_COMPONENT_STATUS_ERROR
;
85 clock
= bt_ctf_event_get_clock(event
);
87 /* Stream has no timestamp. */
88 //puts("no_timestamp!");
92 fputs(print_names
? "timestamp = " : "[", out
);
93 if (text
->options
.print_timestamp_cycles
) {
94 print_timestamp_cycles(text
, clock
, event
);
96 print_timestamp_wall(text
, clock
, event
);
99 fputs(print_names
? ", " : "] ", out
);
100 if (!text
->options
.print_delta_field
) {
110 enum bt_component_status
print_event_header(struct text_component
*text
,
111 struct bt_ctf_event
*event
)
113 enum bt_component_status ret
;
114 struct bt_ctf_event_class
*event_class
= bt_ctf_event_get_class(event
);
116 ret
= print_event_timestamp(text
, event
);
117 if (ret
!= BT_COMPONENT_STATUS_OK
) {
121 fputs(bt_ctf_event_class_get_name(event_class
), text
->out
);
127 enum bt_component_status
text_print_event(struct text_component
*text
,
128 struct bt_ctf_event
*event
)
130 enum bt_component_status ret
;
132 ret
= print_event_header(text
, event
);
133 if (ret
!= BT_COMPONENT_STATUS_OK
) {
137 fputc('\n', text
->out
);