1 // Render with Asciidoctor
3 = barectf Linux FS platform
8 The barectf Linux FS platform is a very simple platform used to
11 The platform writes the CTF packets to a data stream file on the file
14 This platform can also simulate a full back-end randomly with a
17 == barectf configuration requirements
19 * The default `barectf` file name prefix.
21 * The default `barectf_` identifier prefix.
23 * A single data stream type named `default`:
25 ** No extra packet context field type members.
26 ** A default clock type named `default`:
27 Frequency:::: 1000000000 (default)
28 Offsets:::: 0 (default)
29 Origin is Unix epoch?:::: Yes (default)
30 C{nbsp}type:::: `uint64_t`
32 .Compatible YAML configuration
36 --- !<tag:barectf.org,2020/3/config>
48 $default-clock-type-name: default
66 struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
67 unsigned int buf_size, const char *trace_dir, int simulate_full_backend,
68 unsigned int full_backend_rand_max, unsigned int full_backend_rand_lt);
78 |Size of the packet buffer to allocate (bytes).
81 |Path of the directory to which to write the single data stream file
84 |`simulate_full_backend`
87 Disable full back-end simulation.
90 Enable full back-end simulation.
92 |`full_backend_rand_max`
93 |If `simulate_full_backend` is 1, maximum random value.
95 |`full_backend_rand_lt`
96 |If `simulate_full_backend` is 1, the back-end is considered full
97 if the random value is less than `full_backend_rand_lt`.
100 When `simulate_full_backend` is 1, `full_backend_rand_lt` and
101 `full_backend_rand_max` form a ratio. For example, if
102 `full_backend_rand_max` is 5 and `full_backend_rand_lt` is 3, then the
103 probability of having a full back-end is 3/5.
108 An allocated Linux FS platform context.
110 Call <<api-fini,`+barectf_platform_linux_fs_fini()+`>> to finalize and
123 void barectf_platform_linux_fs_fini(struct barectf_platform_linux_fs_ctx *ctx);
132 |Linux FS platform context to finalize and free.
135 === barectf context access
141 struct barectf_default_ctx *barectf_platform_linux_fs_get_barectf_ctx(
142 struct barectf_platform_linux_fs_ctx *ctx);
151 |Linux FS platform context.
156 The barectf context to pass to your tracing functions
157 (`+barectf_default_trace_*()+`).
164 --- !<tag:barectf.org,2020/3/config>
169 target-byte-order: le
176 $default-clock-type-name: default
190 #include "barectf-platform-linux-fs.h"
195 struct barectf_platform_linux_fs_ctx *platform_ctx;
196 struct barectf_default_ctx *barectf_ctx;
199 platform_ctx = barectf_platform_linux_fs_init(256, "trace", 0, 0, 0);
200 assert(platform_ctx);
201 barectf_ctx = barectf_platform_linux_fs_get_barectf_ctx(platform_ctx);
203 for (i = 0; i < 50; ++i) {
204 barectf_trace_my_event(barectf_ctx, i);
207 barectf_platform_linux_fs_fini(platform_ctx);
212 .Command lines to build and execute the example
215 $ barectf --metadata-dir=trace config.yaml
216 $ gcc -o example -I. example.c barectf.c barectf-platform-linux-fs.c
220 The complete CTF trace is the `trace` directory.
222 Read it with https://babeltrace.org/[Babeltrace{nbsp}2], for example:
229 [20:55:29.539931489] (+?.?????????) my_event: { number = 0 }
230 [20:55:29.539932347] (+0.000000858) my_event: { number = 1 }
231 [20:55:29.539932698] (+0.000000351) my_event: { number = 2 }
232 [20:55:29.539932985] (+0.000000287) my_event: { number = 3 }
233 [20:55:29.539933379] (+0.000000394) my_event: { number = 4 }
234 [20:55:29.539933684] (+0.000000305) my_event: { number = 5 }
236 [20:55:29.539965071] (+0.000000277) my_event: { number = 44 }
237 [20:55:29.539965356] (+0.000000285) my_event: { number = 45 }
238 [20:55:29.539965622] (+0.000000266) my_event: { number = 46 }
239 [20:55:29.539965903] (+0.000000281) my_event: { number = 47 }
240 [20:55:29.539966181] (+0.000000278) my_event: { number = 48 }
241 [20:55:29.539966518] (+0.000000337) my_event: { number = 49 }