7c28ee23319df6b51847ac9f5e72c52c51fba9b7
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-update-stream-class-config.c
1 /*
2 * Copyright 2019 - Philippe Proulx <pproulx@efficios.com>
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 */
14
15 #define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-SC-CONFIG"
16 #include "logging.h"
17
18 #include <babeltrace2/babeltrace.h>
19 #include "common/macros.h"
20 #include "common/assert.h"
21 #include <glib.h>
22 #include <stdint.h>
23 #include <string.h>
24 #include <inttypes.h>
25
26 #include "ctf-meta-visitors.h"
27
28 BT_HIDDEN
29 int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc)
30 {
31 struct ctf_field_class_int *int_fc;
32 uint64_t i;
33
34 for (i = 0; i < ctf_tc->stream_classes->len; i++) {
35 struct ctf_stream_class *sc =
36 ctf_tc->stream_classes->pdata[i];
37
38 if (sc->is_translated) {
39 continue;
40 }
41
42 if (!sc->packet_context_fc) {
43 continue;
44 }
45
46 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
47 (void *) sc->packet_context_fc, "timestamp_begin");
48 if (int_fc && int_fc->meaning ==
49 CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
50 sc->packets_have_ts_begin = true;
51 }
52
53 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
54 (void *) sc->packet_context_fc, "timestamp_end");
55 if (int_fc && int_fc->meaning ==
56 CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
57 sc->packets_have_ts_end = true;
58 }
59
60 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
61 (void *) sc->packet_context_fc, "events_discarded");
62 if (int_fc && int_fc->meaning ==
63 CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
64 sc->has_discarded_events = true;
65 }
66
67 sc->discarded_events_have_default_cs =
68 sc->has_discarded_events && sc->packets_have_ts_begin &&
69 sc->packets_have_ts_end;
70 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
71 (void *) sc->packet_context_fc, "packet_seq_num");
72 if (int_fc && int_fc->meaning ==
73 CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
74 sc->has_discarded_packets = true;
75 }
76
77 sc->discarded_packets_have_default_cs =
78 sc->has_discarded_packets &&
79 sc->packets_have_ts_begin && sc->packets_have_ts_end;
80 }
81
82 return 0;
83 }
This page took 0.036881 seconds and 3 git commands to generate.