Commit | Line | Data |
---|---|---|
46322b33 MD |
1 | #ifndef _BABELTRACE_CTF_TEXT_TYPES_H |
2 | #define _BABELTRACE_CTF_TEXT_TYPES_H | |
3 | ||
4 | /* | |
5 | * Common Trace Format (Text Output) | |
6 | * | |
7 | * Type header | |
8 | * | |
9 | * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
12 | * of this software and associated documentation files (the "Software"), to deal | |
13 | * in the Software without restriction, including without limitation the rights | |
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
15 | * copies of the Software, and to permit persons to whom the Software is | |
16 | * furnished to do so, subject to the following conditions: | |
17 | * | |
18 | * The above copyright notice and this permission notice shall be included in | |
19 | * all copies or substantial portions of the Software. | |
c462e188 MD |
20 | * |
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
27 | * SOFTWARE. | |
46322b33 MD |
28 | */ |
29 | ||
30 | #include <sys/mman.h> | |
31 | #include <errno.h> | |
32 | #include <stdint.h> | |
33 | #include <unistd.h> | |
34 | #include <glib.h> | |
70bd0a12 | 35 | #include <babeltrace/babeltrace-internal.h> |
46322b33 | 36 | #include <babeltrace/types.h> |
1ae19169 | 37 | #include <babeltrace/format.h> |
caf929fa | 38 | #include <babeltrace/format-internal.h> |
46322b33 | 39 | |
1ae19169 | 40 | /* |
1b8455b7 | 41 | * Inherit from both struct bt_stream_pos and struct bt_trace_descriptor. |
1ae19169 | 42 | */ |
46322b33 | 43 | struct ctf_text_stream_pos { |
1cf393f6 | 44 | struct bt_stream_pos parent; |
1b8455b7 | 45 | struct bt_trace_descriptor trace_descriptor; |
46322b33 | 46 | FILE *fp; /* File pointer. NULL if unset. */ |
1ae19169 MD |
47 | int depth; |
48 | int dummy; /* disable output */ | |
31262354 | 49 | int print_names; /* print field names */ |
fd3382e8 | 50 | int field_nr; |
03798a93 JD |
51 | uint64_t last_real_timestamp; /* to print delta */ |
52 | uint64_t last_cycles_timestamp; /* to print delta */ | |
81dee1bb | 53 | GString *string; /* Current string */ |
46322b33 MD |
54 | }; |
55 | ||
1ae19169 | 56 | static inline |
1cf393f6 | 57 | struct ctf_text_stream_pos *ctf_text_pos(struct bt_stream_pos *pos) |
1ae19169 MD |
58 | { |
59 | return container_of(pos, struct ctf_text_stream_pos, parent); | |
60 | } | |
61 | ||
46322b33 | 62 | /* |
1ae19169 | 63 | * Write only is supported for now. |
46322b33 | 64 | */ |
90b55a97 | 65 | BT_HIDDEN |
0d69b916 | 66 | int ctf_text_integer_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 67 | BT_HIDDEN |
0d69b916 | 68 | int ctf_text_float_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 69 | BT_HIDDEN |
0d69b916 | 70 | int ctf_text_string_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 71 | BT_HIDDEN |
0d69b916 | 72 | int ctf_text_enum_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 73 | BT_HIDDEN |
0d69b916 | 74 | int ctf_text_struct_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 75 | BT_HIDDEN |
0d69b916 | 76 | int ctf_text_variant_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 77 | BT_HIDDEN |
0d69b916 | 78 | int ctf_text_array_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
90b55a97 | 79 | BT_HIDDEN |
0d69b916 | 80 | int ctf_text_sequence_write(struct bt_stream_pos *pos, struct bt_definition *definition); |
46322b33 | 81 | |
1ae19169 MD |
82 | static inline |
83 | void print_pos_tabs(struct ctf_text_stream_pos *pos) | |
84 | { | |
85 | int i; | |
46322b33 | 86 | |
1ae19169 MD |
87 | for (i = 0; i < pos->depth; i++) |
88 | fprintf(pos->fp, "\t"); | |
89 | } | |
46322b33 | 90 | |
d335f0f7 MD |
91 | /* |
92 | * Check if the field must be printed. | |
93 | */ | |
90b55a97 | 94 | BT_HIDDEN |
0d69b916 | 95 | int print_field(struct bt_definition *definition); |
d335f0f7 | 96 | |
46322b33 | 97 | #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */ |