2 * Copyright 2019 - Philippe Proulx <pproulx@efficios.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
15 #include <babeltrace2/babeltrace.h>
16 #include "common/macros.h"
17 #include "common/assert.h"
23 #include "ctf-meta-visitors.h"
26 int ctf_trace_class_update_stream_class_config(struct ctf_trace_class
*ctf_tc
)
28 struct ctf_field_class_int
*int_fc
;
31 for (i
= 0; i
< ctf_tc
->stream_classes
->len
; i
++) {
32 struct ctf_stream_class
*sc
=
33 ctf_tc
->stream_classes
->pdata
[i
];
35 if (sc
->is_translated
) {
39 if (!sc
->packet_context_fc
) {
43 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
44 (void *) sc
->packet_context_fc
, "timestamp_begin");
45 if (int_fc
&& int_fc
->meaning
==
46 CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME
) {
47 sc
->packets_have_ts_begin
= true;
50 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
51 (void *) sc
->packet_context_fc
, "timestamp_end");
52 if (int_fc
&& int_fc
->meaning
==
53 CTF_FIELD_CLASS_MEANING_PACKET_END_TIME
) {
54 sc
->packets_have_ts_end
= true;
57 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
58 (void *) sc
->packet_context_fc
, "events_discarded");
59 if (int_fc
&& int_fc
->meaning
==
60 CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT
) {
61 sc
->has_discarded_events
= true;
64 sc
->discarded_events_have_default_cs
=
65 sc
->has_discarded_events
&& sc
->packets_have_ts_begin
&&
66 sc
->packets_have_ts_end
;
67 int_fc
= ctf_field_class_struct_borrow_member_int_field_class_by_name(
68 (void *) sc
->packet_context_fc
, "packet_seq_num");
69 if (int_fc
&& int_fc
->meaning
==
70 CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT
) {
71 sc
->has_discarded_packets
= true;
74 sc
->discarded_packets_have_default_cs
=
75 sc
->has_discarded_packets
&&
76 sc
->packets_have_ts_begin
&& sc
->packets_have_ts_end
;