Commit | Line | Data |
---|---|---|
490db841 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
490db841 | 3 | * |
f3bc2010 | 4 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
56a1cced | 5 | * Copyright 2016 Philippe Proulx <pproulx@efficios.com> |
490db841 | 6 | * |
0235b0db | 7 | * BabelTrace - CTF on File System Component |
490db841 JG |
8 | */ |
9 | ||
ae2be88d SM |
10 | #ifndef BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP |
11 | #define BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP | |
0235b0db | 12 | |
c7e1be4b | 13 | #include <glib.h> |
c802cacb | 14 | |
c7e1be4b | 15 | #include <babeltrace2/babeltrace.h> |
c802cacb | 16 | |
0f5c5d5c SM |
17 | #include "cpp-common/bt2c/logging.hpp" |
18 | ||
cdf7de78 | 19 | #include "data-stream-file.hpp" |
1fa280c9 | 20 | #include "plugins/ctf/common/src/metadata/tsdl/decoder.hpp" |
490db841 | 21 | |
78bb6992 | 22 | extern bool ctf_fs_debug; |
56a1cced | 23 | |
4164020e SM |
24 | struct ctf_fs_metadata |
25 | { | |
2dba3a29 SM |
26 | using UP = std::unique_ptr<ctf_fs_metadata>; |
27 | ||
4164020e | 28 | /* Owned by this */ |
1fa280c9 | 29 | ctf_metadata_decoder_up decoder; |
44c440bc | 30 | |
ded1f3d6 | 31 | bt2::TraceClass::Shared trace_class; |
1a9f7075 | 32 | |
4164020e | 33 | /* Weak (owned by `decoder` above) */ |
afb0f12b | 34 | struct ctf_trace_class *tc = nullptr; |
44c440bc | 35 | |
afb0f12b | 36 | int bo = 0; |
56a1cced JG |
37 | }; |
38 | ||
4164020e SM |
39 | struct ctf_fs_trace |
40 | { | |
e001dd28 | 41 | using UP = std::unique_ptr<ctf_fs_trace>; |
7df773f2 | 42 | |
0f5c5d5c SM |
43 | explicit ctf_fs_trace(const bt2c::Logger& parentLogger) : |
44 | logger {parentLogger, "PLUGIN/SRC.CTF.FS/TRACE"} | |
45 | { | |
46 | } | |
98903a3e | 47 | |
0f5c5d5c | 48 | bt2c::Logger logger; |
4c65a157 | 49 | |
2dba3a29 | 50 | ctf_fs_metadata::UP metadata; |
1a9f7075 | 51 | |
e44859b1 | 52 | bt2::Trace::Shared trace; |
862ca4ed | 53 | |
cdf7de78 | 54 | std::vector<ctf_fs_ds_file_group::UP> ds_file_groups; |
94cf822e | 55 | |
cee8a466 | 56 | std::string path; |
1a9f7075 | 57 | |
4164020e | 58 | /* Next automatic stream ID when not provided by packet header */ |
afb0f12b | 59 | uint64_t next_stream_id = 0; |
1a9f7075 PP |
60 | }; |
61 | ||
09721481 SM |
62 | struct ctf_fs_port_data |
63 | { | |
945312a2 SM |
64 | using UP = std::unique_ptr<ctf_fs_port_data>; |
65 | ||
09721481 SM |
66 | /* Weak, belongs to ctf_fs_trace */ |
67 | struct ctf_fs_ds_file_group *ds_file_group = nullptr; | |
68 | ||
69 | /* Weak */ | |
70 | struct ctf_fs_component *ctf_fs = nullptr; | |
71 | }; | |
72 | ||
09721481 SM |
73 | struct ctf_fs_component |
74 | { | |
57ec0a35 | 75 | using UP = std::unique_ptr<ctf_fs_component>; |
09721481 | 76 | |
e1d200e5 SM |
77 | explicit ctf_fs_component(const ctf::src::ClkClsCfg& clkClsCfgParam, |
78 | const bt2c::Logger& parentLogger) noexcept : | |
79 | logger {parentLogger, "PLUGIN/SRC.CTF.FS/COMP"}, | |
80 | clkClsCfg {clkClsCfgParam} | |
09721481 SM |
81 | { |
82 | } | |
83 | ||
84 | bt2c::Logger logger; | |
85 | ||
945312a2 | 86 | std::vector<ctf_fs_port_data::UP> port_data; |
09721481 | 87 | |
7df773f2 | 88 | ctf_fs_trace::UP trace; |
09721481 SM |
89 | |
90 | ctf::src::ClkClsCfg clkClsCfg; | |
91 | }; | |
92 | ||
4164020e SM |
93 | struct ctf_fs_msg_iter_data |
94 | { | |
adf452d1 SM |
95 | using UP = std::unique_ptr<ctf_fs_msg_iter_data>; |
96 | ||
0f5c5d5c | 97 | explicit ctf_fs_msg_iter_data(bt_self_message_iterator *selfMsgIter) : |
f482fba8 SM |
98 | self_msg_iter {selfMsgIter}, |
99 | logger {bt2::SelfMessageIterator {self_msg_iter}, "PLUGIN/SRC.CTF.FS/MSG-ITER"} | |
0f5c5d5c SM |
100 | { |
101 | } | |
4c65a157 | 102 | |
4164020e | 103 | /* Weak */ |
afb0f12b | 104 | bt_self_message_iterator *self_msg_iter = nullptr; |
5c563278 | 105 | |
0f5c5d5c SM |
106 | bt2c::Logger logger; |
107 | ||
4164020e | 108 | /* Weak, belongs to ctf_fs_trace */ |
afb0f12b | 109 | struct ctf_fs_ds_file_group *ds_file_group = nullptr; |
94cf822e | 110 | |
537fddc0 | 111 | ctf_msg_iter_up msg_iter; |
cbca1c06 | 112 | |
4164020e SM |
113 | /* |
114 | * Saved error. If we hit an error in the _next method, but have some | |
115 | * messages ready to return, we save the error here and return it on | |
116 | * the next _next call. | |
117 | */ | |
afb0f12b SM |
118 | bt_message_iterator_class_next_method_status next_saved_status = |
119 | BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; | |
120 | const struct bt_error *next_saved_error = nullptr; | |
f6e68e70 | 121 | |
3cf88182 | 122 | ctf_fs_ds_group_medops_data_up msg_iter_medops_data; |
94cf822e PP |
123 | }; |
124 | ||
4164020e SM |
125 | bt_component_class_initialize_method_status |
126 | ctf_fs_init(bt_self_component_source *source, bt_self_component_source_configuration *config, | |
127 | const bt_value *params, void *init_method_data); | |
490db841 | 128 | |
b19ff26f | 129 | void ctf_fs_finalize(bt_self_component_source *component); |
d3e4dcd8 | 130 | |
4164020e SM |
131 | bt_component_class_query_method_status ctf_fs_query(bt_self_component_class_source *comp_class, |
132 | bt_private_query_executor *priv_query_exec, | |
133 | const char *object, const bt_value *params, | |
134 | void *method_data, const bt_value **result); | |
55314f2a | 135 | |
4164020e SM |
136 | bt_message_iterator_class_initialize_method_status |
137 | ctf_fs_iterator_init(bt_self_message_iterator *self_msg_iter, | |
138 | bt_self_message_iterator_configuration *config, | |
139 | bt_self_component_port_output *self_port); | |
d94d92ac | 140 | |
d6e69534 | 141 | void ctf_fs_iterator_finalize(bt_self_message_iterator *it); |
d3eb6e8f | 142 | |
4164020e SM |
143 | bt_message_iterator_class_next_method_status |
144 | ctf_fs_iterator_next(bt_self_message_iterator *iterator, bt_message_array_const msgs, | |
145 | uint64_t capacity, uint64_t *count); | |
d3eb6e8f | 146 | |
4164020e SM |
147 | bt_message_iterator_class_seek_beginning_method_status |
148 | ctf_fs_iterator_seek_beginning(bt_self_message_iterator *message_iterator); | |
6a9bb5e9 | 149 | |
f280892e | 150 | /* |
a0cd55ad SM |
151 | * Create one `struct ctf_fs_trace` from one trace, or multiple traces sharing |
152 | * the same UUID. | |
153 | * | |
154 | * `paths_value` must be an array of strings, | |
155 | * | |
156 | * The created `struct ctf_fs_trace` is assigned to `ctf_fs->trace`. | |
d23b766e SM |
157 | * |
158 | * `self_comp` and `self_comp_class` are used for logging, only one of them | |
159 | * should be set. | |
f280892e SM |
160 | */ |
161 | ||
4164020e | 162 | int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs, |
c5a5a936 | 163 | bt2::ConstArrayValue pathsValue, const char *traceName, |
0f5c5d5c | 164 | bt_self_component *selfComp); |
f280892e | 165 | |
c5a5a936 SM |
166 | namespace ctf { |
167 | namespace src { | |
168 | namespace fs { | |
169 | ||
170 | /* `src.ctf.fs` parameters */ | |
171 | ||
172 | struct Parameters | |
173 | { | |
174 | explicit Parameters(const bt2::ConstArrayValue inputsParam) noexcept : inputs {inputsParam} | |
175 | { | |
176 | } | |
177 | ||
178 | bt2::ConstArrayValue inputs; | |
179 | bt2s::optional<std::string> traceName; | |
180 | ClkClsCfg clkClsCfg; | |
181 | }; | |
182 | ||
183 | } /* namespace fs */ | |
184 | } /* namespace src */ | |
185 | } /* namespace ctf */ | |
186 | ||
d907165c SM |
187 | /* |
188 | * Read and validate parameters taken by the src.ctf.fs plugin. | |
189 | * | |
c5a5a936 | 190 | * Throw if any parameter doesn't pass validation. |
d907165c | 191 | */ |
f280892e | 192 | |
c5a5a936 SM |
193 | ctf::src::fs::Parameters read_src_fs_parameters(bt2::ConstMapValue params, |
194 | const bt2c::Logger& logger); | |
f280892e | 195 | |
a38d7650 SM |
196 | /* |
197 | * Generate the port name to be used for a given data stream file group. | |
a38d7650 SM |
198 | */ |
199 | ||
3045bbcb | 200 | std::string ctf_fs_make_port_name(ctf_fs_ds_file_group *ds_file_group); |
a38d7650 | 201 | |
ae2be88d | 202 | #endif /* BABELTRACE_PLUGINS_CTF_FS_SRC_FS_HPP */ |