lib: metadata: transform fast path precond. checks to BT_ASSERT_PRE()
[babeltrace.git] / lib / ctf-ir / event-class.c
... / ...
CommitLineData
1/*
2 * event-class.c
3 *
4 * Babeltrace CTF IR - Event class
5 *
6 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 *
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29#define BT_LOG_TAG "EVENT-CLASS"
30#include <babeltrace/lib-logging-internal.h>
31
32#include <babeltrace/ctf-ir/fields-internal.h>
33#include <babeltrace/ctf-ir/field-types-internal.h>
34#include <babeltrace/ctf-ir/event-class.h>
35#include <babeltrace/ctf-ir/event-class-internal.h>
36#include <babeltrace/ctf-ir/stream-class.h>
37#include <babeltrace/ctf-ir/stream-class-internal.h>
38#include <babeltrace/ctf-ir/trace-internal.h>
39#include <babeltrace/ctf-ir/validation-internal.h>
40#include <babeltrace/ctf-ir/utils.h>
41#include <babeltrace/ctf-ir/utils-internal.h>
42#include <babeltrace/ref.h>
43#include <babeltrace/ctf-ir/attributes-internal.h>
44#include <babeltrace/compiler-internal.h>
45#include <babeltrace/endian-internal.h>
46#include <babeltrace/types.h>
47#include <babeltrace/values-internal.h>
48#include <babeltrace/assert-internal.h>
49#include <babeltrace/assert-pre-internal.h>
50#include <inttypes.h>
51#include <stdlib.h>
52
53static
54void bt_event_class_destroy(struct bt_object *obj);
55
56struct bt_event_class *bt_event_class_create(const char *name)
57{
58 struct bt_value *obj = NULL;
59 struct bt_event_class *event_class = NULL;
60
61 BT_LOGD("Creating event class object: name=\"%s\"",
62 name);
63
64 if (!name) {
65 BT_LOGW_STR("Invalid parameter: name is NULL.");
66 goto error;
67 }
68
69 event_class = g_new0(struct bt_event_class, 1);
70 if (!event_class) {
71 BT_LOGE_STR("Failed to allocate one event class.");
72 goto error;
73 }
74
75 bt_object_init(event_class, bt_event_class_destroy);
76 event_class->fields = bt_field_type_structure_create();
77 if (!event_class->fields) {
78 BT_LOGE_STR("Cannot create event class's initial payload field type object.");
79 goto error;
80 }
81
82 event_class->id = -1;
83 event_class->name = g_string_new(name);
84 if (!event_class->name) {
85 BT_LOGE_STR("Failed to allocate a GString.");
86 goto error;
87 }
88
89 event_class->emf_uri = g_string_new(NULL);
90 if (!event_class->emf_uri) {
91 BT_LOGE_STR("Failed to allocate a GString.");
92 goto error;
93 }
94
95 event_class->log_level = BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED;
96 BT_PUT(obj);
97 BT_LOGD("Created event class object: addr=%p, name=\"%s\"",
98 event_class, bt_event_class_get_name(event_class));
99 return event_class;
100
101error:
102 BT_PUT(event_class);
103 BT_PUT(obj);
104 return event_class;
105}
106
107const char *bt_event_class_get_name(struct bt_event_class *event_class)
108{
109 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
110 BT_ASSERT(event_class->name);
111 return event_class->name->str;
112}
113
114int64_t bt_event_class_get_id(struct bt_event_class *event_class)
115{
116 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
117 return event_class->id;
118}
119
120int bt_event_class_set_id(struct bt_event_class *event_class,
121 uint64_t id_param)
122{
123 int ret = 0;
124 int64_t id = (int64_t) id_param;
125
126 if (!event_class) {
127 BT_LOGW_STR("Invalid parameter: event class is NULL.");
128 ret = -1;
129 goto end;
130 }
131
132 if (event_class->frozen) {
133 BT_LOGW("Invalid parameter: event class is frozen: "
134 "addr=%p, name=\"%s\", id=%" PRId64,
135 event_class, bt_event_class_get_name(event_class),
136 bt_event_class_get_id(event_class));
137 ret = -1;
138 goto end;
139 }
140
141 if (id < 0) {
142 BT_LOGW("Invalid parameter: invalid event class's ID: "
143 "addr=%p, name=\"%s\", id=%" PRIu64,
144 event_class, bt_event_class_get_name(event_class),
145 id_param);
146 ret = -1;
147 goto end;
148 }
149
150 event_class->id = id;
151 BT_LOGV("Set event class's ID: "
152 "addr=%p, name=\"%s\", id=%" PRId64,
153 event_class, bt_event_class_get_name(event_class), id);
154
155end:
156 return ret;
157}
158
159enum bt_event_class_log_level bt_event_class_get_log_level(
160 struct bt_event_class *event_class)
161{
162 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
163 return event_class->log_level;
164}
165
166int bt_event_class_set_log_level(struct bt_event_class *event_class,
167 enum bt_event_class_log_level log_level)
168{
169 int ret = 0;
170
171 if (!event_class) {
172 BT_LOGW_STR("Invalid parameter: event class is NULL.");
173 ret = -1;
174 goto end;
175 }
176
177 if (event_class->frozen) {
178 BT_LOGW("Invalid parameter: event class is frozen: "
179 "addr=%p, name=\"%s\", id=%" PRId64,
180 event_class, bt_event_class_get_name(event_class),
181 bt_event_class_get_id(event_class));
182 ret = -1;
183 goto end;
184 }
185
186 switch (log_level) {
187 case BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
188 case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
189 case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
190 case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
191 case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
192 case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
193 case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
194 case BT_EVENT_CLASS_LOG_LEVEL_INFO:
195 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
196 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
197 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
198 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
199 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
200 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
201 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
202 case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
203 break;
204 default:
205 BT_LOGW("Invalid parameter: unknown event class log level: "
206 "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
207 event_class, bt_event_class_get_name(event_class),
208 bt_event_class_get_id(event_class), log_level);
209 ret = -1;
210 goto end;
211 }
212
213 event_class->log_level = log_level;
214 BT_LOGV("Set event class's log level: "
215 "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
216 event_class, bt_event_class_get_name(event_class),
217 bt_event_class_get_id(event_class),
218 bt_event_class_log_level_string(log_level));
219
220end:
221 return ret;
222}
223
224const char *bt_event_class_get_emf_uri(
225 struct bt_event_class *event_class)
226{
227 const char *emf_uri = NULL;
228
229 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
230
231 if (event_class->emf_uri->len > 0) {
232 emf_uri = event_class->emf_uri->str;
233 }
234
235 return emf_uri;
236}
237
238int bt_event_class_set_emf_uri(struct bt_event_class *event_class,
239 const char *emf_uri)
240{
241 int ret = 0;
242
243 if (!event_class) {
244 BT_LOGW_STR("Invalid parameter: event class is NULL.");
245 ret = -1;
246 goto end;
247 }
248
249 if (emf_uri && strlen(emf_uri) == 0) {
250 BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
251 ret = -1;
252 goto end;
253 }
254
255 if (event_class->frozen) {
256 BT_LOGW("Invalid parameter: event class is frozen: "
257 "addr=%p, name=\"%s\", id=%" PRId64,
258 event_class, bt_event_class_get_name(event_class),
259 bt_event_class_get_id(event_class));
260 ret = -1;
261 goto end;
262 }
263
264 if (emf_uri) {
265 g_string_assign(event_class->emf_uri, emf_uri);
266 BT_LOGV("Set event class's EMF URI: "
267 "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
268 event_class, bt_event_class_get_name(event_class),
269 bt_event_class_get_id(event_class), emf_uri);
270 } else {
271 g_string_assign(event_class->emf_uri, "");
272 BT_LOGV("Reset event class's EMF URI: "
273 "addr=%p, name=\"%s\", id=%" PRId64,
274 event_class, bt_event_class_get_name(event_class),
275 bt_event_class_get_id(event_class));
276 }
277
278end:
279 return ret;
280}
281
282struct bt_stream_class *bt_event_class_get_stream_class(
283 struct bt_event_class *event_class)
284{
285 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
286 return bt_get(bt_event_class_borrow_stream_class(event_class));
287}
288
289struct bt_field_type *bt_event_class_get_payload_type(
290 struct bt_event_class *event_class)
291{
292 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
293 return bt_get(event_class->fields);
294}
295
296int bt_event_class_set_payload_type(struct bt_event_class *event_class,
297 struct bt_field_type *payload)
298{
299 int ret = 0;
300
301 if (!event_class) {
302 BT_LOGW_STR("Invalid parameter: event class is NULL.");
303 ret = -1;
304 goto end;
305 }
306
307 if (payload && bt_field_type_get_type_id(payload) !=
308 BT_FIELD_TYPE_ID_STRUCT) {
309 BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
310 "addr=%p, name=\"%s\", id=%" PRId64 ", "
311 "payload-ft-addr=%p, payload-ft-id=%s",
312 event_class, bt_event_class_get_name(event_class),
313 bt_event_class_get_id(event_class), payload,
314 bt_field_type_id_string(
315 bt_field_type_get_type_id(payload)));
316 ret = -1;
317 goto end;
318 }
319
320 bt_put(event_class->fields);
321 event_class->fields = bt_get(payload);
322 BT_LOGV("Set event class's payload field type: "
323 "event-class-addr=%p, event-class-name=\"%s\", "
324 "event-class-id=%" PRId64 ", payload-ft-addr=%p",
325 event_class, bt_event_class_get_name(event_class),
326 bt_event_class_get_id(event_class), payload);
327end:
328 return ret;
329}
330
331int bt_event_class_add_field(struct bt_event_class *event_class,
332 struct bt_field_type *type,
333 const char *name)
334{
335 int ret = 0;
336
337 if (!event_class || !type) {
338 BT_LOGW("Invalid parameter: event class or field type is NULL: "
339 "event-class-addr=%p, field-type-addr=%p",
340 event_class, type);
341 ret = -1;
342 goto end;
343 }
344
345 if (!bt_identifier_is_valid(name)) {
346 BT_LOGW("Invalid parameter: event class's payload field type's field name is not a valid CTF identifier: "
347 "addr=%p, name=\"%s\", id=%" PRId64 ", field-name=\"%s\"",
348 event_class, bt_event_class_get_name(event_class),
349 bt_event_class_get_id(event_class),
350 name);
351 ret = -1;
352 goto end;
353 }
354
355 if (event_class->frozen) {
356 BT_LOGW("Invalid parameter: event class is frozen: "
357 "addr=%p, name=\"%s\", id=%" PRId64,
358 event_class, bt_event_class_get_name(event_class),
359 bt_event_class_get_id(event_class));
360 ret = -1;
361 goto end;
362 }
363
364 if (!event_class->fields) {
365 BT_LOGW("Event class has no payload field type: "
366 "addr=%p, name=\"%s\", id=%" PRId64,
367 event_class, bt_event_class_get_name(event_class),
368 bt_event_class_get_id(event_class));
369 ret = -1;
370 goto end;
371 }
372
373 BT_ASSERT(bt_field_type_get_type_id(event_class->fields) ==
374 BT_FIELD_TYPE_ID_STRUCT);
375 ret = bt_field_type_structure_add_field(event_class->fields,
376 type, name);
377 BT_LOGV("Added field to event class's payload field type: "
378 "event-class-addr=%p, event-class-name=\"%s\", "
379 "event-class-id=%" PRId64 ", field-name=\"%s\", ft-addr=%p",
380 event_class, bt_event_class_get_name(event_class),
381 bt_event_class_get_id(event_class), name, type);
382end:
383 return ret;
384}
385
386int64_t bt_event_class_get_payload_type_field_count(
387 struct bt_event_class *event_class)
388{
389 int64_t ret;
390
391 if (!event_class) {
392 BT_LOGW_STR("Invalid parameter: event class is NULL.");
393 ret = (int64_t) -1;
394 goto end;
395 }
396
397 if (!event_class->fields) {
398 BT_LOGV("Event class has no payload field type: "
399 "addr=%p, name=\"%s\", id=%" PRId64,
400 event_class, bt_event_class_get_name(event_class),
401 bt_event_class_get_id(event_class));
402 ret = (int64_t) -1;
403 goto end;
404 }
405
406 BT_ASSERT(bt_field_type_get_type_id(event_class->fields) ==
407 BT_FIELD_TYPE_ID_STRUCT);
408 ret = bt_field_type_structure_get_field_count(event_class->fields);
409end:
410 return ret;
411}
412
413int bt_event_class_get_payload_type_field_by_index(
414 struct bt_event_class *event_class,
415 const char **field_name, struct bt_field_type **field_type,
416 uint64_t index)
417{
418 int ret;
419
420 if (!event_class) {
421 BT_LOGW_STR("Invalid parameter: event class is NULL.");
422 ret = -1;
423 goto end;
424 }
425
426 if (!event_class->fields) {
427 BT_LOGV("Event class has no payload field type: "
428 "addr=%p, name=\"%s\", id=%" PRId64 ", index=%" PRIu64,
429 event_class, bt_event_class_get_name(event_class),
430 bt_event_class_get_id(event_class), index);
431 ret = -1;
432 goto end;
433 }
434
435 BT_ASSERT(bt_field_type_get_type_id(event_class->fields) ==
436 BT_FIELD_TYPE_ID_STRUCT);
437 ret = bt_field_type_structure_get_field_by_index(event_class->fields,
438 field_name, field_type, index);
439end:
440 return ret;
441}
442
443struct bt_field_type *
444bt_event_class_get_payload_type_field_type_by_name(
445 struct bt_event_class *event_class, const char *name)
446{
447 GQuark name_quark;
448 struct bt_field_type *field_type = NULL;
449
450 if (!event_class || !name) {
451 BT_LOGW("Invalid parameter: event class or name is NULL: "
452 "event-class-addr=%p, name-addr=%p",
453 event_class, name);
454 goto end;
455 }
456
457 if (!event_class->fields) {
458 BT_LOGV("Event class has no payload field type: "
459 "addr=%p, name=\"%s\", id=%" PRId64,
460 event_class, bt_event_class_get_name(event_class),
461 bt_event_class_get_id(event_class));
462 goto end;
463 }
464
465 BT_ASSERT(bt_field_type_get_type_id(event_class->fields) ==
466 BT_FIELD_TYPE_ID_STRUCT);
467 name_quark = g_quark_try_string(name);
468 if (!name_quark) {
469 BT_LOGE("Cannot get GQuark: string=\"%s\"", name);
470 goto end;
471 }
472
473 /*
474 * No need to increment field_type's reference count since getting it
475 * from the structure already does.
476 */
477 field_type = bt_field_type_structure_get_field_type_by_name(
478 event_class->fields, name);
479end:
480 return field_type;
481}
482
483struct bt_field_type *bt_event_class_get_context_type(
484 struct bt_event_class *event_class)
485{
486 struct bt_field_type *context_type = NULL;
487
488 BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
489
490 if (!event_class->context) {
491 BT_LOGV("Event class has no context field type: "
492 "addr=%p, name=\"%s\", id=%" PRId64,
493 event_class, bt_event_class_get_name(event_class),
494 bt_event_class_get_id(event_class));
495 goto end;
496 }
497
498 context_type = bt_get(event_class->context);
499
500end:
501 return context_type;
502}
503
504int bt_event_class_set_context_type(
505 struct bt_event_class *event_class,
506 struct bt_field_type *context)
507{
508 int ret = 0;
509
510 if (!event_class) {
511 BT_LOGW_STR("Invalid parameter: event class is NULL.");
512 ret = -1;
513 goto end;
514 }
515
516 if (event_class->frozen) {
517 BT_LOGW("Invalid parameter: event class is frozen: "
518 "addr=%p, name=\"%s\", id=%" PRId64,
519 event_class, bt_event_class_get_name(event_class),
520 bt_event_class_get_id(event_class));
521 ret = -1;
522 goto end;
523 }
524
525 if (context && bt_field_type_get_type_id(context) !=
526 BT_FIELD_TYPE_ID_STRUCT) {
527 BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
528 "addr=%p, name=\"%s\", id=%" PRId64 ", "
529 "context-ft-id=%s",
530 event_class, bt_event_class_get_name(event_class),
531 bt_event_class_get_id(event_class),
532 bt_field_type_id_string(
533 bt_field_type_get_type_id(context)));
534 ret = -1;
535 goto end;
536 }
537
538 bt_put(event_class->context);
539 event_class->context = bt_get(context);
540 BT_LOGV("Set event class's context field type: "
541 "event-class-addr=%p, event-class-name=\"%s\", "
542 "event-class-id=%" PRId64 ", context-ft-addr=%p",
543 event_class, bt_event_class_get_name(event_class),
544 bt_event_class_get_id(event_class), context);
545end:
546 return ret;
547
548}
549
550/* Pre-2.0 CTF writer backward compatibility */
551void bt_ctf_event_class_get(struct bt_event_class *event_class)
552{
553 bt_get(event_class);
554}
555
556/* Pre-2.0 CTF writer backward compatibility */
557void bt_ctf_event_class_put(struct bt_event_class *event_class)
558{
559 bt_put(event_class);
560}
561
562static
563void bt_event_class_destroy(struct bt_object *obj)
564{
565 struct bt_event_class *event_class;
566
567 event_class = container_of(obj, struct bt_event_class, base);
568 BT_LOGD("Destroying event class: addr=%p, name=\"%s\", id=%" PRId64,
569 event_class, bt_event_class_get_name(event_class),
570 bt_event_class_get_id(event_class));
571 g_string_free(event_class->name, TRUE);
572 g_string_free(event_class->emf_uri, TRUE);
573 BT_LOGD_STR("Putting context field type.");
574 bt_put(event_class->context);
575 BT_LOGD_STR("Putting payload field type.");
576 bt_put(event_class->fields);
577 g_free(event_class);
578}
579
580BT_HIDDEN
581void bt_event_class_freeze(struct bt_event_class *event_class)
582{
583 BT_ASSERT(event_class);
584
585 if (event_class->frozen) {
586 return;
587 }
588
589 BT_LOGD("Freezing event class: addr=%p, name=\"%s\", id=%" PRId64,
590 event_class, bt_event_class_get_name(event_class),
591 bt_event_class_get_id(event_class));
592 event_class->frozen = 1;
593 BT_LOGD_STR("Freezing event class's context field type.");
594 bt_field_type_freeze(event_class->context);
595 BT_LOGD_STR("Freezing event class's payload field type.");
596 bt_field_type_freeze(event_class->fields);
597}
598
599BT_HIDDEN
600int bt_event_class_serialize(struct bt_event_class *event_class,
601 struct metadata_context *context)
602{
603 int ret = 0;
604 struct bt_value *attr_value = NULL;
605
606 BT_ASSERT(event_class);
607 BT_ASSERT(context);
608 BT_LOGD("Serializing event class's metadata: "
609 "event-class-addr=%p, event-class-name=\"%s\", "
610 "event-class-id=%" PRId64 ", metadata-context-addr=%p",
611 event_class, bt_event_class_get_name(event_class),
612 bt_event_class_get_id(event_class), context);
613 context->current_indentation_level = 1;
614 g_string_assign(context->field_name, "");
615 g_string_append(context->string, "event {\n");
616
617 /* Serialize attributes */
618 g_string_append_printf(context->string, "\tname = \"%s\";\n",
619 event_class->name->str);
620 BT_ASSERT(event_class->id >= 0);
621 g_string_append_printf(context->string, "\tid = %" PRId64 ";\n",
622 event_class->id);
623 g_string_append_printf(context->string, "\tstream_id = %" PRId64 ";\n",
624 bt_stream_class_get_id(
625 bt_event_class_borrow_stream_class(event_class)));
626
627 if (event_class->log_level != BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED) {
628 g_string_append_printf(context->string, "\tloglevel = %d;\n",
629 (int) event_class->log_level);
630 }
631
632 if (event_class->emf_uri->len > 0) {
633 g_string_append_printf(context->string, "\tmodel.emf.uri = \"%s\";\n",
634 event_class->emf_uri->str);
635 }
636
637 /* Serialize context field type */
638 if (event_class->context) {
639 g_string_append(context->string, "\tcontext := ");
640 BT_LOGD_STR("Serializing event class's context field type metadata.");
641 ret = bt_field_type_serialize(event_class->context,
642 context);
643 if (ret) {
644 BT_LOGW("Cannot serialize event class's context field type's metadata: "
645 "ret=%d", ret);
646 goto end;
647 }
648 g_string_append(context->string, ";\n");
649 }
650
651 /* Serialize payload field type */
652 if (event_class->fields) {
653 g_string_append(context->string, "\tfields := ");
654 BT_LOGD_STR("Serializing event class's payload field type metadata.");
655 ret = bt_field_type_serialize(event_class->fields, context);
656 if (ret) {
657 BT_LOGW("Cannot serialize event class's payload field type's metadata: "
658 "ret=%d", ret);
659 goto end;
660 }
661 g_string_append(context->string, ";\n");
662 }
663
664 g_string_append(context->string, "};\n\n");
665end:
666 context->current_indentation_level = 0;
667 BT_PUT(attr_value);
668 return ret;
669}
670
671BT_HIDDEN
672int bt_event_class_validate_single_clock_class(
673 struct bt_event_class *event_class,
674 struct bt_clock_class **expected_clock_class)
675{
676 int ret = 0;
677
678 BT_ASSERT(event_class);
679 BT_ASSERT(expected_clock_class);
680 ret = bt_validate_single_clock_class(event_class->context,
681 expected_clock_class);
682 if (ret) {
683 BT_LOGW("Event class's context field type "
684 "is not recursively mapped to the "
685 "expected clock class: "
686 "event-class-addr=%p, "
687 "event-class-name=\"%s\", "
688 "event-class-id=%" PRId64 ", "
689 "ft-addr=%p",
690 event_class,
691 bt_event_class_get_name(event_class),
692 event_class->id,
693 event_class->context);
694 goto end;
695 }
696
697 ret = bt_validate_single_clock_class(event_class->fields,
698 expected_clock_class);
699 if (ret) {
700 BT_LOGW("Event class's payload field type "
701 "is not recursively mapped to the "
702 "expected clock class: "
703 "event-class-addr=%p, "
704 "event-class-name=\"%s\", "
705 "event-class-id=%" PRId64 ", "
706 "ft-addr=%p",
707 event_class,
708 bt_event_class_get_name(event_class),
709 event_class->id,
710 event_class->fields);
711 goto end;
712 }
713
714end:
715 return ret;
716}
This page took 0.026128 seconds and 4 git commands to generate.