`ctf` plugin: metadata: use local log level
[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 #include <babeltrace2/babeltrace.h>
16 #include "common/macros.h"
17 #include "common/assert.h"
18 #include <glib.h>
19 #include <stdint.h>
20 #include <string.h>
21 #include <inttypes.h>
22
23 #include "ctf-meta-visitors.h"
24
25 BT_HIDDEN
26 int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc)
27 {
28 struct ctf_field_class_int *int_fc;
29 uint64_t i;
30
31 for (i = 0; i < ctf_tc->stream_classes->len; i++) {
32 struct ctf_stream_class *sc =
33 ctf_tc->stream_classes->pdata[i];
34
35 if (sc->is_translated) {
36 continue;
37 }
38
39 if (!sc->packet_context_fc) {
40 continue;
41 }
42
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;
48 }
49
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;
55 }
56
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;
62 }
63
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;
72 }
73
74 sc->discarded_packets_have_default_cs =
75 sc->has_discarded_packets &&
76 sc->packets_have_ts_begin && sc->packets_have_ts_end;
77 }
78
79 return 0;
80 }
This page took 0.031724 seconds and 5 git commands to generate.