From 67d2ce028c96b6a3b3614b393d8928663bce4490 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 7 Jun 2019 12:25:10 -0400 Subject: [PATCH] ctf-writer: externalize libbabeltrace2-ctf-writer Completely split the ctf writer part from the main babeltrace2 library. * Remove the obsolete libbabeltrace2-ctf library * Add a new libbabeltrace2-ctf-writer library * Remove the ctf writer includes from the main include file * Fork an internal copy of assert-pre.h that doesn't use the library structures. * Add a logging context specific to ctf writer Signed-off-by: Michael Jeanson Change-Id: Iff9ab62ee9eeb8abd290fb1d758a73050e21c99b Reviewed-on: https://review.lttng.org/c/babeltrace/+/1410 Tested-by: jenkins Reviewed-by: Philippe Proulx --- .gitignore | 2 +- Makefile.am | 3 +- ...-ctf.pc.in => babeltrace2-ctf-writer.pc.in | 8 +- configure.ac | 4 +- ctf-writer/Makefile.am | 36 ++++ {lib/ctf-writer => ctf-writer}/attributes.c | 2 +- {lib/ctf-writer => ctf-writer}/clock-class.c | 4 +- {lib/ctf-writer => ctf-writer}/clock.c | 42 ++--- {lib/ctf-writer => ctf-writer}/event-class.c | 6 +- {lib/ctf-writer => ctf-writer}/event.c | 70 ++++---- {lib/ctf-writer => ctf-writer}/field-path.c | 2 +- {lib/ctf-writer => ctf-writer}/field-types.c | 166 +++++++++--------- .../ctf-writer => ctf-writer}/field-wrapper.c | 5 +- {lib/ctf-writer => ctf-writer}/fields.c | 114 ++++++------ {lib/ctf-writer => ctf-writer}/functor.c | 0 ctf-writer/logging.c | 27 +++ ctf-writer/logging.h | 31 ++++ {lib/ctf-writer => ctf-writer}/object-pool.c | 6 +- {lib/ctf-writer => ctf-writer}/object.c | 0 {lib/ctf-writer => ctf-writer}/resolve.c | 2 +- {lib/ctf-writer => ctf-writer}/stream-class.c | 4 +- {lib/ctf-writer => ctf-writer}/stream.c | 6 +- {lib/ctf-writer => ctf-writer}/trace.c | 2 +- {lib/ctf-writer => ctf-writer}/utils.c | 2 +- {lib/ctf-writer => ctf-writer}/validation.c | 4 +- {lib/ctf-writer => ctf-writer}/values.c | 141 ++++++++------- {lib/ctf-writer => ctf-writer}/visitor.c | 0 {lib/ctf-writer => ctf-writer}/writer.c | 2 +- extras/gen-babeltrace-h.py | 3 + include/Makefile.am | 1 + include/babeltrace2/babeltrace.h | 31 ---- .../ctf-writer/assert-pre-internal.h | 129 ++++++++++++++ .../ctf-writer/event-class-internal.h | 12 +- .../babeltrace2/ctf-writer/event-internal.h | 14 +- .../ctf-writer/field-types-internal.h | 10 +- .../babeltrace2/ctf-writer/fields-internal.h | 124 ++++++------- .../ctf-writer/stream-class-internal.h | 18 +- .../babeltrace2/ctf-writer/stream-internal.h | 6 +- .../babeltrace2/ctf-writer/trace-internal.h | 46 ++--- lib/Makefile.am | 26 +-- lib/ctf-writer/Makefile.am | 26 --- tests/lib/Makefile.am | 23 +-- tests/lib/test_trace_ir_ref.c | 9 + 43 files changed, 663 insertions(+), 506 deletions(-) rename babeltrace2-ctf.pc.in => babeltrace2-ctf-writer.pc.in (63%) create mode 100644 ctf-writer/Makefile.am rename {lib/ctf-writer => ctf-writer}/attributes.c (99%) rename {lib/ctf-writer => ctf-writer}/clock-class.c (99%) rename {lib/ctf-writer => ctf-writer}/clock.c (87%) rename {lib/ctf-writer => ctf-writer}/event-class.c (99%) rename {lib/ctf-writer => ctf-writer}/event.c (93%) rename {lib/ctf-writer => ctf-writer}/field-path.c (98%) rename {lib/ctf-writer => ctf-writer}/field-types.c (96%) rename {lib/ctf-writer => ctf-writer}/field-wrapper.c (94%) rename {lib/ctf-writer => ctf-writer}/fields.c (94%) rename {lib/ctf-writer => ctf-writer}/functor.c (100%) create mode 100644 ctf-writer/logging.c create mode 100644 ctf-writer/logging.h rename {lib/ctf-writer => ctf-writer}/object-pool.c (94%) rename {lib/ctf-writer => ctf-writer}/object.c (100%) rename {lib/ctf-writer => ctf-writer}/resolve.c (99%) rename {lib/ctf-writer => ctf-writer}/stream-class.c (99%) rename {lib/ctf-writer => ctf-writer}/stream.c (99%) rename {lib/ctf-writer => ctf-writer}/trace.c (99%) rename {lib/ctf-writer => ctf-writer}/utils.c (98%) rename {lib/ctf-writer => ctf-writer}/validation.c (99%) rename {lib/ctf-writer => ctf-writer}/values.c (89%) rename {lib/ctf-writer => ctf-writer}/visitor.c (100%) rename {lib/ctf-writer => ctf-writer}/writer.c (99%) create mode 100644 include/babeltrace2/ctf-writer/assert-pre-internal.h delete mode 100644 lib/ctf-writer/Makefile.am diff --git a/.gitignore b/.gitignore index 13fdf958..9c71bb9d 100644 --- a/.gitignore +++ b/.gitignore @@ -88,7 +88,7 @@ core stamp-h1 __pycache__ /babeltrace2.pc -/babeltrace2-ctf.pc +/babeltrace2-ctf-writer.pc TAGS cscope* doc/api/Doxyfile diff --git a/Makefile.am b/Makefile.am index 76ba8249..938dc75b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,7 @@ SUBDIRS = include \ logging \ lib \ python-plugin-provider \ + ctf-writer \ plugins \ cli \ bindings \ @@ -24,7 +25,7 @@ dist_doc_DATA = ChangeLog LICENSE mit-license.txt gpl-2.0.txt \ dist_noinst_DATA = CodingStyle pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = babeltrace2.pc babeltrace2-ctf.pc +pkgconfig_DATA = babeltrace2.pc babeltrace2-ctf-writer.pc # This is a convenience target, it's not part of the build process. CONTRIBUTING.html: CONTRIBUTING.adoc diff --git a/babeltrace2-ctf.pc.in b/babeltrace2-ctf-writer.pc.in similarity index 63% rename from babeltrace2-ctf.pc.in rename to babeltrace2-ctf-writer.pc.in index b20d98b1..504d8597 100644 --- a/babeltrace2-ctf.pc.in +++ b/babeltrace2-ctf-writer.pc.in @@ -4,10 +4,10 @@ libdir=@libdir@ includedir=@includedir@ Name: Babeltrace CTF parser -Description: libbabeltrace2-ctf provides the specific bits necessary to read a Common Trace Format (CTF) trace. +Description: libbabeltrace2-ctf provides the specific bits necessary to write a Common Trace Format (CTF) trace. Version: @PACKAGE_VERSION@ -Requires: babeltrace -Requires.private: -Libs: -L${libdir} -lbabeltrace2-ctf +Requires: +Requires.private: uuid popt +Libs: -L${libdir} -lbabeltrace2-ctf-writer Cflags: -I${includedir} diff --git a/configure.ac b/configure.ac index 3fc2eb94..b4f1e915 100644 --- a/configure.ac +++ b/configure.ac @@ -732,6 +732,7 @@ AC_CONFIG_FILES([ bindings/python/bt2/bt2/__init__.py common/Makefile ctfser/Makefile + ctf-writer/Makefile compat/Makefile cli/Makefile doc/Makefile @@ -749,7 +750,6 @@ AC_CONFIG_FILES([ lib/graph/Makefile lib/graph/message/Makefile lib/trace-ir/Makefile - lib/ctf-writer/Makefile include/Makefile logging/Makefile bindings/Makefile @@ -782,7 +782,7 @@ AC_CONFIG_FILES([ plugins/lttng-utils/Makefile plugins/lttng-utils/debug-info/Makefile babeltrace2.pc - babeltrace2-ctf.pc + babeltrace2-ctf-writer.pc ]) AC_CONFIG_FILES([tests/cli/test_intersection], [chmod +x tests/cli/test_intersection]) diff --git a/ctf-writer/Makefile.am b/ctf-writer/Makefile.am new file mode 100644 index 00000000..7c5d046e --- /dev/null +++ b/ctf-writer/Makefile.am @@ -0,0 +1,36 @@ +lib_LTLIBRARIES = libbabeltrace2-ctf-writer.la + +libbabeltrace2_ctf_writer_la_SOURCES = \ + attributes.c \ + clock.c \ + clock-class.c \ + event.c \ + event-class.c \ + field-path.c \ + fields.c \ + field-types.c \ + field-wrapper.c \ + functor.c \ + logging.c \ + logging.h \ + object.c \ + object-pool.c \ + resolve.c \ + stream.c \ + stream-class.c \ + trace.c \ + utils.c \ + validation.c \ + values.c \ + visitor.c \ + writer.c + +libbabeltrace2_ctf_writer_la_LDFLAGS = $(LT_NO_UNDEFINED) \ + -version-info $(BABELTRACE_LIBRARY_VERSION) + +libbabeltrace2_ctf_writer_la_LIBADD = \ + $(top_builddir)/logging/libbabeltrace2-logging.la \ + $(top_builddir)/common/libbabeltrace2-common.la \ + $(top_builddir)/ctfser/libbabeltrace2-ctfser.la \ + $(top_builddir)/compat/libcompat.la \ + $(UUID_LIBS) diff --git a/lib/ctf-writer/attributes.c b/ctf-writer/attributes.c similarity index 99% rename from lib/ctf-writer/attributes.c rename to ctf-writer/attributes.c index a594015f..fbb81a03 100644 --- a/lib/ctf-writer/attributes.c +++ b/ctf-writer/attributes.c @@ -26,7 +26,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-ATTRS" -#include +#include "logging.h" #include #include diff --git a/lib/ctf-writer/clock-class.c b/ctf-writer/clock-class.c similarity index 99% rename from lib/ctf-writer/clock-class.c rename to ctf-writer/clock-class.c index 9e3807c0..1c507e37 100644 --- a/lib/ctf-writer/clock-class.c +++ b/ctf-writer/clock-class.c @@ -27,9 +27,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-CLOCK-CLASS" -#include +#include "logging.h" -#include +#include #include #include #include diff --git a/lib/ctf-writer/clock.c b/ctf-writer/clock.c similarity index 87% rename from lib/ctf-writer/clock.c rename to ctf-writer/clock.c index f270ce3d..0238c25b 100644 --- a/lib/ctf-writer/clock.c +++ b/ctf-writer/clock.c @@ -28,7 +28,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-CLOCK" -#include +#include "logging.h" #include #include @@ -50,7 +50,7 @@ struct bt_ctf_clock *bt_ctf_clock_create(const char *name) struct bt_ctf_clock *clock = NULL; unsigned char cc_uuid[BABELTRACE_UUID_LEN]; - BT_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); clock = g_new0(struct bt_ctf_clock, 1); if (!clock) { goto error; @@ -82,99 +82,99 @@ error: const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_name(clock->clock_class); } const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_description(clock->clock_class); } int bt_ctf_clock_set_description(struct bt_ctf_clock *clock, const char *desc) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_description(clock->clock_class, desc); } uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_frequency(clock->clock_class); } int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock, uint64_t freq) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_frequency(clock->clock_class, freq); } uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_precision(clock->clock_class); } int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, uint64_t precision) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_precision(clock->clock_class, precision); } int bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock, int64_t *offset_s) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_offset_s(clock->clock_class, offset_s); } int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, int64_t offset_s) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_offset_s(clock->clock_class, offset_s); } int bt_ctf_clock_get_offset(struct bt_ctf_clock *clock, int64_t *offset) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_offset_cycles(clock->clock_class, offset); } int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, int64_t offset) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_offset_cycles(clock->clock_class, offset); } int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_is_absolute(clock->clock_class); } int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_is_absolute(clock->clock_class, is_absolute); } const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_get_uuid(clock->clock_class); } int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock, const unsigned char *uuid) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); return bt_ctf_clock_class_set_uuid(clock->clock_class, uuid); } @@ -183,7 +183,7 @@ int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time) int64_t value; struct bt_ctf_clock_class *cc; - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); cc = clock->clock_class; /* Common case where cycles are actually nanoseconds */ @@ -194,7 +194,7 @@ int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time) (double) cc->frequency) / 1e9); } - BT_ASSERT_PRE(clock->value <= value, + BT_CTF_ASSERT_PRE(clock->value <= value, "CTF writer clock value must be updated monotonically: " "prev-value=%" PRId64 ", new-value=%" PRId64, clock->value, value); @@ -205,8 +205,8 @@ int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time) BT_HIDDEN int bt_ctf_clock_get_value(struct bt_ctf_clock *clock, uint64_t *value) { - BT_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); *value = clock->value; return 0; } diff --git a/lib/ctf-writer/event-class.c b/ctf-writer/event-class.c similarity index 99% rename from lib/ctf-writer/event-class.c rename to ctf-writer/event-class.c index f918b86d..3d8c1f5c 100644 --- a/lib/ctf-writer/event-class.c +++ b/ctf-writer/event-class.c @@ -22,9 +22,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-EVENT-CLASS" -#include +#include "logging.h" -#include +#include #include #include #include @@ -268,7 +268,7 @@ int bt_ctf_event_class_set_emf_uri(struct bt_ctf_event_class *event_class, struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class( struct bt_ctf_event_class *event_class) { - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); return bt_ctf_object_get_ref(bt_ctf_event_class_common_borrow_stream_class( BT_CTF_TO_COMMON(event_class))); } diff --git a/lib/ctf-writer/event.c b/ctf-writer/event.c similarity index 93% rename from lib/ctf-writer/event.c rename to ctf-writer/event.c index 62df18b2..b074cdb1 100644 --- a/lib/ctf-writer/event.c +++ b/ctf-writer/event.c @@ -22,9 +22,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-EVENT" -#include +#include "logging.h" -#include +#include #include #include #include @@ -221,7 +221,7 @@ int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event) ret = bt_ctf_field_common_validate_recursive( event->header_field->field); if (ret) { - BT_ASSERT_PRE_MSG("Invalid event's header field: " + BT_CTF_ASSERT_PRE_MSG("Invalid event's header field: " "event-addr=%p, field-addr=%p", event, event->header_field->field); goto end; @@ -240,7 +240,7 @@ int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event) ret = bt_ctf_field_common_validate_recursive( event->stream_event_context_field); if (ret) { - BT_ASSERT_PRE_MSG("Invalid event's stream event context field: " + BT_CTF_ASSERT_PRE_MSG("Invalid event's stream event context field: " "event-addr=%p, field-addr=%p", event, event->stream_event_context_field); goto end; @@ -250,7 +250,7 @@ int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event) if (event->class->context_field_type) { ret = bt_ctf_field_common_validate_recursive(event->context_field); if (ret) { - BT_ASSERT_PRE_MSG("Invalid event's payload field: " + BT_CTF_ASSERT_PRE_MSG("Invalid event's payload field: " "event-addr=%p, field-addr=%p", event, event->context_field); goto end; @@ -259,7 +259,7 @@ int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event) ret = bt_ctf_field_common_validate_recursive(event->payload_field); if (ret) { - BT_ASSERT_PRE_MSG("Invalid event's payload field: " + BT_CTF_ASSERT_PRE_MSG("Invalid event's payload field: " "event-addr=%p, field-addr=%p", event, event->payload_field); goto end; @@ -333,14 +333,14 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, init_expected_clock_class ? bt_ctf_object_get_ref(init_expected_clock_class) : NULL; - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_LOGD("Initializing common event object: event-class-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64, event_class, bt_ctf_event_class_common_get_name(event_class), bt_ctf_event_class_common_get_id(event_class)); stream_class = bt_ctf_event_class_common_borrow_stream_class(event_class); - BT_ASSERT_PRE(stream_class, + BT_CTF_ASSERT_PRE(stream_class, "Event class is not part of a stream class: event-class-addr=%p", event_class); @@ -349,7 +349,7 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, trace = bt_ctf_stream_class_common_borrow_trace(stream_class); if (must_be_in_trace) { - BT_ASSERT_PRE(trace, + BT_CTF_ASSERT_PRE(trace, "Event class's stream class is not part of a trace: " "ec-addr=%p, sc-addr=%p", event_class, stream_class); } @@ -637,7 +637,7 @@ end: struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); return bt_ctf_object_get_ref(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event))); } @@ -651,16 +651,16 @@ struct bt_ctf_stream *bt_ctf_event_borrow_stream(struct bt_ctf_event *event) struct bt_ctf_stream *bt_ctf_event_get_stream(struct bt_ctf_event *event) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); return bt_ctf_object_get_ref(bt_ctf_event_borrow_stream(event)); } int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *field) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_NON_NULL(field, "Payload field"); - BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(field, "Payload field"); + BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); return bt_ctf_field_structure_set_field_by_name( (void *) event->common.payload_field, name, field); } @@ -670,7 +670,7 @@ struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, { struct bt_ctf_field *field = NULL; - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); if (name) { field = bt_ctf_field_structure_get_field_by_name( @@ -761,15 +761,15 @@ void _bt_ctf_event_freeze(struct bt_ctf_event *event) int bt_ctf_event_set_header(struct bt_ctf_event *event, struct bt_ctf_field *header) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); /* * Ensure the provided header's type matches the one registered to the * stream class. */ if (header) { - BT_ASSERT_PRE(bt_ctf_field_type_common_compare( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_compare( ((struct bt_ctf_field_common *) header)->type, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type) == 0, "Header field's type is different from the " @@ -778,9 +778,9 @@ int bt_ctf_event_set_header(struct bt_ctf_event *event, event, ((struct bt_ctf_field_common *) header)->type, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type); } else { - BT_ASSERT_PRE(!bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type, + BT_CTF_ASSERT_PRE(!bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type, "Setting no event header field, " - "but event header field type is not NULL: ", + "but event header field type is not NULL: " "event-addr=%p, header-ft-addr=%p", event, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type); @@ -799,11 +799,11 @@ int bt_ctf_event_set_header(struct bt_ctf_event *event, int bt_ctf_event_common_set_payload(struct bt_ctf_event *event, struct bt_ctf_field *payload) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); if (payload) { - BT_ASSERT_PRE(bt_ctf_field_type_common_compare( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_compare( ((struct bt_ctf_field_common *) payload)->type, event->common.class->payload_field_type) == 0, "Payload field's type is different from the " @@ -813,9 +813,9 @@ int bt_ctf_event_common_set_payload(struct bt_ctf_event *event, ((struct bt_ctf_field_common *) payload)->type, event->common.class->payload_field_type); } else { - BT_ASSERT_PRE(!event->common.class->payload_field_type, + BT_CTF_ASSERT_PRE(!event->common.class->payload_field_type, "Setting no event payload field, " - "but event payload field type is not NULL: ", + "but event payload field type is not NULL: " "event-addr=%p, payload-ft-addr=%p", event, event->common.class->payload_field_type); } @@ -833,11 +833,11 @@ int bt_ctf_event_common_set_payload(struct bt_ctf_event *event, int bt_ctf_event_set_context(struct bt_ctf_event *event, struct bt_ctf_field *context) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); if (context) { - BT_ASSERT_PRE(bt_ctf_field_type_common_compare( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_compare( ((struct bt_ctf_field_common *) context)->type, event->common.class->context_field_type) == 0, "Context field's type is different from the " @@ -846,9 +846,9 @@ int bt_ctf_event_set_context(struct bt_ctf_event *event, event, ((struct bt_ctf_field_common *) context)->type, event->common.class->context_field_type); } else { - BT_ASSERT_PRE(!event->common.class->context_field_type, + BT_CTF_ASSERT_PRE(!event->common.class->context_field_type, "Setting no event context field, " - "but event context field type is not NULL: ", + "but event context field type is not NULL: " "event-addr=%p, context-ft-addr=%p", event, event->common.class->context_field_type); } @@ -866,11 +866,11 @@ int bt_ctf_event_set_context(struct bt_ctf_event *event, int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, struct bt_ctf_field *stream_event_context) { - BT_ASSERT_PRE_NON_NULL(event, "Event"); - BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(BT_CTF_TO_COMMON(event), "Event"); if (stream_event_context) { - BT_ASSERT_PRE(bt_ctf_field_type_common_compare( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_compare( ((struct bt_ctf_field_common *) stream_event_context)->type, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type) == 0, "Stream event context field's type is different from the " @@ -880,9 +880,9 @@ int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, ((struct bt_ctf_field_common *) stream_event_context)->type, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type); } else { - BT_ASSERT_PRE(!bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type, + BT_CTF_ASSERT_PRE(!bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type, "Setting no stream event context field, " - "but stream event context field type is not NULL: ", + "but stream event context field type is not NULL: " "event-addr=%p, context-ft-addr=%p", event, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type); diff --git a/lib/ctf-writer/field-path.c b/ctf-writer/field-path.c similarity index 98% rename from lib/ctf-writer/field-path.c rename to ctf-writer/field-path.c index eb6c0353..284e850d 100644 --- a/lib/ctf-writer/field-path.c +++ b/ctf-writer/field-path.c @@ -26,7 +26,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-FIELD-PATH" -#include +#include "logging.h" #include #include diff --git a/lib/ctf-writer/field-types.c b/ctf-writer/field-types.c similarity index 96% rename from lib/ctf-writer/field-types.c rename to ctf-writer/field-types.c index 64cdcd17..2d18c45c 100644 --- a/lib/ctf-writer/field-types.c +++ b/ctf-writer/field-types.c @@ -23,9 +23,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-FIELD-TYPES" -#include +#include "logging.h" -#include +#include #include #include #include @@ -621,8 +621,8 @@ bt_ctf_field_type_common_enumeration_find_mappings_type( { struct bt_ctf_field_type_enumeration_mapping_iterator *iter = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); iter = g_new0(struct bt_ctf_field_type_enumeration_mapping_iterator, 1); if (!iter) { @@ -697,7 +697,7 @@ int bt_ctf_field_type_enumeration_mapping_iterator_next( struct bt_ctf_field_type_common_enumeration *enum_ft = iter->enumeration_ft; int i, ret = 0, len; - BT_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); + BT_CTF_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); len = enum_ft->entries->len; for (i = iter->index + 1; i < len; i++) { struct bt_ctf_enumeration_mapping *mapping = @@ -814,8 +814,8 @@ int bt_ctf_field_type_enumeration_mapping_iterator_signed_get( const char **mapping_name, int64_t *range_begin, int64_t *range_end) { - BT_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); - BT_ASSERT_PRE(iter->index != -1, + BT_CTF_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); + BT_CTF_ASSERT_PRE(iter->index != -1, "Invalid enumeration field type mapping iterator access: " "addr=%p, position=-1", iter); return bt_ctf_field_type_common_enumeration_signed_get_mapping_by_index( @@ -829,8 +829,8 @@ int bt_ctf_field_type_enumeration_mapping_iterator_unsigned_get( const char **mapping_name, uint64_t *range_begin, uint64_t *range_end) { - BT_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); - BT_ASSERT_PRE(iter->index != -1, + BT_CTF_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator"); + BT_CTF_ASSERT_PRE(iter->index != -1, "Invalid enumeration field type mapping iterator access: " "addr=%p, position=-1", iter); return bt_ctf_field_type_common_enumeration_unsigned_get_mapping_by_index( @@ -1123,8 +1123,8 @@ int bt_ctf_field_type_common_integer_get_size(struct bt_ctf_field_type_common *f { struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, "Field type"); return (int) int_ft->size; } @@ -1134,8 +1134,8 @@ bt_bool bt_ctf_field_type_common_integer_is_signed(struct bt_ctf_field_type_comm { struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, "Field type"); return int_ft->is_signed; } @@ -1225,8 +1225,8 @@ enum bt_ctf_integer_base bt_ctf_field_type_common_integer_get_base( { struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, "Field type"); return int_ft->base; } @@ -1288,8 +1288,8 @@ enum bt_ctf_string_encoding bt_ctf_field_type_common_integer_get_encoding( { struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, "Field type"); return int_ft->encoding; } @@ -1345,8 +1345,8 @@ struct bt_ctf_clock_class *bt_ctf_field_type_common_integer_borrow_mapped_clock_ { struct bt_ctf_field_type_common_integer *int_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_INTEGER, "Field type"); return int_ft->mapped_clock_class; } @@ -1427,8 +1427,8 @@ int bt_ctf_field_type_common_enumeration_signed_get_mapping_by_index( int ret = 0; struct bt_ctf_enumeration_mapping *mapping; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); mapping = bt_ctf_field_type_common_enumeration_get_mapping_by_index(ft, index); @@ -1464,8 +1464,8 @@ int bt_ctf_field_type_common_enumeration_unsigned_get_mapping_by_index( int ret = 0; struct bt_ctf_enumeration_mapping *mapping; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); mapping = bt_ctf_field_type_common_enumeration_get_mapping_by_index( ft, index); if (!mapping) { @@ -1498,8 +1498,8 @@ bt_ctf_field_type_common_enumeration_borrow_container_field_type( { struct bt_ctf_field_type_common_enumeration *enum_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); return BT_CTF_TO_COMMON(enum_ft->container_ft); } @@ -1689,8 +1689,8 @@ int64_t bt_ctf_field_type_common_enumeration_get_mapping_count( { struct bt_ctf_field_type_common_enumeration *enum_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ENUM, "Field type"); return (int64_t) enum_ft->entries->len; } @@ -1700,8 +1700,8 @@ int bt_ctf_field_type_common_floating_point_get_exponent_digits( { struct bt_ctf_field_type_common_floating_point *flt_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_FLOAT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_FLOAT, "Field type"); return (int) flt_ft->exp_dig; } @@ -1759,8 +1759,8 @@ int bt_ctf_field_type_common_floating_point_get_mantissa_digits( { struct bt_ctf_field_type_common_floating_point *flt_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_FLOAT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_FLOAT, "Field type"); return (int) flt_ft->mant_dig; } @@ -1910,8 +1910,8 @@ int64_t bt_ctf_field_type_common_structure_get_field_count( { struct bt_ctf_field_type_common_structure *struct_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field type"); return (int64_t) struct_ft->fields->len; } @@ -1925,10 +1925,10 @@ int bt_ctf_field_type_common_structure_borrow_field_by_index( struct bt_ctf_field_type_common_structure *struct_ft = BT_CTF_FROM_COMMON(ft); struct bt_ctf_field_type_common_structure_field *field; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field type"); - BT_ASSERT_PRE(index < struct_ft->fields->len, + BT_CTF_ASSERT_PRE(index < struct_ft->fields->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u, ft-addr=%p", index, struct_ft->fields->len, ft); @@ -1957,9 +1957,9 @@ bt_ctf_field_type_common_structure_borrow_field_type_by_name( struct bt_ctf_field_type_common_structure *struct_ft = BT_CTF_FROM_COMMON(ft); struct bt_ctf_field_type_common *field_type = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field type"); name_quark = g_quark_try_string(name); if (!name_quark) { @@ -1992,8 +1992,8 @@ bt_ctf_field_type_common_variant_borrow_tag_field_type( struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); struct bt_ctf_field_type_common *tag_ft = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); if (!var_ft->tag_ft) { @@ -2015,8 +2015,8 @@ const char *bt_ctf_field_type_common_variant_get_tag_name( struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); const char *tag_name = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); if (var_ft->tag_name->len == 0) { @@ -2174,9 +2174,9 @@ bt_ctf_field_type_common_variant_borrow_field_type_by_name( struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); struct bt_ctf_field_type_common *field_type = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_NON_NULL(field_name, "Name"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(field_name, "Name"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); name_quark = g_quark_try_string(field_name); if (!name_quark) { @@ -2207,8 +2207,8 @@ int64_t bt_ctf_field_type_common_variant_get_field_count( { struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Variant field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Variant field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); return (int64_t) var_ft->choices->len; } @@ -2222,10 +2222,10 @@ int bt_ctf_field_type_common_variant_borrow_field_by_index( struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); struct bt_ctf_field_type_common_variant_choice *choice; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); - BT_ASSERT_PRE(index < var_ft->choices->len, + BT_CTF_ASSERT_PRE(index < var_ft->choices->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u, ft-addr=%p", index, var_ft->choices->len, ft); @@ -2307,8 +2307,8 @@ bt_ctf_field_type_common_array_borrow_element_field_type( { struct bt_ctf_field_type_common_array *array_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ARRAY, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ARRAY, "Field type"); BT_ASSERT(array_ft && array_ft->element_ft); return array_ft->element_ft; @@ -2359,8 +2359,8 @@ int64_t bt_ctf_field_type_common_array_get_length(struct bt_ctf_field_type_commo { struct bt_ctf_field_type_common_array *array_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ARRAY, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_ARRAY, "Field type"); return (int64_t) array_ft->length; } @@ -2371,8 +2371,8 @@ struct bt_ctf_field_type_common *bt_ctf_field_type_common_sequence_borrow_elemen { struct bt_ctf_field_type_common_sequence *seq_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, "Field type"); return seq_ft->element_ft; } @@ -2424,8 +2424,8 @@ const char *bt_ctf_field_type_common_sequence_get_length_field_name( { struct bt_ctf_field_type_common_sequence *seq_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, "Field type"); return seq_ft->length_field_name ? seq_ft->length_field_name->str : NULL; @@ -2437,8 +2437,8 @@ enum bt_ctf_string_encoding bt_ctf_field_type_common_string_get_encoding( { struct bt_ctf_field_type_common_string *string_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRING, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRING, "Field type"); return string_ft->encoding; } @@ -2486,7 +2486,7 @@ int bt_ctf_field_type_common_get_alignment(struct bt_ctf_field_type_common *ft) int ret; enum bt_ctf_field_type_id type_id; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); if (ft->frozen) { ret = (int) ft->alignment; @@ -2630,7 +2630,7 @@ enum bt_ctf_byte_order bt_ctf_field_type_common_get_byte_order( { enum bt_ctf_byte_order ret = BT_CTF_BYTE_ORDER_UNKNOWN; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); switch (ft->id) { case BT_CTF_FIELD_TYPE_ID_INTEGER: @@ -2718,7 +2718,7 @@ BT_HIDDEN enum bt_ctf_field_type_id bt_ctf_field_type_common_get_type_id( struct bt_ctf_field_type_common *ft) { - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); return ft->id; } @@ -2813,7 +2813,7 @@ struct bt_ctf_field_type_common *bt_ctf_field_type_common_copy( { struct bt_ctf_field_type_common *ft_copy = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); BT_ASSERT(ft->methods->copy); ft_copy = ft->methods->copy(ft); if (!ft_copy) { @@ -2836,9 +2836,9 @@ int bt_ctf_field_type_common_structure_get_field_name_index( GQuark name_quark; struct bt_ctf_field_type_common_structure *struct_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field type"); name_quark = g_quark_try_string(name); @@ -2875,9 +2875,9 @@ int bt_ctf_field_type_common_variant_get_field_name_index( GQuark name_quark; struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); name_quark = g_quark_try_string(name); if (!name_quark) { @@ -3699,8 +3699,8 @@ int bt_ctf_field_type_common_compare(struct bt_ctf_field_type_common *ft_a, { int ret = 1; - BT_ASSERT_PRE_NON_NULL(ft_a, "Field type A"); - BT_ASSERT_PRE_NON_NULL(ft_b, "Field type B"); + BT_CTF_ASSERT_PRE_NON_NULL(ft_a, "Field type A"); + BT_CTF_ASSERT_PRE_NON_NULL(ft_b, "Field type B"); if (ft_a == ft_b) { /* Same reference: equal (even if both are NULL) */ @@ -3848,8 +3848,8 @@ struct bt_ctf_field_path *bt_ctf_field_type_common_variant_borrow_tag_field_path { struct bt_ctf_field_type_common_variant *var_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); return var_ft->tag_field_path; } @@ -3860,8 +3860,8 @@ struct bt_ctf_field_path *bt_ctf_field_type_common_sequence_borrow_length_field_ { struct bt_ctf_field_type_common_sequence *seq_ft = BT_CTF_FROM_COMMON(ft); - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_SEQUENCE, "Field type"); return seq_ft->length_field_path; } @@ -4947,14 +4947,14 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag( struct bt_ctf_field_type_common_variant *var_ft = (void *) ft; struct bt_ctf_field_type *ret_ft = NULL; - BT_ASSERT_PRE_NON_NULL(ft, "Field type"); - BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, + BT_CTF_ASSERT_PRE_NON_NULL(ft, "Field type"); + BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(ft, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field type"); - BT_ASSERT_PRE_NON_NULL(tag_field, "Tag field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( + BT_CTF_ASSERT_PRE_NON_NULL(tag_field, "Tag field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( (struct bt_ctf_field_common *) tag_field, BT_CTF_FIELD_TYPE_ID_ENUM, "Tag field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((struct bt_ctf_field_common *) tag_field, + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((struct bt_ctf_field_common *) tag_field, "Tag field"); container = bt_ctf_field_enumeration_borrow_container(tag_field); @@ -4979,7 +4979,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag( } if (choice_index < 0) { - BT_LIB_LOGW("Cannot find variant field type's field: " + BT_LOGW("Cannot find variant field type's field: " "var-ft-addr=%p, tag-field-addr=%p", ft, tag_field); goto end; } diff --git a/lib/ctf-writer/field-wrapper.c b/ctf-writer/field-wrapper.c similarity index 94% rename from lib/ctf-writer/field-wrapper.c rename to ctf-writer/field-wrapper.c index f5629fcd..a5a3b46f 100644 --- a/lib/ctf-writer/field-wrapper.c +++ b/ctf-writer/field-wrapper.c @@ -21,7 +21,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-FIELD-WRAPPER" -#include +#include "logging.h" #include #include @@ -69,8 +69,7 @@ struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create( BT_ASSERT(ft); field_wrapper = bt_ctf_object_pool_create_object(pool); if (!field_wrapper) { - BT_LIB_LOGE("Cannot allocate one field wrapper from field wrapper pool: " - "%![pool-]+o", pool); + BT_LOGE("Cannot allocate one field wrapper"); goto error; } diff --git a/lib/ctf-writer/fields.c b/ctf-writer/fields.c similarity index 94% rename from lib/ctf-writer/fields.c rename to ctf-writer/fields.c index a0f00a9b..327f62e2 100644 --- a/lib/ctf-writer/fields.c +++ b/ctf-writer/fields.c @@ -23,9 +23,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-FIELDS" -#include +#include "logging.h" -#include +#include #include #include #include @@ -41,8 +41,8 @@ #include #include -#define BT_ASSERT_PRE_CTF_FIELD_IS_INT_OR_ENUM(_field, _name) \ - BT_ASSERT_PRE((_field)->type->id == BT_CTF_FIELD_TYPE_ID_INTEGER || \ +#define BT_CTF_ASSERT_PRE_CTF_FIELD_IS_INT_OR_ENUM(_field, _name) \ + BT_CTF_ASSERT_PRE((_field)->type->id == BT_CTF_FIELD_TYPE_ID_INTEGER || \ (_field)->type->id == BT_CTF_FIELD_TYPE_ID_ENUM, \ _name " is not an integer or an enumeration field: " \ "field-addr=%p", (_field)) @@ -52,7 +52,7 @@ struct bt_ctf_field_common *bt_ctf_field_common_copy(struct bt_ctf_field_common { struct bt_ctf_field_common *copy = NULL; - BT_ASSERT_PRE_NON_NULL(field, "Field"); + BT_CTF_ASSERT_PRE_NON_NULL(field, "Field"); BT_ASSERT(field_type_common_has_known_id(field->type)); BT_ASSERT(field->methods->copy); copy = field->methods->copy(field); @@ -287,7 +287,7 @@ int bt_ctf_field_common_structure_validate_recursive(struct bt_ctf_field_common this_ret = bt_ctf_field_type_common_structure_borrow_field_by_index( field->type, &name, NULL, i); BT_ASSERT(this_ret == 0); - BT_ASSERT_PRE_MSG("Invalid structure field's field: " + BT_CTF_ASSERT_PRE_MSG("Invalid structure field's field: " "struct-field-addr=%p, field-name=\"%s\", " "index=%" PRId64 ", field-addr=%p", field, name, i, structure->fields->pdata[i]); @@ -330,8 +330,8 @@ int bt_ctf_field_common_array_validate_recursive(struct bt_ctf_field_common *fie for (i = 0; i < array->elements->len; i++) { ret = bt_ctf_field_common_validate_recursive((void *) array->elements->pdata[i]); if (ret) { - BT_ASSERT_PRE_MSG("Invalid array field's element field: " - "array-field-addr=%p, " PRId64 ", " + BT_CTF_ASSERT_PRE_MSG("Invalid array field's element field: " + "array-field-addr=%p, %" PRId64 ", " "elem-field-addr=%p", field, i, array->elements->pdata[i]); goto end; @@ -345,7 +345,7 @@ end: BT_HIDDEN int bt_ctf_field_common_sequence_validate_recursive(struct bt_ctf_field_common *field) { - size_t i; + int64_t i; int ret = 0; struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field); @@ -355,8 +355,8 @@ int bt_ctf_field_common_sequence_validate_recursive(struct bt_ctf_field_common * ret = bt_ctf_field_common_validate_recursive( (void *) sequence->elements->pdata[i]); if (ret) { - BT_ASSERT_PRE_MSG("Invalid sequence field's element field: " - "seq-field-addr=%p, " PRId64 ", " + BT_CTF_ASSERT_PRE_MSG("Invalid sequence field's element field: " + "seq-field-addr=%p, %" PRId64 ", " "elem-field-addr=%p", field, i, sequence->elements->pdata[i]); goto end; @@ -864,7 +864,7 @@ int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field, bt_ctf_field_serialize_recursive_func serialize_func; BT_ASSERT(ctfser); - BT_ASSERT_PRE_NON_NULL(field, "Field"); + BT_CTF_ASSERT_PRE_NON_NULL(field, "Field"); BT_ASSERT(field_common->spec.writer.serialize_func); serialize_func = field_common->spec.writer.serialize_func; return serialize_func(field_common, ctfser, @@ -883,7 +883,7 @@ int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field, BT_CTF_FROM_COMMON(field); enum bt_ctf_byte_order byte_order; - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field"); BT_LOGV("Serializing CTF writer integer field: addr=%p, native-bo=%s", field, bt_ctf_byte_order_string(native_byte_order)); @@ -940,7 +940,7 @@ int bt_ctf_field_floating_point_serialize(struct bt_ctf_field_common *field, struct bt_ctf_field_common_floating_point *flt_field = BT_CTF_FROM_COMMON(field); enum bt_ctf_byte_order byte_order; - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field"); BT_LOGV("Serializing floating point number field: " "addr=%p, native-bo=%s", field, bt_ctf_byte_order_string(native_byte_order)); @@ -1123,7 +1123,7 @@ int bt_ctf_field_string_serialize(struct bt_ctf_field_common *field, int ret; struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field"); BT_LOGV("Serializing string field: addr=%p, native-bo=%s", field, bt_ctf_byte_order_string((int) native_byte_order)); ret = bt_ctfser_write_string(ctfser, (const char *) string->buf->data); @@ -1141,9 +1141,9 @@ struct bt_ctf_field *bt_ctf_field_create(struct bt_ctf_field_type *type) struct bt_ctf_field *field = NULL; enum bt_ctf_field_type_id type_id; - BT_ASSERT_PRE_NON_NULL(type, "Field type"); + BT_CTF_ASSERT_PRE_NON_NULL(type, "Field type"); BT_ASSERT(field_type_common_has_known_id((void *) type)); - BT_ASSERT_PRE(bt_ctf_field_type_common_validate((void *) type) == 0, + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_validate((void *) type) == 0, "Field type is invalid: ft-addr=%p", type); type_id = bt_ctf_field_type_get_type_id(type); field = field_create_funcs[type_id](type); @@ -1166,7 +1166,7 @@ enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field) { struct bt_ctf_field_common *field_common = (void *) field; - BT_ASSERT_PRE_NON_NULL(field, "Field"); + BT_CTF_ASSERT_PRE_NON_NULL(field, "Field"); return (int) field_common->type->id; } @@ -1177,9 +1177,9 @@ int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field, struct bt_ctf_field_common *common_length_field = (void *) length_field; uint64_t length; - BT_ASSERT_PRE_NON_NULL(length_field, "Length field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((void *) length_field, "Length field"); - BT_ASSERT_PRE(common_length_field->type->id == BT_CTF_FIELD_TYPE_ID_INTEGER || + BT_CTF_ASSERT_PRE_NON_NULL(length_field, "Length field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((void *) length_field, "Length field"); + BT_CTF_ASSERT_PRE(common_length_field->type->id == BT_CTF_FIELD_TYPE_ID_INTEGER || common_length_field->type->id == BT_CTF_FIELD_TYPE_ID_ENUM, "Length field must be an integer or enumeration field: field-addr=%p", length_field); @@ -1237,20 +1237,20 @@ struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *field, uint64_t tag_uval; int ret; - BT_ASSERT_PRE_NON_NULL(field, "Variant field"); - BT_ASSERT_PRE_NON_NULL(tag_field, "Tag field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((void *) tag_field, "Tag field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( + BT_CTF_ASSERT_PRE_NON_NULL(field, "Variant field"); + BT_CTF_ASSERT_PRE_NON_NULL(tag_field, "Tag field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET((void *) tag_field, "Tag field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( (struct bt_ctf_field_common *) tag_field, BT_CTF_FIELD_TYPE_ID_ENUM, "Tag field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID( (struct bt_ctf_field_common *) field, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field"); - BT_ASSERT_PRE( + BT_CTF_ASSERT_PRE( bt_ctf_field_common_validate_recursive((void *) tag_field) == 0, "Tag field is invalid: field-addr=%p", tag_field); variant_ft = BT_CTF_FROM_COMMON(variant_field->common.common.type); - BT_ASSERT_PRE(bt_ctf_field_type_common_compare( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_compare( BT_CTF_TO_COMMON(variant_ft->tag_ft), enum_field->common.type) == 0, "Unexpected tag field's type: expected-ft-addr=%p, " "tag-ft-addr=%p", variant_ft->tag_ft, @@ -1298,8 +1298,8 @@ struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container( { struct bt_ctf_field_enumeration *enumeration = (void *) field; - BT_ASSERT_PRE_NON_NULL(field, "Enumeration field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID((struct bt_ctf_field_common *) field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Enumeration field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID((struct bt_ctf_field_common *) field, BT_CTF_FIELD_TYPE_ID_ENUM, "Field"); BT_ASSERT(enumeration->container); return (void *) enumeration->container; @@ -1316,12 +1316,12 @@ int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field, { struct bt_ctf_field_common_integer *integer = (void *) field; - BT_ASSERT_PRE_NON_NULL(field, "Integer field"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(BT_CTF_TO_COMMON(integer), "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), + BT_CTF_ASSERT_PRE_NON_NULL(field, "Integer field"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(BT_CTF_TO_COMMON(integer), "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), BT_CTF_FIELD_TYPE_ID_INTEGER, "Field"); - BT_ASSERT_PRE(bt_ctf_field_type_common_integer_is_signed( + BT_CTF_ASSERT_PRE(bt_ctf_field_type_common_integer_is_signed( integer->common.type), "Field's type is unsigned: field-addr=%p", field); *value = integer->payload.signd; @@ -1335,15 +1335,15 @@ int bt_ctf_field_integer_signed_set_value(struct bt_ctf_field *field, struct bt_ctf_field_common_integer *integer = (void *) field; struct bt_ctf_field_type_common_integer *integer_type; - BT_ASSERT_PRE_NON_NULL(field, "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(BT_CTF_TO_COMMON(integer), "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), + BT_CTF_ASSERT_PRE_NON_NULL(field, "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(BT_CTF_TO_COMMON(integer), "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), BT_CTF_FIELD_TYPE_ID_INTEGER, "Field"); integer_type = BT_CTF_FROM_COMMON(integer->common.type); - BT_ASSERT_PRE( + BT_CTF_ASSERT_PRE( bt_ctf_field_type_common_integer_is_signed(integer->common.type), "Field's type is unsigned: field-addr=%p", field); - BT_ASSERT_PRE(value_is_in_range_signed(integer_type->size, value), + BT_CTF_ASSERT_PRE(value_is_in_range_signed(integer_type->size, value), "Value is out of bounds: value=%" PRId64 ", field-addr=%p", value, field); integer->payload.signd = value; @@ -1356,12 +1356,12 @@ int bt_ctf_field_integer_unsigned_get_value(struct bt_ctf_field *field, { struct bt_ctf_field_common_integer *integer = (void *) field; - BT_ASSERT_PRE_NON_NULL(field, "Integer field"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(BT_CTF_TO_COMMON(integer), "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), + BT_CTF_ASSERT_PRE_NON_NULL(field, "Integer field"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(BT_CTF_TO_COMMON(integer), "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), BT_CTF_FIELD_TYPE_ID_INTEGER, "Field"); - BT_ASSERT_PRE( + BT_CTF_ASSERT_PRE( !bt_ctf_field_type_common_integer_is_signed(integer->common.type), "Field's type is signed: field-addr=%p", field); *value = integer->payload.unsignd; @@ -1374,15 +1374,15 @@ int bt_ctf_field_integer_unsigned_set_value(struct bt_ctf_field *field, struct bt_ctf_field_common_integer *integer = (void *) field; struct bt_ctf_field_type_common_integer *integer_type; - BT_ASSERT_PRE_NON_NULL(field, "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(BT_CTF_TO_COMMON(integer), "Integer field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), + BT_CTF_ASSERT_PRE_NON_NULL(field, "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(BT_CTF_TO_COMMON(integer), "Integer field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(BT_CTF_TO_COMMON(integer), BT_CTF_FIELD_TYPE_ID_INTEGER, "Field"); integer_type = BT_CTF_FROM_COMMON(integer->common.type); - BT_ASSERT_PRE( + BT_CTF_ASSERT_PRE( !bt_ctf_field_type_common_integer_is_signed(integer->common.type), "Field's type is signed: field-addr=%p", field); - BT_ASSERT_PRE(value_is_in_range_unsigned(integer_type->size, value), + BT_CTF_ASSERT_PRE(value_is_in_range_unsigned(integer_type->size, value), "Value is out of bounds: value=%" PRIu64 ", field-addr=%p", value, field); integer->payload.unsignd = value; @@ -1793,7 +1793,7 @@ void bt_ctf_field_variant_reset_recursive(struct bt_ctf_field_common *field) bt_ctf_field_common_variant_reset_recursive((void *) field); } -BT_ASSERT_PRE_FUNC +BT_CTF_ASSERT_PRE_FUNC static inline bool field_to_set_has_expected_type( struct bt_ctf_field_common *struct_field, const char *name, struct bt_ctf_field_common *value) @@ -1806,7 +1806,7 @@ static inline bool field_to_set_has_expected_type( struct_field->type, name); if (bt_ctf_field_type_common_compare(expected_field_type, value->type)) { - BT_ASSERT_PRE_MSG("Value field's type is different from the expected field type: " + BT_CTF_ASSERT_PRE_MSG("Value field's type is different from the expected field type: " "value-ft-addr=%p, expected-ft-addr=%p", value->type, expected_field_type); ret = false; @@ -1831,12 +1831,12 @@ int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field, GHashTable *field_name_to_index; struct bt_ctf_field_type_common_structure *structure_ft; - BT_ASSERT_PRE_NON_NULL(field, "Parent field"); - BT_ASSERT_PRE_NON_NULL(name, "Field name"); - BT_ASSERT_PRE_NON_NULL(value, "Value field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(common_field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Parent field"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Field name"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(common_field, BT_CTF_FIELD_TYPE_ID_STRUCT, "Parent field"); - BT_ASSERT_PRE(field_to_set_has_expected_type(common_field, + BT_CTF_ASSERT_PRE(field_to_set_has_expected_type(common_field, name, common_value), "Value field's type is different from the expected field type."); field_quark = g_quark_from_string(name); diff --git a/lib/ctf-writer/functor.c b/ctf-writer/functor.c similarity index 100% rename from lib/ctf-writer/functor.c rename to ctf-writer/functor.c diff --git a/ctf-writer/logging.c b/ctf-writer/logging.c new file mode 100644 index 00000000..641d5d99 --- /dev/null +++ b/ctf-writer/logging.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2017 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_OUTPUT_LEVEL bt_lib_ctf_writer_log_level +#include "logging.h" + +BT_LOG_INIT_LOG_LEVEL(bt_lib_ctf_writer_log_level, + "BABELTRACE_CTF_WRITER_LOG_LEVEL"); diff --git a/ctf-writer/logging.h b/ctf-writer/logging.h new file mode 100644 index 00000000..a6cf543d --- /dev/null +++ b/ctf-writer/logging.h @@ -0,0 +1,31 @@ +#ifndef BABELTRACE_CTF_WRITER_LOGGING_H +#define BABELTRACE_CTF_WRITER_LOGGING_H + +/* + * Copyright (c) 2017 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_OUTPUT_LEVEL bt_lib_ctf_writer_log_level +#include + +BT_LOG_LEVEL_EXTERN_SYMBOL(bt_lib_ctf_writer_log_level); + +#endif /* BABELTRACE_CTF_WRITER_LOGGING_H */ diff --git a/lib/ctf-writer/object-pool.c b/ctf-writer/object-pool.c similarity index 94% rename from lib/ctf-writer/object-pool.c rename to ctf-writer/object-pool.c index e62356be..2d932ac9 100644 --- a/lib/ctf-writer/object-pool.c +++ b/ctf-writer/object-pool.c @@ -22,7 +22,7 @@ */ #define BT_LOG_TAG "OBJECT-POOL" -#include +#include "logging.h" #include #include @@ -49,7 +49,7 @@ int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool, pool->funcs.destroy_object = destroy_object_func; pool->data = data; pool->size = 0; - BT_LIB_LOGD("Initialized object pool: %!+o", pool); + BT_LOGD("Initialized object pool."); goto end; error: @@ -68,7 +68,7 @@ void bt_ctf_object_pool_finalize(struct bt_ctf_object_pool *pool) uint64_t i; BT_ASSERT(pool); - BT_LIB_LOGD("Finalizing object pool: %!+o", pool); + BT_LOGD("Finalizing object pool."); if (pool->objects) { for (i = 0; i < pool->size; i++) { diff --git a/lib/ctf-writer/object.c b/ctf-writer/object.c similarity index 100% rename from lib/ctf-writer/object.c rename to ctf-writer/object.c diff --git a/lib/ctf-writer/resolve.c b/ctf-writer/resolve.c similarity index 99% rename from lib/ctf-writer/resolve.c rename to ctf-writer/resolve.c index bbb81ac6..b0a5e156 100644 --- a/lib/ctf-writer/resolve.c +++ b/ctf-writer/resolve.c @@ -29,7 +29,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-RESOLVE" -#include +#include "logging.h" #include #include diff --git a/lib/ctf-writer/stream-class.c b/ctf-writer/stream-class.c similarity index 99% rename from lib/ctf-writer/stream-class.c rename to ctf-writer/stream-class.c index bcb79f51..4b61a7ec 100644 --- a/lib/ctf-writer/stream-class.c +++ b/ctf-writer/stream-class.c @@ -22,9 +22,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-STREAM-CLASS" -#include +#include "logging.h" -#include +#include #include #include #include diff --git a/lib/ctf-writer/stream.c b/ctf-writer/stream.c similarity index 99% rename from lib/ctf-writer/stream.c rename to ctf-writer/stream.c index 4f0eee03..fc7557ee 100644 --- a/lib/ctf-writer/stream.c +++ b/ctf-writer/stream.c @@ -22,9 +22,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-STREAM" -#include +#include "logging.h" -#include +#include #include #include #include @@ -1423,7 +1423,7 @@ int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, /* Make sure the various scopes of the event are set */ BT_LOGV_STR("Validating event to append."); - BT_ASSERT_PRE(bt_ctf_event_common_validate(BT_CTF_TO_COMMON(event)) == 0, + BT_CTF_ASSERT_PRE(bt_ctf_event_common_validate(BT_CTF_TO_COMMON(event)) == 0, "Invalid event: event-addr=%p", event); /* Save the new event and freeze it */ diff --git a/lib/ctf-writer/trace.c b/ctf-writer/trace.c similarity index 99% rename from lib/ctf-writer/trace.c rename to ctf-writer/trace.c index e9db29a3..8737470c 100644 --- a/lib/ctf-writer/trace.c +++ b/ctf-writer/trace.c @@ -22,7 +22,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-TRACE" -#include +#include "logging.h" #include #include diff --git a/lib/ctf-writer/utils.c b/ctf-writer/utils.c similarity index 98% rename from lib/ctf-writer/utils.c rename to ctf-writer/utils.c index fbf515b0..fdf0a933 100644 --- a/lib/ctf-writer/utils.c +++ b/ctf-writer/utils.c @@ -27,7 +27,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-UTILS" -#include +#include "logging.h" #include #include diff --git a/lib/ctf-writer/validation.c b/ctf-writer/validation.c similarity index 99% rename from lib/ctf-writer/validation.c rename to ctf-writer/validation.c index 97a279aa..9c4276eb 100644 --- a/lib/ctf-writer/validation.c +++ b/ctf-writer/validation.c @@ -25,9 +25,9 @@ */ #define BT_LOG_TAG "CTF-WRITER-VALIDATION" -#include +#include "logging.h" -#include +#include #include #include #include diff --git a/lib/ctf-writer/values.c b/ctf-writer/values.c similarity index 89% rename from lib/ctf-writer/values.c rename to ctf-writer/values.c index 7c45dafa..dd8ae949 100644 --- a/lib/ctf-writer/values.c +++ b/ctf-writer/values.c @@ -22,7 +22,7 @@ */ #define BT_LOG_TAG "CTF-WRITER-VALUES" -#include +#include "logging.h" #include #include @@ -37,7 +37,7 @@ #include #include #include -#include +#include #define BT_CTF_VALUE_FROM_CONCRETE(_concrete) ((struct bt_ctf_value *) (_concrete)) #define BT_CTF_VALUE_TO_BOOL(_base) ((struct bt_ctf_value_bool *) (_base)) @@ -47,18 +47,15 @@ #define BT_CTF_VALUE_TO_ARRAY(_base) ((struct bt_ctf_value_array *) (_base)) #define BT_CTF_VALUE_TO_MAP(_base) ((struct bt_ctf_value_map *) (_base)) -#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \ - BT_ASSERT_PRE(((struct bt_ctf_value *) (_value))->type == (_type), \ - "Value has the wrong type ID: expected-type=%d, " \ - "%![value-]+v", (_type), \ - (_value)) +#define BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \ + BT_CTF_ASSERT_PRE(((struct bt_ctf_value *) (_value))->type == (_type), \ + "Value has the wrong type ID: expected-type=%d", (_type)) -#define BT_ASSERT_PRE_VALUE_HOT(_value, _name) \ - BT_ASSERT_PRE_HOT(((struct bt_ctf_value *) (_value)), (_name), \ - ": %!+v", (_value)) +#define BT_CTF_ASSERT_PRE_VALUE_HOT(_value, _name) \ + BT_CTF_ASSERT_PRE_HOT(((struct bt_ctf_value *) (_value)), (_name), "") -#define BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(_index, _count) \ - BT_ASSERT_PRE((_index) < (_count), \ +#define BT_CTF_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(_index, _count) \ + BT_CTF_ASSERT_PRE((_index) < (_count), \ "Index is out of bound: " \ "index=%" PRIu64 ", count=%u", (_index), (_count)); @@ -584,7 +581,7 @@ end: BT_HIDDEN enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object) { - BT_ASSERT_PRE_NON_NULL(object, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(object, "Value object"); return object->type; } @@ -779,17 +776,17 @@ end: BT_HIDDEN bt_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj) { - BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL); + BT_CTF_ASSERT_PRE_NON_NULL(bool_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL); return BT_CTF_VALUE_TO_BOOL(bool_obj)->value; } BT_HIDDEN void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj, bt_bool val) { - BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL); - BT_ASSERT_PRE_VALUE_HOT(bool_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(bool_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_CTF_VALUE_TYPE_BOOL); + BT_CTF_ASSERT_PRE_VALUE_HOT(bool_obj, "Value object"); BT_CTF_VALUE_TO_BOOL(bool_obj)->value = val; BT_LOGV("Set boolean value's raw value: value-addr=%p, value=%d", bool_obj, val); @@ -798,8 +795,8 @@ void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj, bt_boo BT_HIDDEN int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj) { - BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER); + BT_CTF_ASSERT_PRE_NON_NULL(integer_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER); return BT_CTF_VALUE_TO_INTEGER(integer_obj)->value; } @@ -807,9 +804,9 @@ BT_HIDDEN void bt_ctf_private_value_integer_set(struct bt_ctf_private_value *integer_obj, int64_t val) { - BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER); - BT_ASSERT_PRE_VALUE_HOT(integer_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(integer_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_CTF_VALUE_TYPE_INTEGER); + BT_CTF_ASSERT_PRE_VALUE_HOT(integer_obj, "Value object"); BT_CTF_VALUE_TO_INTEGER(integer_obj)->value = val; BT_LOGV("Set integer value's raw value: value-addr=%p, value=%" PRId64, integer_obj, val); @@ -818,17 +815,17 @@ void bt_ctf_private_value_integer_set(struct bt_ctf_private_value *integer_obj, BT_HIDDEN double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj) { - BT_ASSERT_PRE_NON_NULL(real_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL); + BT_CTF_ASSERT_PRE_NON_NULL(real_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL); return BT_CTF_VALUE_TO_REAL(real_obj)->value; } BT_HIDDEN void bt_ctf_private_value_real_set(struct bt_ctf_private_value *real_obj, double val) { - BT_ASSERT_PRE_NON_NULL(real_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL); - BT_ASSERT_PRE_VALUE_HOT(real_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(real_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_CTF_VALUE_TYPE_REAL); + BT_CTF_ASSERT_PRE_VALUE_HOT(real_obj, "Value object"); BT_CTF_VALUE_TO_REAL(real_obj)->value = val; BT_LOGV("Set real number value's raw value: value-addr=%p, value=%f", real_obj, val); @@ -837,8 +834,8 @@ void bt_ctf_private_value_real_set(struct bt_ctf_private_value *real_obj, double BT_HIDDEN const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj) { - BT_ASSERT_PRE_NON_NULL(string_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING); + BT_CTF_ASSERT_PRE_NON_NULL(string_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING); return BT_CTF_VALUE_TO_STRING(string_obj)->gstr->str; } @@ -846,9 +843,9 @@ BT_HIDDEN enum bt_ctf_value_status bt_ctf_private_value_string_set( struct bt_ctf_private_value *string_obj, const char *val) { - BT_ASSERT_PRE_NON_NULL(string_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING); - BT_ASSERT_PRE_VALUE_HOT(string_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(string_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_CTF_VALUE_TYPE_STRING); + BT_CTF_ASSERT_PRE_VALUE_HOT(string_obj, "Value object"); g_string_assign(BT_CTF_VALUE_TO_STRING(string_obj)->gstr, val); BT_LOGV("Set string value's raw value: value-addr=%p, raw-value-addr=%p", string_obj, val); @@ -858,8 +855,8 @@ enum bt_ctf_value_status bt_ctf_private_value_string_set( BT_HIDDEN uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj) { - BT_ASSERT_PRE_NON_NULL(array_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); + BT_CTF_ASSERT_PRE_NON_NULL(array_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); return (uint64_t) BT_CTF_VALUE_TO_ARRAY(array_obj)->garray->len; } @@ -871,9 +868,9 @@ struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index( struct bt_ctf_value_array *typed_array_obj = BT_CTF_VALUE_TO_ARRAY(array_obj); - BT_ASSERT_PRE_NON_NULL(array_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); - BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index, + BT_CTF_ASSERT_PRE_NON_NULL(array_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); + BT_CTF_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index, typed_array_obj->garray->len); return g_ptr_array_index(typed_array_obj->garray, index); } @@ -895,10 +892,10 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_element( struct bt_ctf_value_array *typed_array_obj = BT_CTF_VALUE_TO_ARRAY(array_obj); - BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); - BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); - BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); + BT_CTF_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); + BT_CTF_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); + BT_CTF_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); g_ptr_array_add(typed_array_obj->garray, element_obj); bt_ctf_object_get_ref(element_obj); BT_LOGV("Appended element to array value: array-value-addr=%p, " @@ -999,11 +996,11 @@ enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index( struct bt_ctf_value_array *typed_array_obj = BT_CTF_VALUE_TO_ARRAY(array_obj); - BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); - BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); - BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); - BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index, + BT_CTF_ASSERT_PRE_NON_NULL(array_obj, "Array value object"); + BT_CTF_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY); + BT_CTF_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); + BT_CTF_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index, typed_array_obj->garray->len); bt_ctf_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index)); g_ptr_array_index(typed_array_obj->garray, index) = element_obj; @@ -1017,8 +1014,8 @@ enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index( BT_HIDDEN uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj) { - BT_ASSERT_PRE_NON_NULL(map_obj, "Value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); return (uint64_t) g_hash_table_size(BT_CTF_VALUE_TO_MAP(map_obj)->ght); } @@ -1026,9 +1023,9 @@ BT_HIDDEN struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(const struct bt_ctf_value *map_obj, const char *key) { - BT_ASSERT_PRE_NON_NULL(map_obj, "Value object"); - BT_ASSERT_PRE_NON_NULL(key, "Key"); - BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(key, "Key"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); return g_hash_table_lookup(BT_CTF_VALUE_TO_MAP(map_obj)->ght, GUINT_TO_POINTER(g_quark_from_string(key))); } @@ -1043,9 +1040,9 @@ struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value( BT_HIDDEN bt_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj, const char *key) { - BT_ASSERT_PRE_NON_NULL(map_obj, "Value object"); - BT_ASSERT_PRE_NON_NULL(key, "Key"); - BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(key, "Key"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); return bt_g_hash_table_contains(BT_CTF_VALUE_TO_MAP(map_obj)->ght, GUINT_TO_POINTER(g_quark_from_string(key))); } @@ -1055,11 +1052,11 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry( struct bt_ctf_private_value *map_obj, const char *key, struct bt_ctf_value *element_obj) { - BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object"); - BT_ASSERT_PRE_NON_NULL(key, "Key"); - BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); - BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); - BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object"); + BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Map value object"); + BT_CTF_ASSERT_PRE_NON_NULL(key, "Key"); + BT_CTF_ASSERT_PRE_NON_NULL(element_obj, "Element value object"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object"); g_hash_table_insert(BT_CTF_VALUE_TO_MAP(map_obj)->ght, GUINT_TO_POINTER(g_quark_from_string(key)), element_obj); bt_ctf_object_get_ref(element_obj); @@ -1163,9 +1160,9 @@ enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(const struct bt_ctf_valu GHashTableIter iter; struct bt_ctf_value_map *typed_map_obj = BT_CTF_VALUE_TO_MAP(map_obj); - BT_ASSERT_PRE_NON_NULL(map_obj, "Value object"); - BT_ASSERT_PRE_NON_NULL(cb, "Callback"); - BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(cb, "Callback"); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_CTF_VALUE_TYPE_MAP); g_hash_table_iter_init(&iter, typed_map_obj->ght); while (g_hash_table_iter_next(&iter, &key, &element_obj)) { @@ -1250,12 +1247,12 @@ enum bt_ctf_value_status bt_ctf_value_map_extend( .status = BT_CTF_VALUE_STATUS_OK, }; - BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object"); - BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object"); - BT_ASSERT_PRE_NON_NULL(extended_map_obj, + BT_CTF_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object"); + BT_CTF_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object"); + BT_CTF_ASSERT_PRE_NON_NULL(extended_map_obj, "Extended value object (output)"); - BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_CTF_VALUE_TYPE_MAP); - BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_CTF_VALUE_TYPE_MAP); + BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_CTF_VALUE_TYPE_MAP); BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p", base_map_obj, extension_obj); *extended_map_obj = NULL; @@ -1307,8 +1304,8 @@ enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy_ob { enum bt_ctf_value_status status = BT_CTF_VALUE_STATUS_OK; - BT_ASSERT_PRE_NON_NULL(object, "Value object"); - BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)"); + BT_CTF_ASSERT_PRE_NON_NULL(object, "Value object"); + BT_CTF_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)"); BT_LOGD("Copying value object: addr=%p", object); *copy_obj = copy_funcs[object->type](object); if (*copy_obj) { @@ -1329,8 +1326,8 @@ bt_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a, { bt_bool ret = BT_FALSE; - BT_ASSERT_PRE_NON_NULL(object_a, "Value object A"); - BT_ASSERT_PRE_NON_NULL(object_b, "Value object B"); + BT_CTF_ASSERT_PRE_NON_NULL(object_a, "Value object A"); + BT_CTF_ASSERT_PRE_NON_NULL(object_b, "Value object B"); if (object_a->type != object_b->type) { BT_LOGV("Values are different: type mismatch: " diff --git a/lib/ctf-writer/visitor.c b/ctf-writer/visitor.c similarity index 100% rename from lib/ctf-writer/visitor.c rename to ctf-writer/visitor.c diff --git a/lib/ctf-writer/writer.c b/ctf-writer/writer.c similarity index 99% rename from lib/ctf-writer/writer.c rename to ctf-writer/writer.c index e0215d33..949bbea2 100644 --- a/lib/ctf-writer/writer.c +++ b/ctf-writer/writer.c @@ -27,7 +27,7 @@ */ #define BT_LOG_TAG "CTF-WRITER" -#include +#include "logging.h" #include #include diff --git a/extras/gen-babeltrace-h.py b/extras/gen-babeltrace-h.py index f03110fc..7c64a676 100644 --- a/extras/gen-babeltrace-h.py +++ b/extras/gen-babeltrace-h.py @@ -45,6 +45,9 @@ def _c_includes_from_sections(sections): src = '' for section in sections: + if 'ctf' in section.title.lower(): + continue + src += '/* {} */\n'.format(section.title) for filename in sorted(section.filenames): diff --git a/include/Makefile.am b/include/Makefile.am index e069b2cc..a340b805 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -235,6 +235,7 @@ noinst_HEADERS = \ babeltrace2/plugin/python-plugin-provider-internal.h \ babeltrace2/assert-internal.h \ babeltrace2/value-internal.h \ + babeltrace2/ctf-writer/assert-pre-internal.h \ babeltrace2/ctf-writer/attributes-internal.h \ babeltrace2/ctf-writer/clock-class-internal.h \ babeltrace2/ctf-writer/clock-internal.h \ diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 45509a8a..20d50f59 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -34,37 +34,6 @@ #include #include -/* Legacy API (for CTF writer) */ -#include - -/* CTF writer API */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Legacy API (for CTF writer) */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - /* Trace IR API */ #include #include diff --git a/include/babeltrace2/ctf-writer/assert-pre-internal.h b/include/babeltrace2/ctf-writer/assert-pre-internal.h new file mode 100644 index 00000000..3ac3af1c --- /dev/null +++ b/include/babeltrace2/ctf-writer/assert-pre-internal.h @@ -0,0 +1,129 @@ +#ifndef BABELTRACE_CTF_WRITER_ASSERT_PRE_INTERNAL_H +#define BABELTRACE_CTF_WRITER_ASSERT_PRE_INTERNAL_H + +/* + * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation + * Copyright (c) 2018 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * The macros in this header use macros defined in + * . We don't want this header to + * automatically include because you + * need to manually define BT_LOG_TAG before including + * and it is unexpected that you + * also need to define it before including this header. + * + * This is a reminder that in order to use + * , you also need to use logging + * explicitly. + */ + +#ifndef BABELTRACE_LOGGING_INTERNAL_H +# error Include before this header. +#endif + +#include +#include +#include + +#ifdef BT_DEV_MODE +/* + * Asserts that the library precondition _cond is satisfied. + * + * If _cond is false, log a fatal statement using _fmt and the optional + * arguments using BT_LOGF(), and abort. + * + * To assert that a postcondition is satisfied or that some internal + * object/context/value is in the expected state, use BT_ASSERT(). + */ +# define BT_CTF_ASSERT_PRE(_cond, _fmt, ...) \ + do { \ + if (!(_cond)) { \ + BT_LOGF_STR("Library precondition not satisfied; error is:"); \ + BT_LOGF((_fmt), ##__VA_ARGS__); \ + BT_LOGF_STR("Aborting..."); \ + abort(); \ + } \ + } while (0) + +/* + * Marks a function as being only used within a BT_CTF_ASSERT_PRE() context. + */ +# define BT_CTF_ASSERT_PRE_FUNC + +/* + * Prints the details of an unsatisfied precondition without immediately + * aborting. You should use this within a function which checks + * preconditions, but which is called from a BT_CTF_ASSERT_PRE() context, so + * that the function can still return its result for BT_CTF_ASSERT_PRE() to + * evaluate it. + * + * Example: + * + * BT_CTF_ASSERT_PRE_FUNC + * static inline bool check_complex_precond(...) + * { + * ... + * + * if (...) { + * BT_CTF_ASSERT_PRE_MSG("Invalid object: ...", ...); + * return false; + * } + * + * ... + * } + * + * ... + * + * BT_CTF_ASSERT_PRE(check_complex_precond(...), + * "Precondition is not satisfied: ...", ...); + */ +# define BT_CTF_ASSERT_PRE_MSG BT_LOGF +#else +# define BT_CTF_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) +# define BT_CTF_ASSERT_PRE_FUNC BT_UNUSED +# define BT_CTF_ASSERT_PRE_MSG(_fmt, ...) +#endif /* BT_DEV_MODE */ + +/* + * Developer mode: asserts that a given variable is not NULL. + */ +#define BT_CTF_ASSERT_PRE_NON_NULL(_obj, _obj_name) \ + BT_CTF_ASSERT_PRE((_obj) != NULL, "%s is NULL: ", _obj_name) + +/* + * Developer mode: asserts that a given object is NOT frozen. This macro + * checks the `frozen` field of _obj. + */ +#define BT_CTF_ASSERT_PRE_HOT(_obj, _obj_name, _fmt, ...) \ + BT_CTF_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name, \ + ##__VA_ARGS__) + +/* + * Developer mode: asserts that a given index is less than a given size. + */ +#define BT_CTF_ASSERT_PRE_VALID_INDEX(_index, _length) \ + BT_CTF_ASSERT_PRE((_index) < (_length), \ + "Index is out of bounds: index=%" PRIu64 ", " \ + "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length)) + +#endif /* BABELTRACE_CTF_WRITER_ASSERT_PRE_INTERNAL_H */ diff --git a/include/babeltrace2/ctf-writer/event-class-internal.h b/include/babeltrace2/ctf-writer/event-class-internal.h index 34ce8ce4..c67184ae 100644 --- a/include/babeltrace2/ctf-writer/event-class-internal.h +++ b/include/babeltrace2/ctf-writer/event-class-internal.h @@ -92,7 +92,7 @@ static inline const char *bt_ctf_event_class_common_get_name( struct bt_ctf_event_class_common *event_class) { - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT(event_class->name); return event_class->name->str; } @@ -101,7 +101,7 @@ static inline int64_t bt_ctf_event_class_common_get_id( struct bt_ctf_event_class_common *event_class) { - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); return event_class->id; } @@ -151,7 +151,7 @@ static inline int bt_ctf_event_class_common_get_log_level( struct bt_ctf_event_class_common *event_class) { - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); return event_class->log_level; } @@ -221,7 +221,7 @@ const char *bt_ctf_event_class_common_get_emf_uri( { const char *emf_uri = NULL; - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); if (event_class->emf_uri->len > 0) { emf_uri = event_class->emf_uri->str; @@ -282,7 +282,7 @@ struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_context_field_ { struct bt_ctf_field_type_common *context_ft = NULL; - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); if (!event_class->context_field_type) { BT_LOGV("Event class has no context field type: " @@ -350,7 +350,7 @@ static inline struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_payload_field_type( struct bt_ctf_event_class_common *event_class) { - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_CTF_ASSERT_PRE_NON_NULL(event_class, "Event class"); return event_class->payload_field_type; } diff --git a/include/babeltrace2/ctf-writer/event-internal.h b/include/babeltrace2/ctf-writer/event-internal.h index d1d3dc9d..97039878 100644 --- a/include/babeltrace2/ctf-writer/event-internal.h +++ b/include/babeltrace2/ctf-writer/event-internal.h @@ -29,7 +29,7 @@ */ #include -#include +#include #include #include #include @@ -74,8 +74,8 @@ void _bt_ctf_event_common_set_is_frozen(struct bt_ctf_event_common *event, # define bt_ctf_event_common_set_is_frozen(_event, _is_frozen) #endif -#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \ - BT_ASSERT_PRE_HOT((_event), (_name), ": event-addr=%p", (_event)) +#define BT_CTF_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \ + BT_CTF_ASSERT_PRE_HOT((_event), (_name), ": event-addr=%p", (_event)) static inline struct bt_ctf_event_class_common *bt_ctf_event_common_borrow_class( @@ -111,7 +111,7 @@ struct bt_ctf_field_common *bt_ctf_event_common_borrow_payload( { struct bt_ctf_field_common *payload = NULL; - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); if (!event->payload_field) { BT_LOGV("Event has no current payload field: addr=%p, " @@ -133,7 +133,7 @@ struct bt_ctf_field_common *bt_ctf_event_common_borrow_header( { struct bt_ctf_field_common *header = NULL; - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); if (!event->header_field) { BT_LOGV("Event has no current header field: addr=%p, " @@ -155,7 +155,7 @@ struct bt_ctf_field_common *bt_ctf_event_common_borrow_context( { struct bt_ctf_field_common *context = NULL; - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); if (!event->context_field) { BT_LOGV("Event has no current context field: addr=%p, " @@ -177,7 +177,7 @@ struct bt_ctf_field_common *bt_ctf_event_common_borrow_stream_event_context( { struct bt_ctf_field_common *stream_event_context = NULL; - BT_ASSERT_PRE_NON_NULL(event, "Event"); + BT_CTF_ASSERT_PRE_NON_NULL(event, "Event"); if (!event->stream_event_context_field) { BT_LOGV("Event has no current stream event context field: addr=%p, " diff --git a/include/babeltrace2/ctf-writer/field-types-internal.h b/include/babeltrace2/ctf-writer/field-types-internal.h index 9f514772..757170fa 100644 --- a/include/babeltrace2/ctf-writer/field-types-internal.h +++ b/include/babeltrace2/ctf-writer/field-types-internal.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -39,13 +39,13 @@ #include #include -#define BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(_ft, _type_id, _name) \ - BT_ASSERT_PRE(((struct bt_ctf_field_type_common *) (_ft))->id == (_type_id), \ +#define BT_CTF_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(_ft, _type_id, _name) \ + BT_CTF_ASSERT_PRE(((struct bt_ctf_field_type_common *) (_ft))->id == (_type_id), \ _name " has the wrong type ID: expected-type-id=%s, " \ "ft-addr=%p", bt_ctf_field_type_id_string(_type_id), (_ft)) -#define BT_ASSERT_PRE_CTF_FT_HOT(_ft, _name) \ - BT_ASSERT_PRE_HOT((_ft), (_name), ": ft-addr=%p", (_ft)) +#define BT_CTF_ASSERT_PRE_CTF_FT_HOT(_ft, _name) \ + BT_CTF_ASSERT_PRE_HOT((_ft), (_name), ": ft-addr=%p", (_ft)) #define BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \ (&g_array_index(((struct bt_ctf_field_type_common_structure *) (_ft))->fields, \ diff --git a/include/babeltrace2/ctf-writer/fields-internal.h b/include/babeltrace2/ctf-writer/fields-internal.h index 0586fdd7..e9bd3962 100644 --- a/include/babeltrace2/ctf-writer/fields-internal.h +++ b/include/babeltrace2/ctf-writer/fields-internal.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -46,18 +46,18 @@ #include #include -#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name) \ - BT_ASSERT_PRE((_field)->type->id == ((int) (_type_id)), \ +#define BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name) \ + BT_CTF_ASSERT_PRE((_field)->type->id == ((int) (_type_id)), \ _name " has the wrong type ID: expected-type-id=%s, " \ "field-addr=%p", \ bt_ctf_field_type_id_string((int) (_type_id)), (_field)) -#define BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(_field, _name) \ - BT_ASSERT_PRE(bt_ctf_field_common_is_set_recursive(_field), \ +#define BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(_field, _name) \ + BT_CTF_ASSERT_PRE(bt_ctf_field_common_is_set_recursive(_field), \ _name " is not set: field-addr=%p", (_field)) -#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(_field, _name) \ - BT_ASSERT_PRE_HOT((_field), (_name), ": field-addr=%p", (_field)) +#define BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(_field, _name) \ + BT_CTF_ASSERT_PRE_HOT((_field), (_name), ": field-addr=%p", (_field)) struct bt_ctf_field_common; @@ -297,7 +297,7 @@ int _bt_ctf_field_common_validate_recursive(struct bt_ctf_field_common *field) int ret = 0; if (!field) { - BT_ASSERT_PRE_MSG("%s", "Invalid field: field is NULL."); + BT_CTF_ASSERT_PRE_MSG("%s", "Invalid field: field is NULL."); ret = -1; goto end; } @@ -363,7 +363,7 @@ struct bt_ctf_field_type_common *bt_ctf_field_common_borrow_type( { struct bt_ctf_field_type_common *ret = NULL; - BT_ASSERT_PRE_NON_NULL(field, "Field"); + BT_CTF_ASSERT_PRE_NON_NULL(field, "Field"); ret = field->type; return ret; } @@ -373,8 +373,8 @@ int64_t bt_ctf_field_common_sequence_get_length(struct bt_ctf_field_common *fiel { struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Sequence field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Sequence field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE, "Field"); return (int64_t) sequence->length; } @@ -386,11 +386,11 @@ int bt_ctf_field_common_sequence_set_length(struct bt_ctf_field_common *field, int ret = 0; struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Sequence field"); - BT_ASSERT_PRE(((int64_t) length) >= 0, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Sequence field"); + BT_CTF_ASSERT_PRE(((int64_t) length) >= 0, "Invalid sequence length (too large): length=%" PRId64, length); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Sequence field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Sequence field"); if (unlikely(length > sequence->elements->len)) { /* Make more room */ @@ -432,9 +432,9 @@ struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_name( size_t index; GHashTable *field_name_to_index; - BT_ASSERT_PRE_NON_NULL(field, "Structure field"); - BT_ASSERT_PRE_NON_NULL(name, "Field name"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Structure field"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Field name"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field"); structure_ft = BT_CTF_FROM_COMMON(field->type); field_name_to_index = structure_ft->field_name_to_index; @@ -461,10 +461,10 @@ struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_index( { struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Structure field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Structure field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRUCT, "Field"); - BT_ASSERT_PRE(index < structure->fields->len, + BT_CTF_ASSERT_PRE(index < structure->fields->len, "Index is out of bound: struct-field-addr=%p, " "index=%" PRIu64 ", count=%u", field, index, structure->fields->len); @@ -477,10 +477,10 @@ struct bt_ctf_field_common *bt_ctf_field_common_array_borrow_field( { struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Array field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_ARRAY, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Array field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_ARRAY, "Field"); - BT_ASSERT_PRE(index < array->elements->len, + BT_CTF_ASSERT_PRE(index < array->elements->len, "Index is out of bound: array-field-addr=%p, " "index=%" PRIu64 ", count=%u", field, index, array->elements->len); @@ -493,10 +493,10 @@ struct bt_ctf_field_common *bt_ctf_field_common_sequence_borrow_field( { struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Sequence field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Sequence field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE, "Field"); - BT_ASSERT_PRE(index < sequence->length, + BT_CTF_ASSERT_PRE(index < sequence->length, "Index is out of bound: seq-field-addr=%p, " "index=%" PRIu64 ", count=%u", field, index, sequence->elements->len); @@ -511,8 +511,8 @@ int bt_ctf_field_common_variant_set_tag(struct bt_ctf_field_common *variant_fiel int64_t choice_index; struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field); - BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, + BT_CTF_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field"); /* Find matching index in variant field's type */ @@ -538,10 +538,10 @@ struct bt_ctf_field_common *bt_ctf_field_common_variant_borrow_current_field( { struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field); - BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, + BT_CTF_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field"); - BT_ASSERT_PRE(variant->current_field, + BT_CTF_ASSERT_PRE(variant->current_field, "Variant field has no current field: field-addr=%p", variant_field); return variant->current_field; } @@ -552,10 +552,10 @@ int bt_ctf_field_common_variant_get_tag_signed(struct bt_ctf_field_common *varia { struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field); - BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, + BT_CTF_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field"); - BT_ASSERT_PRE(variant->current_field, + BT_CTF_ASSERT_PRE(variant->current_field, "Variant field has no current field: field-addr=%p", variant_field); *tag = variant->tag_value.i; return 0; @@ -567,10 +567,10 @@ int bt_ctf_field_common_variant_get_tag_unsigned(struct bt_ctf_field_common *var { struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field); - BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, + BT_CTF_ASSERT_PRE_NON_NULL(variant_field, "Variant field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field, BT_CTF_FIELD_TYPE_ID_VARIANT, "Field"); - BT_ASSERT_PRE(variant->current_field, + BT_CTF_ASSERT_PRE(variant->current_field, "Variant field has no current field: field-addr=%p", variant_field); *tag = variant->tag_value.u; return 0; @@ -583,10 +583,10 @@ int bt_ctf_field_common_floating_point_get_value(struct bt_ctf_field_common *fie struct bt_ctf_field_common_floating_point *floating_point = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Floating point number field"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Floating point number field"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_FLOAT, "Field"); *value = floating_point->payload; return 0; @@ -599,9 +599,9 @@ int bt_ctf_field_common_floating_point_set_value(struct bt_ctf_field_common *fie struct bt_ctf_field_common_floating_point *floating_point = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "Floating point number field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Floating point number field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "Floating point number field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Floating point number field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_FLOAT, "Field"); floating_point->payload = value; bt_ctf_field_common_set(field, true); @@ -613,9 +613,9 @@ const char *bt_ctf_field_common_string_get_value(struct bt_ctf_field_common *fie { struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRING, "Field"); return (const char *) string->buf->data; } @@ -625,9 +625,9 @@ int bt_ctf_field_common_string_clear(struct bt_ctf_field_common *field) { struct bt_ctf_field_common_string *string_field = BT_CTF_FROM_COMMON(field); - BT_ASSERT_PRE_NON_NULL(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRING, "Field"); string_field->size = 0; bt_ctf_field_common_set(field, true); @@ -642,14 +642,14 @@ int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field, char *data; size_t new_size; - BT_ASSERT_PRE_NON_NULL(field, "String field"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "String field"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRING, "Field"); /* Make sure no null bytes are appended */ - BT_ASSERT_PRE(memchr(value, '\0', length) == NULL, + BT_CTF_ASSERT_PRE(memchr(value, '\0', length) == NULL, "String value to append contains a null character: " "partial-value=\"%.32s\", length=%u", value, length); @@ -671,7 +671,7 @@ static inline int bt_ctf_field_common_string_append(struct bt_ctf_field_common *field, const char *value) { - BT_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); return bt_ctf_field_common_string_append_len(field, value, strlen(value)); } @@ -680,10 +680,10 @@ static inline int bt_ctf_field_common_string_set_value(struct bt_ctf_field_common *field, const char *value) { - BT_ASSERT_PRE_NON_NULL(field, "String field"); - BT_ASSERT_PRE_NON_NULL(value, "Value"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); - BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, + BT_CTF_ASSERT_PRE_NON_NULL(field, "String field"); + BT_CTF_ASSERT_PRE_NON_NULL(value, "Value"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field"); + BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_STRING, "Field"); bt_ctf_field_common_string_clear(field); return bt_ctf_field_common_string_append_len(field, @@ -784,7 +784,7 @@ void bt_ctf_field_common_string_finalize(struct bt_ctf_field_common *field) } } -BT_ASSERT_PRE_FUNC +BT_CTF_ASSERT_PRE_FUNC static inline bool value_is_in_range_signed(unsigned int size, int64_t value) { bool ret = true; @@ -802,7 +802,7 @@ static inline bool value_is_in_range_signed(unsigned int size, int64_t value) return ret; } -BT_ASSERT_PRE_FUNC +BT_CTF_ASSERT_PRE_FUNC static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value) { bool ret = true; diff --git a/include/babeltrace2/ctf-writer/stream-class-internal.h b/include/babeltrace2/ctf-writer/stream-class-internal.h index 20982535..0b7fd47d 100644 --- a/include/babeltrace2/ctf-writer/stream-class-internal.h +++ b/include/babeltrace2/ctf-writer/stream-class-internal.h @@ -101,7 +101,7 @@ static inline const char *bt_ctf_stream_class_common_get_name( struct bt_ctf_stream_class_common *stream_class) { - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); return stream_class->name->len > 0 ? stream_class->name->str : NULL; } @@ -111,7 +111,7 @@ int64_t bt_ctf_stream_class_common_get_id( { int64_t ret; - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); if (!stream_class->id_set) { BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"", @@ -289,8 +289,8 @@ static inline struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_by_index( struct bt_ctf_stream_class_common *stream_class, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - BT_ASSERT_PRE(index < stream_class->event_classes->len, + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE(index < stream_class->event_classes->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u", index, stream_class->event_classes->len); @@ -303,8 +303,8 @@ struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_ { int64_t id_key = (int64_t) id; - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - BT_ASSERT_PRE(id_key >= 0, + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE(id_key >= 0, "Invalid event class ID: %" PRIu64, id); return g_hash_table_lookup(stream_class->event_classes_ht, &id_key); @@ -315,7 +315,7 @@ struct bt_ctf_field_type_common * bt_ctf_stream_class_common_borrow_packet_context_field_type( struct bt_ctf_stream_class_common *stream_class) { - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); return stream_class->packet_context_field_type; } @@ -378,7 +378,7 @@ bt_ctf_stream_class_common_borrow_event_header_field_type( { struct bt_ctf_field_type_common *ret = NULL; - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); if (!stream_class->event_header_field_type) { BT_LOGV("Stream class has no event header field type: " @@ -454,7 +454,7 @@ bt_ctf_stream_class_common_borrow_event_context_field_type( { struct bt_ctf_field_type_common *ret = NULL; - BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); + BT_CTF_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); if (!stream_class->event_context_field_type) { goto end; diff --git a/include/babeltrace2/ctf-writer/stream-internal.h b/include/babeltrace2/ctf-writer/stream-internal.h index 456a6f4d..c7eb9fae 100644 --- a/include/babeltrace2/ctf-writer/stream-internal.h +++ b/include/babeltrace2/ctf-writer/stream-internal.h @@ -29,7 +29,7 @@ */ #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ struct bt_ctf_stream_class_common *bt_ctf_stream_common_borrow_class( static inline const char *bt_ctf_stream_common_get_name(struct bt_ctf_stream_common *stream) { - BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream"); return stream->name ? stream->name->str : NULL; } @@ -76,7 +76,7 @@ int64_t bt_ctf_stream_common_get_id(struct bt_ctf_stream_common *stream) { int64_t ret; - BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + BT_CTF_ASSERT_PRE_NON_NULL(stream, "Stream"); ret = stream->id; if (ret < 0) { BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"", diff --git a/include/babeltrace2/ctf-writer/trace-internal.h b/include/babeltrace2/ctf-writer/trace-internal.h index ff313cf4..4d3e4d1a 100644 --- a/include/babeltrace2/ctf-writer/trace-internal.h +++ b/include/babeltrace2/ctf-writer/trace-internal.h @@ -28,7 +28,7 @@ * http://www.efficios.com/ctf */ -#include +#include #include #include #include @@ -79,7 +79,7 @@ void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace); static inline const char *bt_ctf_trace_common_get_name(struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return trace->name ? trace->name->str : NULL; } @@ -89,7 +89,7 @@ int bt_ctf_trace_common_set_name(struct bt_ctf_trace_common *trace, const char * static inline const unsigned char *bt_ctf_trace_common_get_uuid(struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return trace->uuid_set ? trace->uuid : NULL; } @@ -114,7 +114,7 @@ int64_t bt_ctf_trace_common_get_environment_field_count( { int64_t ret; - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); ret = bt_ctf_attributes_get_count(trace->environment); BT_ASSERT(ret >= 0); return ret; @@ -125,7 +125,7 @@ const char * bt_ctf_trace_common_get_environment_field_name_by_index( struct bt_ctf_trace_common *trace, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return bt_ctf_attributes_get_field_name(trace->environment, index); } @@ -134,7 +134,7 @@ struct bt_ctf_private_value * bt_ctf_trace_common_borrow_environment_field_value_by_index( struct bt_ctf_trace_common *trace, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return bt_ctf_attributes_borrow_field_value(trace->environment, index); } @@ -143,8 +143,8 @@ struct bt_ctf_private_value * bt_ctf_trace_common_borrow_environment_field_value_by_name( struct bt_ctf_trace_common *trace, const char *name) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); return bt_ctf_attributes_borrow_field_value_by_name(trace->environment, name); } @@ -156,7 +156,7 @@ int bt_ctf_trace_common_add_clock_class(struct bt_ctf_trace_common *trace, static inline int64_t bt_ctf_trace_common_get_clock_class_count(struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return trace->clock_classes->len; } @@ -164,8 +164,8 @@ static inline struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_index( struct bt_ctf_trace_common *trace, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE(index < trace->clock_classes->len, + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE(index < trace->clock_classes->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u", index, trace->clock_classes->len); @@ -175,7 +175,7 @@ struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_index( static inline int64_t bt_ctf_trace_common_get_stream_count(struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return (int64_t) trace->streams->len; } @@ -184,8 +184,8 @@ struct bt_ctf_stream_common *bt_ctf_trace_common_borrow_stream_by_index( struct bt_ctf_trace_common *trace, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE(index < trace->streams->len, + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE(index < trace->streams->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u", index, trace->streams->len); @@ -195,7 +195,7 @@ struct bt_ctf_stream_common *bt_ctf_trace_common_borrow_stream_by_index( static inline int64_t bt_ctf_trace_common_get_stream_class_count(struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return (int64_t) trace->stream_classes->len; } @@ -203,8 +203,8 @@ static inline struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_index( struct bt_ctf_trace_common *trace, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE(index < trace->stream_classes->len, + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE(index < trace->stream_classes->len, "Index is out of bounds: index=%" PRIu64 ", " "count=%u", index, trace->stream_classes->len); @@ -219,8 +219,8 @@ struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_id struct bt_ctf_stream_class_common *stream_class = NULL; int64_t id = (int64_t) id_param; - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE(id >= 0, + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE(id >= 0, "Invalid stream class ID: %" PRIu64, id_param); for (i = 0; i < trace->stream_classes->len; i++) { @@ -247,8 +247,8 @@ struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_name( size_t i; struct bt_ctf_clock_class *clock_class = NULL; - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); - BT_ASSERT_PRE_NON_NULL(name, "Name"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(name, "Name"); for (i = 0; i < trace->clock_classes->len; i++) { struct bt_ctf_clock_class *cur_clk = @@ -273,7 +273,7 @@ static inline enum bt_ctf_byte_order bt_ctf_trace_common_get_native_byte_order( struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return trace->native_byte_order; } @@ -285,7 +285,7 @@ static inline struct bt_ctf_field_type_common *bt_ctf_trace_common_borrow_packet_header_field_type( struct bt_ctf_trace_common *trace) { - BT_ASSERT_PRE_NON_NULL(trace, "Trace"); + BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace"); return trace->packet_header_field_type; } diff --git a/lib/Makefile.am b/lib/Makefile.am index fe6b88b0..39b956a9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ -SUBDIRS = trace-ir ctf-writer prio_heap plugin graph . +SUBDIRS = trace-ir prio_heap plugin graph -lib_LTLIBRARIES = libbabeltrace2.la libbabeltrace2-ctf.la +lib_LTLIBRARIES = libbabeltrace2.la libbabeltrace2_la_SOURCES = \ babeltrace2.c \ @@ -17,32 +17,10 @@ libbabeltrace2_la_LIBADD = \ graph/libgraph.la \ plugin/libplugin.la \ trace-ir/libtrace-ir.la \ - ctf-writer/libctf-writer.la \ $(top_builddir)/logging/libbabeltrace2-logging.la \ $(top_builddir)/common/libbabeltrace2-common.la \ - $(top_builddir)/ctfser/libbabeltrace2-ctfser.la \ $(top_builddir)/compat/libcompat.la if ENABLE_BUILT_IN_PYTHON_PLUGIN_SUPPORT libbabeltrace2_la_LIBADD += $(top_builddir)/python-plugin-provider/libbabeltrace2-python-plugin-provider.la endif - -# FIXME: Should we drop this? We changed the basename of the library, -# libbabeltrace2 is not a drop-in replacement for libbabeltrace anymore. -# -# Build a libbabeltrace2-ctf library for backwards compatibility. -# CTF writer used to be in libbabeltrace2-ctf in Babeltrace 1, so this -# file must still exist. As of Babeltrace 2, CTF writer is implemented -# in libbabeltrace2. -libbabeltrace2_ctf_la_SOURCES = $(libbabeltrace2_la_SOURCES) -libbabeltrace2_ctf_la_LDFLAGS = $(LT_NO_UNDEFINED) \ - -version-info $(BABELTRACE_LIBRARY_VERSION) - -libbabeltrace2_ctf_la_LIBADD = \ - graph/libgraph.la \ - trace-ir/libtrace-ir.la \ - ctf-writer/libctf-writer.la \ - $(top_builddir)/logging/libbabeltrace2-logging.la \ - $(top_builddir)/common/libbabeltrace2-common.la \ - $(top_builddir)/ctfser/libbabeltrace2-ctfser.la \ - $(top_builddir)/compat/libcompat.la diff --git a/lib/ctf-writer/Makefile.am b/lib/ctf-writer/Makefile.am deleted file mode 100644 index bee4b394..00000000 --- a/lib/ctf-writer/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -noinst_LTLIBRARIES = libctf-writer.la - -libctf_writer_la_SOURCES = \ - attributes.c \ - clock.c \ - clock-class.c \ - event.c \ - event-class.c \ - field-path.c \ - fields.c \ - field-types.c \ - field-wrapper.c \ - functor.c \ - object.c \ - object-pool.c \ - resolve.c \ - stream.c \ - stream-class.c \ - trace.c \ - utils.c \ - validation.c \ - values.c \ - visitor.c \ - writer.c - -libctf_writer_la_LIBADD = $(UUID_LIBS) diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 4ef581b2..9cb75b00 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -7,21 +7,23 @@ LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la libtestcommon_la_SOURCES = common.c common.h noinst_LTLIBRARIES = libtestcommon.la -# -Wl,--no-as-needed is needed for recent gold linker who seems to think -# it knows better and considers libraries with constructors having -# side-effects as dead code. -COMMON_TEST_LDADD = $(LIBTAP) $(builddir)/libtestcommon.la \ - $(top_builddir)/lib/libbabeltrace2.la +COMMON_TEST_LDADD = $(LIBTAP) $(builddir)/libtestcommon.la test_bitfield_LDADD = $(LIBTAP) $(builddir)/libtestcommon.la -test_ctf_writer_LDADD = $(COMMON_TEST_LDADD) +test_ctf_writer_LDADD = \ + $(COMMON_TEST_LDADD) \ + $(top_builddir)/ctf-writer/libbabeltrace2-ctf-writer.la -test_bt_values_LDADD = $(COMMON_TEST_LDADD) +test_bt_values_LDADD = $(COMMON_TEST_LDADD) \ + $(top_builddir)/lib/libbabeltrace2.la -test_trace_ir_ref_LDADD = $(COMMON_TEST_LDADD) +test_trace_ir_ref_LDADD = $(COMMON_TEST_LDADD) \ + $(top_builddir)/lib/libbabeltrace2.la \ + $(top_builddir)/ctf-writer/libbabeltrace2-ctf-writer.la -test_graph_topo_LDADD = $(COMMON_TEST_LDADD) +test_graph_topo_LDADD = $(COMMON_TEST_LDADD) \ + $(top_builddir)/lib/libbabeltrace2.la noinst_PROGRAMS = test_bitfield test_ctf_writer test_bt_values \ test_trace_ir_ref test_graph_topo @@ -34,7 +36,8 @@ test_graph_topo_SOURCES = test_graph_topo.c if !ENABLE_BUILT_IN_PLUGINS noinst_PROGRAMS += test_plugin -test_plugin_LDADD = $(COMMON_TEST_LDADD) +test_plugin_LDADD = $(COMMON_TEST_LDADD) \ + $(top_builddir)/lib/libbabeltrace2.la test_plugin_SOURCES = test_plugin.c SUBDIRS += test-plugin-plugins endif diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index f4837c90..99a1d374 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -24,6 +24,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" #define NR_TESTS 37 -- 2.34.1