| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | #include "ctf-meta-visitors.hpp" |
| 10 | |
| 11 | int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc) |
| 12 | { |
| 13 | struct ctf_field_class_int *int_fc; |
| 14 | uint64_t i; |
| 15 | |
| 16 | for (i = 0; i < ctf_tc->stream_classes->len; i++) { |
| 17 | struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i]; |
| 18 | |
| 19 | if (sc->is_translated) { |
| 20 | continue; |
| 21 | } |
| 22 | |
| 23 | if (!sc->packet_context_fc) { |
| 24 | continue; |
| 25 | } |
| 26 | |
| 27 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
| 28 | ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin"); |
| 29 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) { |
| 30 | sc->packets_have_ts_begin = true; |
| 31 | } |
| 32 | |
| 33 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
| 34 | ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end"); |
| 35 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) { |
| 36 | sc->packets_have_ts_end = true; |
| 37 | } |
| 38 | |
| 39 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
| 40 | ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded"); |
| 41 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) { |
| 42 | sc->has_discarded_events = true; |
| 43 | } |
| 44 | |
| 45 | sc->discarded_events_have_default_cs = |
| 46 | sc->has_discarded_events && sc->packets_have_ts_begin && sc->packets_have_ts_end; |
| 47 | int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name( |
| 48 | ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num"); |
| 49 | if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) { |
| 50 | sc->has_discarded_packets = true; |
| 51 | } |
| 52 | |
| 53 | sc->discarded_packets_have_default_cs = |
| 54 | sc->has_discarded_packets && sc->packets_have_ts_begin && sc->packets_have_ts_end; |
| 55 | } |
| 56 | |
| 57 | return 0; |
| 58 | } |