tap-driver.sh: flush stdout after each test result
[babeltrace.git] / plugins / ctf / fs-sink / fs-sink-stream.h
CommitLineData
15fe47e0
PP
1#ifndef BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H
2#define BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H
3
4/*
5 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
3fadfbc0
MJ
26#include <babeltrace2/babeltrace-internal.h>
27#include <babeltrace2/babeltrace.h>
28#include <babeltrace2/ctfser-internal.h>
15fe47e0
PP
29#include <glib.h>
30#include <stdbool.h>
31#include <stdint.h>
32
33#include "fs-sink-ctf-meta.h"
34
35struct fs_sink_trace;
36
37struct fs_sink_stream {
38 struct fs_sink_trace *trace;
39 struct bt_ctfser ctfser;
40
41 /* Stream's file name */
42 GString *file_name;
43
44 /* Weak */
45 const bt_stream *ir_stream;
46
47 struct fs_sink_ctf_stream_class *sc;
48
491c35cc 49 /* Current packet's state */
15fe47e0 50 struct {
491c35cc
PP
51 /*
52 * True if we're, for this stream, within an opened
53 * packet (got a packet beginning message, but no
54 * packet end message yet).
55 */
15fe47e0 56 bool is_open;
491c35cc
PP
57
58 /*
59 * Current beginning default clock snapshot for the
60 * current packet (`UINT64_C(-1)` if not set).
61 */
15fe47e0 62 uint64_t beginning_cs;
491c35cc
PP
63
64 /*
65 * Current end default clock snapshot for the current
66 * packet (`UINT64_C(-1)` if not set).
67 */
15fe47e0 68 uint64_t end_cs;
491c35cc
PP
69
70 /*
71 * Current packet's content size (bits) for the current
72 * packet.
73 */
15fe47e0 74 uint64_t content_size;
491c35cc
PP
75
76 /*
77 * Current packet's total size (bits) for the current
78 * packet.
79 */
15fe47e0 80 uint64_t total_size;
491c35cc
PP
81
82 /*
83 * Discarded events (free running) counter for the
84 * current packet.
85 */
15fe47e0 86 uint64_t discarded_events_counter;
491c35cc
PP
87
88 /* Sequence number (free running) of the current packet */
15fe47e0 89 uint64_t seq_num;
491c35cc
PP
90
91 /*
92 * Offset of the packet context structure within the
93 * current packet (bits).
94 */
15fe47e0
PP
95 uint64_t context_offset_bits;
96
97 /* Owned by this */
98 const bt_packet *packet;
99 } packet_state;
100
491c35cc 101 /* Previous packet's state */
15fe47e0 102 struct {
491c35cc 103 /* End default clock snapshot (`UINT64_C(-1)` if not set) */
15fe47e0 104 uint64_t end_cs;
491c35cc
PP
105
106 /* Discarded events (free running) counter */
15fe47e0 107 uint64_t discarded_events_counter;
491c35cc
PP
108
109 /* Sequence number (free running) */
15fe47e0
PP
110 uint64_t seq_num;
111 } prev_packet_state;
112
491c35cc 113 /* State to handle discarded events */
15fe47e0 114 struct {
491c35cc
PP
115 /*
116 * True if we're in the time range given by a previously
117 * received discarded events message. In this case,
118 * `beginning_cs` and `end_cs` below contain the
119 * beginning and end clock snapshots for this range.
120 *
121 * This is used to validate that, when receiving a
122 * packet end message, the current discarded events time
123 * range matches what's expected for CTF 1.8, that is:
124 *
125 * * Its beginning time is the previous packet's end
126 * time (or the current packet's beginning time if
127 * this is the first packet).
128 *
129 * * Its end time is the current packet's end time.
130 */
15fe47e0 131 bool in_range;
491c35cc
PP
132
133 /*
134 * Beginning and end times of the time range given by a
135 * previously received discarded events message.
136 */
15fe47e0
PP
137 uint64_t beginning_cs;
138 uint64_t end_cs;
139 } discarded_events_state;
140
491c35cc 141 /* State to handle discarded packets */
15fe47e0 142 struct {
491c35cc
PP
143 /*
144 * True if we're in the time range given by a previously
145 * received discarded packets message. In this case,
146 * `beginning_cs` and `end_cs` below contain the
147 * beginning and end clock snapshots for this range.
148 *
149 * This is used to validate that, when receiving a
150 * packet beginning message, the current discarded
151 * packets time range matches what's expected for CTF
152 * 1.8, that is:
153 *
154 * * Its beginning time is the previous packet's end
155 * time.
156 *
157 * * Its end time is the current packet's beginning
158 * time.
159 */
15fe47e0 160 bool in_range;
491c35cc
PP
161
162 /*
163 * Beginning and end times of the time range given by a
164 * previously received discarded packets message.
165 */
15fe47e0
PP
166 uint64_t beginning_cs;
167 uint64_t end_cs;
168 } discarded_packets_state;
15fe47e0
PP
169};
170
171BT_HIDDEN
172struct fs_sink_stream *fs_sink_stream_create(struct fs_sink_trace *trace,
173 const bt_stream *ir_stream);
174
175BT_HIDDEN
176void fs_sink_stream_destroy(struct fs_sink_stream *stream);
177
178BT_HIDDEN
179int fs_sink_stream_write_event(struct fs_sink_stream *stream,
180 const bt_clock_snapshot *cs, const bt_event *event,
181 struct fs_sink_ctf_event_class *ec);
182
183BT_HIDDEN
184int fs_sink_stream_open_packet(struct fs_sink_stream *stream,
185 const bt_clock_snapshot *cs, const bt_packet *packet);
186
187BT_HIDDEN
188int fs_sink_stream_close_packet(struct fs_sink_stream *stream,
189 const bt_clock_snapshot *cs);
190
191#endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_STREAM_H */
This page took 0.032369 seconds and 4 git commands to generate.