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 | ||
087cd0f5 | 15 | #include "ctf-meta-visitors.hpp" |
afd45274 PP |
16 | |
17 | BT_HIDDEN | |
18 | int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) | |
19 | { | |
4164020e SM |
20 | struct ctf_field_class_int *int_fc; |
21 | uint64_t i; | |
afd45274 | 22 | |
4164020e SM |
23 | for (i = 0; i < ctf_tc->stream_classes->len; i++) { |
24 | struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; | |
afd45274 | 25 | |
4164020e SM |
26 | if (sc->is_translated) { |
27 | continue; | |
28 | } | |
afd45274 | 29 | |
4164020e SM |
30 | if (!sc->packet_context_fc) { |
31 | continue; | |
32 | } | |
afd45274 | 33 | |
4164020e SM |
34 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
35 | ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); | |
36 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) { | |
37 | sc->packets_have_ts_begin = true; | |
38 | } | |
afd45274 | 39 | |
4164020e SM |
40 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
41 | ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); | |
42 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) { | |
43 | sc->packets_have_ts_end = true; | |
44 | } | |
afd45274 | 45 | |
4164020e SM |
46 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
47 | ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); | |
48 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) { | |
49 | sc->has_discarded_events = true; | |
50 | } | |
afd45274 | 51 | |
4164020e SM |
52 | sc->discarded_events_have_default_cs = |
53 | sc->has_discarded_events && sc->packets_have_ts_begin && sc->packets_have_ts_end; | |
54 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( | |
55 | ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); | |
56 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) { | |
57 | sc->has_discarded_packets = true; | |
58 | } | |
afd45274 | 59 | |
4164020e SM |
60 | sc->discarded_packets_have_default_cs = |
61 | sc->has_discarded_packets && sc->packets_have_ts_begin && sc->packets_have_ts_end; | |
62 | } | |
afd45274 | 63 | |
4164020e | 64 | return 0; |
afd45274 | 65 | } |