Commit | Line | Data |
---|---|---|
afd45274 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
afd45274 | 3 | * |
0235b0db | 4 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> |
afd45274 PP |
5 | */ |
6 | ||
3fadfbc0 | 7 | #include <babeltrace2/babeltrace.h> |
91d81473 | 8 | #include "common/macros.h" |
578e048b | 9 | #include "common/assert.h" |
afd45274 PP |
10 | #include <glib.h> |
11 | #include <stdint.h> | |
12 | #include <string.h> | |
13 | #include <inttypes.h> | |
14 | ||
15 | #include "ctf-meta-visitors.h" | |
16 | ||
17 | BT_HIDDEN | |
18 | int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) | |
19 | { | |
20 | struct ctf_field_class_int *int_fc; | |
21 | uint64_t i; | |
22 | ||
23 | for (i = 0; i < ctf_tc->stream_classes->len; i++) { | |
24 | struct ctf_stream_class *sc = | |
25 | ctf_tc->stream_classes->pdata[i]; | |
26 | ||
27 | if (sc->is_translated) { | |
28 | continue; | |
29 | } | |
30 | ||
31 | if (!sc->packet_context_fc) { | |
32 | continue; | |
33 | } | |
34 | ||
35 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( | |
36 | (void *) sc->packet_context_fc, "timestamp_begin"); | |
37 | if (int_fc && int_fc->meaning == | |
38 | CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) { | |
39 | sc->packets_have_ts_begin = true; | |
40 | } | |
41 | ||
42 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( | |
43 | (void *) sc->packet_context_fc, "timestamp_end"); | |
44 | if (int_fc && int_fc->meaning == | |
45 | CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) { | |
46 | sc->packets_have_ts_end = true; | |
47 | } | |
48 | ||
49 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( | |
50 | (void *) sc->packet_context_fc, "events_discarded"); | |
51 | if (int_fc && int_fc->meaning == | |
52 | CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) { | |
53 | sc->has_discarded_events = true; | |
54 | } | |
55 | ||
56 | sc->discarded_events_have_default_cs = | |
57 | sc->has_discarded_events && sc->packets_have_ts_begin && | |
58 | sc->packets_have_ts_end; | |
59 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( | |
60 | (void *) sc->packet_context_fc, "packet_seq_num"); | |
61 | if (int_fc && int_fc->meaning == | |
62 | CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) { | |
63 | sc->has_discarded_packets = true; | |
64 | } | |
65 | ||
66 | sc->discarded_packets_have_default_cs = | |
67 | sc->has_discarded_packets && | |
68 | sc->packets_have_ts_begin && sc->packets_have_ts_end; | |
69 | } | |
70 | ||
71 | return 0; | |
72 | } |