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