2 * Copyright 2018 - 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 #define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-WARN-MEANINGLESS-HEADER-FIELDS"
18 #include <babeltrace2/babeltrace.h>
19 #include <babeltrace2/babeltrace-internal.h>
20 #include <babeltrace2/assert-internal.h>
26 #include "ctf-meta-visitors.h"
29 void warn_meaningless_field(const char *name
, const char *scope_name
)
31 BT_LOGW("User field found in %s: ignoring: name=\"%s\"",
36 void warn_meaningless_fields(struct ctf_field_class
*fc
, const char *name
,
37 const char *scope_name
)
46 case CTF_FIELD_CLASS_TYPE_FLOAT
:
47 case CTF_FIELD_CLASS_TYPE_STRING
:
48 warn_meaningless_field(name
, scope_name
);
50 case CTF_FIELD_CLASS_TYPE_INT
:
51 case CTF_FIELD_CLASS_TYPE_ENUM
:
53 struct ctf_field_class_int
*int_fc
= (void *) fc
;
55 if (int_fc
->meaning
== CTF_FIELD_CLASS_MEANING_NONE
&&
56 !int_fc
->mapped_clock_class
) {
57 warn_meaningless_field(name
, scope_name
);
62 case CTF_FIELD_CLASS_TYPE_STRUCT
:
64 struct ctf_field_class_struct
*struct_fc
= (void *) fc
;
66 for (i
= 0; i
< struct_fc
->members
->len
; i
++) {
67 struct ctf_named_field_class
*named_fc
=
68 ctf_field_class_struct_borrow_member_by_index(
71 warn_meaningless_fields(named_fc
->fc
,
72 named_fc
->name
->str
, scope_name
);
77 case CTF_FIELD_CLASS_TYPE_VARIANT
:
79 struct ctf_field_class_variant
*var_fc
= (void *) fc
;
81 for (i
= 0; i
< var_fc
->options
->len
; i
++) {
82 struct ctf_named_field_class
*named_fc
=
83 ctf_field_class_variant_borrow_option_by_index(
86 warn_meaningless_fields(named_fc
->fc
,
87 named_fc
->name
->str
, scope_name
);
92 case CTF_FIELD_CLASS_TYPE_ARRAY
:
94 struct ctf_field_class_array
*array_fc
= (void *) fc
;
96 if (array_fc
->meaning
!= CTF_FIELD_CLASS_MEANING_NONE
) {
102 case CTF_FIELD_CLASS_TYPE_SEQUENCE
:
104 struct ctf_field_class_array_base
*array_fc
= (void *) fc
;
106 warn_meaningless_fields(array_fc
->elem_fc
, name
, scope_name
);
118 void ctf_trace_class_warn_meaningless_header_fields(
119 struct ctf_trace_class
*ctf_tc
)
123 if (!ctf_tc
->is_translated
) {
124 warn_meaningless_fields(
125 ctf_tc
->packet_header_fc
, NULL
, "packet header");
128 for (i
= 0; i
< ctf_tc
->stream_classes
->len
; i
++) {
129 struct ctf_stream_class
*sc
= ctf_tc
->stream_classes
->pdata
[i
];
131 if (!sc
->is_translated
) {
132 warn_meaningless_fields(sc
->event_header_fc
, NULL
,