/tests/ctf-writer/ctf_writer
/tests/lib/plugin
/tests/lib/test_bitfield
+/tests/lib/test_bt_uuid
/tests/lib/test_bt_values
/tests/lib/test_graph_topo
/tests/lib/test_trace_ir_ref
glib 2.22 or better development libraries
(Debian : libglib2.0-0, libglib2.0-dev)
(Fedora : glib2, glib2-devel)
- uuid development libraries
- (Debian : uuid-dev)
- (Fedora : uuid-devel)
libpopt >= 1.13 development libraries
(Debian : libpopt-dev)
(Fedora : popt)
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
-# First, check for uuid in system libs
-AH_TEMPLATE([BABELTRACE_HAVE_LIBUUID], [Define if you have libuuid support])
-AC_CHECK_FUNCS([uuid_generate],
- [
- AC_DEFINE([BABELTRACE_HAVE_LIBUUID], [1])
- UUID_LIBS=""
- ],
- [
- # Then, check if the pkg-config module is available, otherwise explicitly check
- # for libuuid, or uuid support in the C-library.
- PKG_CHECK_MODULES([UUID], [uuid],
- [
- AC_DEFINE([BABELTRACE_HAVE_LIBUUID], [1])
- dnl PKG_CHECK_MODULES defines UUID_LIBS
- ],
- [
- AC_MSG_WARN([pkg-config was unable to find a valid .pc for libuuid. Set PKG_CONFIG_PATH to specify the pkgconfig configuration file location])
- AC_MSG_WARN([Finding libuuid without pkg-config.])
- AC_CHECK_LIB([uuid], [uuid_generate],
- [
- AC_DEFINE([BABELTRACE_HAVE_LIBUUID], [1])
- UUID_LIBS="-luuid"
- ],
- [
- # libuuid not found, check for uuid_create in libc.
- AC_CHECK_LIB([c], [uuid_create],
- [
- AC_DEFINE([BABELTRACE_HAVE_LIBUUID], [1])
- UUID_LIBS="-lc"
- ],
- [
- # for MinGW32 we have our own internal implementation of uuid using Windows functions.
- AS_IF([test "x$MINGW32" = xno],
- [AC_MSG_FAILURE([Cannot find libuuid uuid_generate nor libc uuid_create. Either set PKG_CONFIG_PATH to the configuration file location or use LDFLAGS=-Ldir to specify the library location])]
- )
- ]
- )
- ]
- )
- ]
- )
- ]
-)
-AC_SUBST(UUID_LIBS)
-
# Check for fmemopen
AC_CHECK_LIB([c], [fmemopen],
[AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FMEMOPEN], 1, [Has fmemopen support.])]
extern int bt_ctf_clock_class_set_is_absolute(
struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
-extern const unsigned char *bt_ctf_clock_class_get_uuid(
+extern const uint8_t *bt_ctf_clock_class_get_uuid(
struct bt_ctf_clock_class *clock_class);
extern int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
- const unsigned char *uuid);
+ const uint8_t *uuid);
#ifdef __cplusplus
}
#endif
* Returns a pointer to the clock's UUID (16 byte array) on success,
* NULL on error.
*/
-extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock);
+extern const uint8_t *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock);
/*
* bt_ctf_clock_set_uuid: set a clock's UUID.
* Returns 0 on success, a negative value on error.
*/
extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock,
- const unsigned char *uuid);
+ const uint8_t *uuid);
/*
* bt_ctf_clock_set_time: set a clock's current time value.
extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace,
enum bt_ctf_byte_order native_byte_order);
-extern const unsigned char *bt_ctf_trace_get_uuid(
+extern const uint8_t *bt_ctf_trace_get_uuid(
struct bt_ctf_trace *trace);
extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
- const unsigned char *uuid);
+ const uint8_t *uuid);
extern int bt_ctf_trace_set_environment_field_integer(
struct bt_ctf_trace *trace, const char *name,
Description: Common Trace Format (CTF) writer library from Babeltrace 2
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lbabeltrace2-ctf-writer
-Libs.private: @UUID_LIBS@
Cflags: -I${includedir}
-Cflags.private: @UUID_CFLAGS@
Description: Babeltrace 2 library to support plugins and create trace processing graphs
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lbabeltrace2
-Libs.private: @UUID_LIBS@
Cflags: -I${includedir}
-Cflags.private: @UUID_CFLAGS@
noinst_LTLIBRARIES = libbabeltrace2-common.la
libbabeltrace2_common_la_SOURCES = \
- assert.h \
assert.c \
+ assert.h \
common.c \
- common.h
+ common.h \
+ uuid.c \
+ uuid.h
noinst_HEADERS = \
align.h \
--- /dev/null
+/*
+ * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "common/assert.h"
+#include "common/uuid.h"
+
+
+/*
+ * Generate a random UUID according to RFC4122, section 4.4.
+ */
+BT_HIDDEN
+void bt_uuid_generate(bt_uuid_t uuid_out)
+{
+ int i;
+ GRand *rand;
+
+ BT_ASSERT(uuid_out);
+
+ rand = g_rand_new();
+
+ /*
+ * Generate 16 bytes of random bits.
+ */
+ for (i = 0; i < BT_UUID_LEN; i++) {
+ uuid_out[i] = (uint8_t) g_rand_int(rand);
+ }
+
+ /*
+ * Set the two most significant bits (bits 6 and 7) of the
+ * clock_seq_hi_and_reserved to zero and one, respectively.
+ */
+ uuid_out[8] &= ~(1 << 6);
+ uuid_out[8] |= (1 << 7);
+
+ /*
+ * Set the four most significant bits (bits 12 through 15) of the
+ * time_hi_and_version field to the 4-bit version number from
+ * Section 4.1.3.
+ */
+ uuid_out[6] &= 0x0f;
+ uuid_out[6] |= (BT_UUID_VER << 4);
+
+ g_rand_free(rand);
+}
+
+BT_HIDDEN
+void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out)
+{
+ BT_ASSERT(uuid_in);
+ BT_ASSERT(str_out);
+
+ sprintf(str_out, BT_UUID_FMT, BT_UUID_FMT_VALUES(uuid_in));
+}
+
+BT_HIDDEN
+int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out)
+{
+ int ret = 0;
+ bt_uuid_t uuid_scan;
+
+ BT_ASSERT(uuid_out);
+ BT_ASSERT(str_in);
+
+ if (strnlen(str_in, BT_UUID_STR_LEN + 1) != BT_UUID_STR_LEN) {
+ ret = -1;
+ goto end;
+ }
+
+ /* Scan to a temporary location in case of a partial match. */
+ if (sscanf(str_in, BT_UUID_FMT, BT_UUID_SCAN_VALUES(uuid_scan)) != BT_UUID_LEN) {
+ ret = -1;
+ }
+
+ bt_uuid_copy(uuid_out, uuid_scan);
+end:
+ return ret;
+}
+
+BT_HIDDEN
+int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b)
+{
+ int ret = 0;
+
+ if (memcmp(uuid_a, uuid_b, BT_UUID_LEN) != 0) {
+ ret = -1;
+ }
+
+ return ret;
+}
+
+BT_HIDDEN
+void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src)
+{
+ BT_ASSERT(uuid_dest);
+ BT_ASSERT(uuid_src);
+ BT_ASSERT(uuid_dest != uuid_src);
+
+ memcpy(uuid_dest, uuid_src, BT_UUID_LEN);
+}
--- /dev/null
+#ifndef _BABELTRACE_COMMON_UUID_H
+#define _BABELTRACE_COMMON_UUID_H
+
+/*
+ * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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.
+ */
+
+#include <stdint.h>
+#include "common/macros.h"
+
+#define BT_UUID_STR_LEN 36 /* Excludes final \0 */
+#define BT_UUID_LEN 16
+#define BT_UUID_VER 4
+
+#define BT_UUID_FMT \
+ "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
+ "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
+ "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
+ "%02" SCNx8
+
+#define BT_UUID_FMT_VALUES(uuid) \
+ (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
+ (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
+ (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
+
+#define BT_UUID_SCAN_VALUES(uuid) \
+ &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
+ &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
+ &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
+
+typedef uint8_t bt_uuid_t[BT_UUID_LEN];
+
+BT_HIDDEN void bt_uuid_generate(bt_uuid_t uuid_out);
+BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out);
+BT_HIDDEN int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out);
+BT_HIDDEN int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b);
+BT_HIDDEN void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src);
+
+#endif /* _BABELTRACE_COMMON_UUID_H */
libcompat_la_SOURCES = \
mman.c \
- mman.h \
- uuid.c \
- uuid.h
+ mman.h
libcompat_la_LDFLAGS = \
$(LD_NO_AS_NEEDED)
-if BABELTRACE_BUILD_WITH_MINGW
-libcompat_la_LDFLAGS += -lrpcrt4
-endif
-
noinst_HEADERS = \
bitfield.h \
compiler.h \
+++ /dev/null
-/*
- * compat/compat_uuid.h
- *
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- */
-
-#ifdef __APPLE__
-#include "common/macros.h"
-
-/*
- * On macOS, we need a dummy symbol so that the linker won't
- * complain of an empty table of contents.
- */
-BT_HIDDEN
-int bt_uuid_dummy_symbol;
-#endif /* __APPLE__ */
-
-#ifdef __MINGW32__
-
-#include <rpc.h>
-#include <stdlib.h>
-#include "compat/uuid.h"
-
-/* MinGW does not provide byteswap - implement our own version. */
-static
-void swap(unsigned char *ptr, unsigned int i, unsigned int j)
-{
- unsigned char tmp;
-
- tmp = ptr[i];
- ptr[i] = ptr[j];
- ptr[j] = tmp;
-}
-
-static
-void fix_uuid_endian(unsigned char * ptr)
-{
- swap(ptr, 0, 3);
- swap(ptr, 1, 2);
- swap(ptr, 4, 5);
- swap(ptr, 6, 7);
-}
-
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- RPC_STATUS status;
-
- status = UuidCreate((UUID *) uuid_out);
- if (status == RPC_S_OK)
- return 0;
- else
- return -1;
-}
-
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- RPC_STATUS status;
- unsigned char *alloc_str;
- int ret;
- unsigned char copy_of_uuid_in[BABELTRACE_UUID_LEN];
-
- /* make a modifyable copy of uuid_in */
- memcpy(copy_of_uuid_in, uuid_in, BABELTRACE_UUID_LEN);
-
- fix_uuid_endian(copy_of_uuid_in);
- status = UuidToString((UUID *) copy_of_uuid_in, &alloc_str);
-
- if (status == RPC_S_OK) {
- strncpy(str_out, (char *) alloc_str, BABELTRACE_UUID_STR_LEN);
- str_out[BABELTRACE_UUID_STR_LEN - 1] = '\0';
- ret = 0;
- } else {
- ret = -1;
- }
- RpcStringFree(&alloc_str);
- return ret;
-}
-
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- RPC_STATUS status;
-
- status = UuidFromString((unsigned char *) str_in,
- (UUID *) uuid_out);
- fix_uuid_endian(uuid_out);
-
- if (status == RPC_S_OK)
- return 0;
- else
- return -1;
-}
-
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- RPC_STATUS status;
-
- return !UuidCompare((UUID *) uuid_a, (UUID *) uuid_b, &status) ? 0 : -1;
-}
-
-#endif
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_UUID_H
-#define _BABELTRACE_COMPAT_UUID_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- */
-
-/* Includes final \0. */
-#define BABELTRACE_UUID_STR_LEN 37
-#define BABELTRACE_UUID_LEN 16
-
-#ifdef BABELTRACE_HAVE_LIBUUID
-#include <uuid/uuid.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uuid_generate(uuid_out);
- return 0;
-}
-
-/* Sun's libuuid lacks const qualifiers */
-#if defined(__sun__)
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse((unsigned char *) uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse((char *) str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare((unsigned char *) uuid_a,
- (unsigned char *) uuid_b);
-}
-#else
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse(uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse(str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare(uuid_a, uuid_b);
-}
-#endif
-
-#elif defined(BABELTRACE_HAVE_LIBC_UUID)
-#include <uuid.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_create((uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uint32_t status;
- char *alloc_str;
- int ret;
-
- uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
- if (status == uuid_s_ok) {
- strcpy(str_out, alloc_str);
- ret = 0;
- } else {
- ret = -1;
- }
- free(alloc_str);
- return ret;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- uint32_t status;
-
- uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-#elif defined(__MINGW32__)
-
-int bt_uuid_generate(unsigned char *uuid_out);
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out);
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out);
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b);
-
-#else
-#error "Babeltrace needs to have a UUID generator configured."
-#endif
-
-#endif /* _BABELTRACE_COMPAT_UUID_H */
$(top_builddir)/src/logging/libbabeltrace2-logging.la \
$(top_builddir)/src/common/libbabeltrace2-common.la \
$(top_builddir)/src/ctfser/libbabeltrace2-ctfser.la \
- $(top_builddir)/src/compat/libcompat.la \
- $(UUID_LIBS)
+ $(top_builddir)/src/compat/libcompat.la
#define BT_LOG_TAG "CTF-WRITER/CLOCK-CLASS"
#include "logging.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/ctf-writer/utils.h>
#include <babeltrace2/ctf-writer/object.h>
#include "compat/compiler.h"
}
BT_HIDDEN
-const unsigned char *bt_ctf_clock_class_get_uuid(
+const uint8_t *bt_ctf_clock_class_get_uuid(
struct bt_ctf_clock_class *clock_class)
{
- const unsigned char *ret;
+ const uint8_t *ret;
if (!clock_class) {
BT_LOGW_STR("Invalid parameter: clock class is NULL.");
BT_HIDDEN
int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
- const unsigned char *uuid)
+ const uint8_t *uuid)
{
int ret = 0;
goto end;
}
- memcpy(clock_class->uuid, uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(clock_class->uuid, uuid);
clock_class->uuid_set = 1;
- BT_LOGT("Set clock class's UUID: addr=%p, name=\"%s\", "
- "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
+ BT_LOGT("Set clock class's UUID: addr=%p, name=\"%s\", uuid=\"" BT_UUID_FMT "\"",
clock_class, bt_ctf_clock_class_get_name(clock_class),
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15]);
+ BT_UUID_FMT_VALUES(uuid));
end:
return ret;
}
goto end;
}
- if (memcmp(clock_class_a->uuid, clock_class_b->uuid,
- BABELTRACE_UUID_LEN) != 0) {
+ if (bt_uuid_compare(clock_class_a->uuid, clock_class_b->uuid) != 0) {
BT_LOGT("Clock classes differ: different UUIDs: "
- "cc-a-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
- "cc-b-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
- (unsigned int) clock_class_a->uuid[0],
- (unsigned int) clock_class_a->uuid[1],
- (unsigned int) clock_class_a->uuid[2],
- (unsigned int) clock_class_a->uuid[3],
- (unsigned int) clock_class_a->uuid[4],
- (unsigned int) clock_class_a->uuid[5],
- (unsigned int) clock_class_a->uuid[6],
- (unsigned int) clock_class_a->uuid[7],
- (unsigned int) clock_class_a->uuid[8],
- (unsigned int) clock_class_a->uuid[9],
- (unsigned int) clock_class_a->uuid[10],
- (unsigned int) clock_class_a->uuid[11],
- (unsigned int) clock_class_a->uuid[12],
- (unsigned int) clock_class_a->uuid[13],
- (unsigned int) clock_class_a->uuid[14],
- (unsigned int) clock_class_a->uuid[15],
- (unsigned int) clock_class_b->uuid[0],
- (unsigned int) clock_class_b->uuid[1],
- (unsigned int) clock_class_b->uuid[2],
- (unsigned int) clock_class_b->uuid[3],
- (unsigned int) clock_class_b->uuid[4],
- (unsigned int) clock_class_b->uuid[5],
- (unsigned int) clock_class_b->uuid[6],
- (unsigned int) clock_class_b->uuid[7],
- (unsigned int) clock_class_b->uuid[8],
- (unsigned int) clock_class_b->uuid[9],
- (unsigned int) clock_class_b->uuid[10],
- (unsigned int) clock_class_b->uuid[11],
- (unsigned int) clock_class_b->uuid[12],
- (unsigned int) clock_class_b->uuid[13],
- (unsigned int) clock_class_b->uuid[14],
- (unsigned int) clock_class_b->uuid[15]);
+ "cc-a-uuid=\"" BT_UUID_FMT "\", "
+ "cc-b-uuid=\"" BT_UUID_FMT "\"",
+ BT_UUID_FMT_VALUES(clock_class_a->uuid),
+ BT_UUID_FMT_VALUES(clock_class_b->uuid));
goto end;
}
} else {
#include "common/macros.h"
#include "object-pool.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/types.h>
#include <stdbool.h>
#include <stdint.h>
uint64_t precision;
int64_t offset_s; /* Offset in seconds */
int64_t offset; /* Offset in ticks */
- unsigned char uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
int uuid_set;
int absolute;
int bt_ctf_clock_class_set_is_absolute(
struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
BT_HIDDEN
-const unsigned char *bt_ctf_clock_class_get_uuid(
+const uint8_t *bt_ctf_clock_class_get_uuid(
struct bt_ctf_clock_class *clock_class);
BT_HIDDEN
int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
- const unsigned char *uuid);
+ const uint8_t *uuid);
#endif /* BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H */
#include "logging.h"
#include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/compiler.h"
#include <babeltrace2/ctf-writer/utils.h>
#include <babeltrace2/ctf-writer/object.h>
{
int ret;
struct bt_ctf_clock *clock = NULL;
- unsigned char cc_uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t cc_uuid;
BT_CTF_ASSERT_PRE_NON_NULL(name, "Name");
clock = g_new0(struct bt_ctf_clock, 1);
}
/* Automatically set clock class's UUID. */
- ret = bt_uuid_generate(cc_uuid);
- if (ret) {
- goto error;
- }
+ bt_uuid_generate(cc_uuid);
ret = bt_ctf_clock_class_set_uuid(clock->clock_class, cc_uuid);
BT_ASSERT(ret == 0);
is_absolute);
}
-const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock)
+const uint8_t *bt_ctf_clock_get_uuid(struct bt_ctf_clock *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)
+int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock, const uint8_t *uuid)
{
BT_CTF_ASSERT_PRE_NON_NULL(clock, "CTF writer clock");
return bt_ctf_clock_class_set_uuid(clock->clock_class, uuid);
void bt_ctf_clock_class_serialize(struct bt_ctf_clock_class *clock_class,
struct metadata_context *context)
{
- unsigned char *uuid;
+ uint8_t *uuid;
BT_LOGD("Serializing clock class's metadata: clock-class-addr=%p, "
"name=\"%s\", metadata-context-addr=%p", clock_class,
if (clock_class->uuid_set) {
g_string_append_printf(context->string,
- "\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
+ "\tuuid = \"" BT_UUID_FMT "\";\n",
+ BT_UUID_FMT_VALUES(uuid));
}
if (clock_class->description) {
#include <babeltrace2/ctf-writer/clock.h>
#include "common/macros.h"
#include <glib.h>
-#include "compat/uuid.h"
#include "clock-class.h"
#include "object.h"
BT_HIDDEN
int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace,
- const unsigned char *uuid)
+ const uint8_t *uuid)
{
int ret = 0;
goto end;
}
- memcpy(trace->uuid, uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(trace->uuid, uuid);
trace->uuid_set = BT_TRUE;
BT_LOGT("Set trace's UUID: addr=%p, name=\"%s\", "
- "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
+ "uuid=\"" BT_UUID_FMT "\"",
trace, bt_ctf_trace_common_get_name(trace),
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15]);
+ BT_UUID_FMT_VALUES(uuid));
end:
return ret;
return trace;
}
-const unsigned char *bt_ctf_trace_get_uuid(struct bt_ctf_trace *trace)
+const uint8_t *bt_ctf_trace_get_uuid(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_uuid(BT_CTF_TO_COMMON(trace));
}
int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
- const unsigned char *uuid)
+ const uint8_t *uuid)
{
return bt_ctf_trace_common_set_uuid(BT_CTF_TO_COMMON(trace), uuid);
}
int append_trace_metadata(struct bt_ctf_trace *trace,
struct metadata_context *context)
{
- unsigned char *uuid = trace->common.uuid;
+ uint8_t *uuid = trace->common.uuid;
int ret = 0;
if (trace->common.native_byte_order == BT_CTF_BYTE_ORDER_NATIVE ||
if (trace->common.uuid_set) {
g_string_append_printf(context->string,
- "\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
+ "\tuuid = \"" BT_UUID_FMT "\";\n",
+ BT_UUID_FMT_VALUES(uuid));
}
g_string_append_printf(context->string, "\tbyte_order = %s;\n",
*/
#include "common/macros.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/ctf-writer/field-types.h>
#include <babeltrace2/ctf-writer/fields.h>
#include <babeltrace2/ctf-writer/trace.h>
struct bt_ctf_object base;
GString *name;
int frozen;
- unsigned char uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
bt_bool uuid_set;
enum bt_ctf_byte_order native_byte_order;
struct bt_ctf_private_value *environment;
int bt_ctf_trace_common_set_name(struct bt_ctf_trace_common *trace, const char *name);
static inline
-const unsigned char *bt_ctf_trace_common_get_uuid(struct bt_ctf_trace_common *trace)
+const uint8_t *bt_ctf_trace_common_get_uuid(struct bt_ctf_trace_common *trace)
{
BT_CTF_ASSERT_PRE_NON_NULL(trace, "Trace");
return trace->uuid_set ? trace->uuid : NULL;
}
BT_HIDDEN
-int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace, const unsigned char *uuid);
+int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace, const uint8_t *uuid);
BT_HIDDEN
int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
#include "common/assert.h"
#include "compat/compiler.h"
#include "compat/endian.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "clock.h"
#include "fields.h"
{
int ret;
struct bt_ctf_writer *writer = NULL;
- unsigned char uuid[16];
+ bt_uuid_t uuid;
char *metadata_path = NULL;
if (!path) {
}
/* Generate a UUID for this writer's trace */
- ret = bt_uuid_generate(uuid);
- if (ret) {
- BT_LOGE_STR("Cannot generate UUID for CTF writer's trace.");
- goto error_destroy;
- }
+ bt_uuid_generate(uuid);
ret = bt_ctf_trace_set_uuid(writer->trace, uuid);
if (ret) {
iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_UNIX;
} else if (clock_class_uuid) {
iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_UUID;
- memcpy(iterator->clock_expectation.uuid, clock_class_uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(iterator->clock_expectation.uuid, clock_class_uuid);
} else {
iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID;
}
#include <babeltrace2/types.h>
#include "common/assert.h"
#include <stdbool.h>
-#include <compat/uuid.h>
+#include "common/uuid.h"
struct bt_port;
struct bt_graph;
* irrelevant (as the clock will be correlatable with other
* clocks having the same origin).
*/
- uint8_t uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
} clock_expectation;
/*
#include <wchar.h>
#include <glib.h>
#include "common/common.h"
+#include "common/uuid.h"
#include <babeltrace2/trace-ir/event-const.h>
#include <babeltrace2/trace-ir/packet-const.h>
#include <babeltrace2/trace-ir/stream-const.h>
static inline void format_uuid(char **buf_ch, bt_uuid uuid)
{
- BUF_APPEND("\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15]);
+ BUF_APPEND("\"" BT_UUID_FMT "\"", BT_UUID_FMT_VALUES(uuid));
}
static inline void format_object_pool(char **buf_ch, bool extended,
trace.h \
utils.c \
utils.h
-
-libtrace_ir_la_LIBADD = $(UUID_LIBS)
#include "lib/logging.h"
#include "lib/assert-pre.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/trace-ir/clock-class-const.h>
#include <babeltrace2/trace-ir/clock-class.h>
#include "clock-class.h"
BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
BT_ASSERT_PRE_NON_NULL(uuid, "UUID");
BT_ASSERT_PRE_CLOCK_CLASS_HOT(clock_class);
- memcpy(clock_class->uuid.uuid, uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(clock_class->uuid.uuid, uuid);
clock_class->uuid.value = clock_class->uuid.uuid;
BT_LIB_LOGD("Set clock class's UUID: %!+K", clock_class);
}
#include "common/macros.h"
#include "common/common.h"
#include "lib/object-pool.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/types.h>
#include "lib/property.h"
#include "common/assert.h"
uint64_t offset_cycles;
struct {
- uint8_t uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
/* NULL or `uuid` above */
bt_uuid value;
#include "lib/logging.h"
#include "lib/assert-pre.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "clock-class.h"
#include "clock-snapshot.h"
#include <babeltrace2/trace-ir/clock-snapshot-const.h>
#include <babeltrace2/types.h>
#include <glib.h>
#include <sys/types.h>
-#include "compat/uuid.h"
#include "stream-class.h"
#include "attributes.h"
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(uuid, "UUID");
BT_ASSERT_PRE_TRACE_HOT(trace);
- memcpy(trace->uuid.uuid, uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(trace->uuid.uuid, uuid);
trace->uuid.value = trace->uuid.uuid;
BT_LIB_LOGD("Set trace's UUID: %!+t", trace);
}
#include <babeltrace2/types.h>
#include <glib.h>
#include <sys/types.h>
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "attributes.h"
#include "clock-class.h"
} name;
struct {
- uint8_t uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
/* NULL or `uuid` above */
bt_uuid value;
ctf-meta-configure-ir-trace.c \
ctf-meta-configure-ir-trace.h
-libctf_ast_la_LIBADD = $(UUID_LIBS)
-
if BABELTRACE_BUILD_WITH_MINGW
-libctf_ast_la_LIBADD += -lrpcrt4 -lintl -liconv -lole32 $(POPT_LIBS)
+libctf_ast_la_LIBADD = -lintl -liconv -lole32 $(POPT_LIBS)
endif
# start with empty files to clean
#include <babeltrace2/babeltrace.h>
#include "common/common.h"
+#include "common/uuid.h"
#include "common/assert.h"
#include <glib.h>
#include <stdint.h>
uint64_t precision;
int64_t offset_seconds;
uint64_t offset_cycles;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
bool has_uuid;
bool is_absolute;
struct ctf_trace_class {
unsigned int major;
unsigned int minor;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
bool is_uuid_set;
enum ctf_byte_order default_byte_order;
#include <stdlib.h>
#include <inttypes.h>
#include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/memstream.h"
#include <babeltrace2/babeltrace.h>
#include <glib.h>
struct ctf_metadata_decoder {
struct ctf_visitor_generate_ir *visitor;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
bool is_uuid_set;
int bo;
struct ctf_metadata_decoder_config config;
struct packet_header {
uint32_t magic;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
uint32_t checksum;
uint32_t content_size;
uint32_t packet_size;
/* Set expected trace UUID if not set; otherwise validate it */
if (is_uuid_set) {
if (!*is_uuid_set) {
- memcpy(uuid, header.uuid, sizeof(header.uuid));
+ bt_uuid_copy(uuid, header.uuid);
*is_uuid_set = true;
} else if (bt_uuid_compare(header.uuid, uuid)) {
BT_COMP_LOGE("Metadata UUID mismatch between packets of the same stream: "
- "packet-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
- "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
+ "packet-uuid=\"" BT_UUID_FMT "\", "
+ "expected-uuid=\"" BT_UUID_FMT "\", "
"offset=%ld",
- (unsigned int) header.uuid[0],
- (unsigned int) header.uuid[1],
- (unsigned int) header.uuid[2],
- (unsigned int) header.uuid[3],
- (unsigned int) header.uuid[4],
- (unsigned int) header.uuid[5],
- (unsigned int) header.uuid[6],
- (unsigned int) header.uuid[7],
- (unsigned int) header.uuid[8],
- (unsigned int) header.uuid[9],
- (unsigned int) header.uuid[10],
- (unsigned int) header.uuid[11],
- (unsigned int) header.uuid[12],
- (unsigned int) header.uuid[13],
- (unsigned int) header.uuid[14],
- (unsigned int) header.uuid[15],
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15],
+ BT_UUID_FMT_VALUES(header.uuid),
+ BT_UUID_FMT_VALUES(uuid),
offset);
goto error;
}
#include <stdlib.h>
#include <inttypes.h>
#include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/memstream.h"
#include <babeltrace2/babeltrace.h>
#include <glib.h>
struct ctf_metadata_decoder {
struct ctf_visitor_generate_ir *visitor;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
bool is_uuid_set;
int bo;
struct ctf_metadata_decoder_config config;
struct packet_header {
uint32_t magic;
- uint8_t uuid[16];
+ bt_uuid_t uuid;
uint32_t checksum;
uint32_t content_size;
uint32_t packet_size;
#include <inttypes.h>
#include <errno.h>
#include "common/common.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/endian.h"
#include <babeltrace2/babeltrace.h>
static
int get_unary_uuid(struct ctx *ctx, struct bt_list_head *head,
- unsigned char *uuid)
+ uint8_t *uuid)
{
int i = 0;
int ret = 0;
}
src_string = node->u.unary_expression.u.string;
- ret = bt_uuid_parse(src_string, uuid);
+ ret = bt_uuid_from_str(src_string, uuid);
if (ret) {
_BT_COMP_LOGE_NODE(node,
"Cannot parse UUID: uuid=\"%s\"", src_string);
g_free(right);
_SET(set, _CLOCK_NAME_SET);
} else if (!strcmp(left, "uuid")) {
- uint8_t uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
if (_IS_SET(set, _CLOCK_UUID_SET)) {
_BT_COMP_LOGE_DUP_ATTR(entry_node, "uuid", "clock class");
}
clock->has_uuid = true;
- memcpy(&clock->uuid[0], uuid, 16);
+ bt_uuid_copy(clock->uuid, uuid);
_SET(set, _CLOCK_UUID_SET);
} else if (!strcmp(left, "description")) {
char *right;
#include <babeltrace2/babeltrace.h>
#include "common/common.h"
#include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <glib.h>
#include <stdint.h>
#include <string.h>
/* Weak */
const bt_trace_class *ir_tc;
- unsigned char uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t uuid;
/* Array of `struct fs_sink_ctf_stream_class *` (owned by this) */
GPtrArray *stream_classes;
BT_ASSERT(trace);
- if (bt_uuid_generate(trace->uuid)) {
- fs_sink_ctf_trace_destroy(trace);
- trace = NULL;
- goto end;
- }
+ bt_uuid_generate(trace->uuid);
trace->ir_trace = ir_trace;
trace->ir_tc = bt_trace_borrow_class_const(ir_trace);
(GDestroyNotify) fs_sink_ctf_stream_class_destroy);
BT_ASSERT(trace->stream_classes);
-end:
return trace;
}
}
/* Packet header: UUID */
- for (i = 0; i < BABELTRACE_UUID_LEN; i++) {
+ for (i = 0; i < BT_UUID_LEN; i++) {
ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser,
(uint64_t) stream->sc->trace->uuid[i], 8, 8, BYTE_ORDER);
if (ret) {
void append_uuid(struct ctx *ctx, bt_uuid uuid)
{
g_string_append_printf(ctx->tsdl,
- "\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15]);
+ "\"" BT_UUID_FMT "\"",
+ BT_UUID_FMT_VALUES(uuid));
}
static
#include "common/common.h"
#include <babeltrace2/babeltrace.h>
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <glib.h>
#include "common/assert.h"
#include <inttypes.h>
/* For the trace, use the uuid if present, else the path. */
if (ds_file_group->ctf_fs_trace->metadata->tc->is_uuid_set) {
- char uuid_str[BABELTRACE_UUID_STR_LEN];
+ char uuid_str[BT_UUID_STR_LEN + 1];
- bt_uuid_unparse(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
+ bt_uuid_to_str(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
g_string_assign(name, uuid_str);
} else {
g_string_assign(name, ds_file_group->ctf_fs_trace->path->str);
struct ctf_fs_trace *winner;
guint i;
int ret = 0;
- char uuid_str[BABELTRACE_UUID_STR_LEN];
+ char uuid_str[BT_UUID_STR_LEN + 1];
BT_ASSERT(num_traces >= 2);
}
/* Use the string representation of the UUID as the trace name. */
- bt_uuid_unparse(winner->metadata->tc->uuid, uuid_str);
+ bt_uuid_to_str(winner->metadata->tc->uuid, uuid_str);
g_string_printf(winner->name, "%s", uuid_str);
end:
#include <stdbool.h>
#include "common/assert.h"
#include <glib.h>
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include "compat/memstream.h"
#include <babeltrace2/babeltrace.h>
#include "common/assert.h"
#include "common/common.h"
+#include "common/uuid.h"
#include "details.h"
#include "write.h"
#include "obj-lifetime-mgmt.h"
write_indent(ctx);
write_prop_name(ctx, prop_name);
g_string_append_printf(ctx->str,
- ": %s%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%s\n",
+ ": %s" BT_UUID_FMT "%s\n",
color_bold(ctx),
- (unsigned int) uuid[0],
- (unsigned int) uuid[1],
- (unsigned int) uuid[2],
- (unsigned int) uuid[3],
- (unsigned int) uuid[4],
- (unsigned int) uuid[5],
- (unsigned int) uuid[6],
- (unsigned int) uuid[7],
- (unsigned int) uuid[8],
- (unsigned int) uuid[9],
- (unsigned int) uuid[10],
- (unsigned int) uuid[11],
- (unsigned int) uuid[12],
- (unsigned int) uuid[13],
- (unsigned int) uuid[14],
- (unsigned int) uuid[15],
+ BT_UUID_FMT_VALUES(uuid),
color_reset(ctx));
}
#include <babeltrace2/babeltrace.h>
#include "compat/bitfield.h"
#include "common/common.h"
+#include "common/uuid.h"
#include "compat/time.h"
#include "common/assert.h"
#include <inttypes.h>
if (trace_uuid) {
g_string_append_printf(pretty->string,
- "(UUID: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x) ",
- trace_uuid[0],
- trace_uuid[1],
- trace_uuid[2],
- trace_uuid[3],
- trace_uuid[4],
- trace_uuid[5],
- trace_uuid[6],
- trace_uuid[7],
- trace_uuid[8],
- trace_uuid[9],
- trace_uuid[10],
- trace_uuid[11],
- trace_uuid[12],
- trace_uuid[13],
- trace_uuid[14],
- trace_uuid[15]);
+ "(UUID: " BT_UUID_FMT ") ",
+ BT_UUID_FMT_VALUES(trace_uuid));
} else {
g_string_append(pretty->string, "(no UUID) ");
}
#include "plugins/comp-logging.h"
#include "common/macros.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
#include <babeltrace2/babeltrace.h>
#include <glib.h>
#include <stdbool.h>
* clock_class_expectation is
* MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID.
*/
- unsigned char expected_clock_class_uuid[BABELTRACE_UUID_LEN];
+ bt_uuid_t expected_clock_class_uuid;
};
static
const bt_clock_class *clock_class)
{
int ret = 0;
- const unsigned char *cc_uuid;
+ const uint8_t *cc_uuid;
const char *cc_name;
BT_ASSERT(clock_class);
*/
muxer_msg_iter->clock_class_expectation =
MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID;
- memcpy(muxer_msg_iter->expected_clock_class_uuid,
- cc_uuid, BABELTRACE_UUID_LEN);
+ bt_uuid_copy(muxer_msg_iter->expected_clock_class_uuid, cc_uuid);
} else {
/*
* Expect non-absolute clock classes
BT_COMP_LOGE("Expecting a non-absolute clock class with no UUID, "
"but got one with a UUID: "
"clock-class-addr=%p, clock-class-name=\"%s\", "
- "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
- clock_class, cc_name,
- (unsigned int) cc_uuid[0],
- (unsigned int) cc_uuid[1],
- (unsigned int) cc_uuid[2],
- (unsigned int) cc_uuid[3],
- (unsigned int) cc_uuid[4],
- (unsigned int) cc_uuid[5],
- (unsigned int) cc_uuid[6],
- (unsigned int) cc_uuid[7],
- (unsigned int) cc_uuid[8],
- (unsigned int) cc_uuid[9],
- (unsigned int) cc_uuid[10],
- (unsigned int) cc_uuid[11],
- (unsigned int) cc_uuid[12],
- (unsigned int) cc_uuid[13],
- (unsigned int) cc_uuid[14],
- (unsigned int) cc_uuid[15]);
+ "uuid=\"" BT_UUID_FMT "\"",
+ clock_class, cc_name, BT_UUID_FMT_VALUES(cc_uuid));
goto error;
}
break;
goto error;
}
- if (memcmp(muxer_msg_iter->expected_clock_class_uuid,
- cc_uuid, BABELTRACE_UUID_LEN) != 0) {
+ if (bt_uuid_compare(muxer_msg_iter->expected_clock_class_uuid, cc_uuid) != 0) {
BT_COMP_LOGE("Expecting a non-absolute clock class with a specific UUID, "
"but got one with different UUID: "
"clock-class-addr=%p, clock-class-name=\"%s\", "
- "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
- "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
+ "expected-uuid=\"" BT_UUID_FMT "\", "
+ "uuid=\"" BT_UUID_FMT "\"",
clock_class, cc_name,
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[0],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[1],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[2],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[3],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[4],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[5],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[6],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[7],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[8],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[9],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[10],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[11],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[12],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[13],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[14],
- (unsigned int) muxer_msg_iter->expected_clock_class_uuid[15],
- (unsigned int) cc_uuid[0],
- (unsigned int) cc_uuid[1],
- (unsigned int) cc_uuid[2],
- (unsigned int) cc_uuid[3],
- (unsigned int) cc_uuid[4],
- (unsigned int) cc_uuid[5],
- (unsigned int) cc_uuid[6],
- (unsigned int) cc_uuid[7],
- (unsigned int) cc_uuid[8],
- (unsigned int) cc_uuid[9],
- (unsigned int) cc_uuid[10],
- (unsigned int) cc_uuid[11],
- (unsigned int) cc_uuid[12],
- (unsigned int) cc_uuid[13],
- (unsigned int) cc_uuid[14],
- (unsigned int) cc_uuid[15]);
+ BT_UUID_FMT_VALUES(muxer_msg_iter->expected_clock_class_uuid),
+ BT_UUID_FMT_VALUES(cc_uuid));
goto error;
}
break;
TESTS_LIB = \
lib/test_bitfield \
lib/test_bt_values \
+ lib/test_bt_uuid \
lib/test_graph_topo \
lib/test_trace_ir_ref
#include "compat/stdio.h"
#include <string.h>
#include "common/assert.h"
+#include "common/uuid.h"
#include <fcntl.h>
#include "tap/tap.h"
#include <math.h>
/* Return 1 if uuids match, zero if different. */
static
-int uuid_match(const unsigned char *uuid_a, const unsigned char *uuid_b)
+int uuid_match(const uint8_t *uuid_a, const uint8_t *uuid_b)
{
int ret = 0;
int i;
struct bt_ctf_stream *stream1;
struct bt_ctf_stream *stream;
const char *ret_string;
- const unsigned char *ret_uuid;
- unsigned char tmp_uuid[16] = { 0 };
+ const uint8_t *ret_uuid;
+ bt_uuid_t tmp_uuid = { 0 };
struct bt_ctf_field_type *packet_context_type,
*packet_context_field_type,
*packet_header_type,
test_bt_values_LDADD = $(COMMON_TEST_LDADD) \
$(top_builddir)/src/lib/libbabeltrace2.la
+test_bt_uuid_LDADD = $(COMMON_TEST_LDADD) \
+ $(top_builddir)/src/common/libbabeltrace2-common.la \
+ $(top_builddir)/src/logging/libbabeltrace2-logging.la
+
test_trace_ir_ref_LDADD = $(COMMON_TEST_LDADD) \
$(top_builddir)/src/lib/libbabeltrace2.la \
$(top_builddir)/src/ctf-writer/libbabeltrace2-ctf-writer.la
test_graph_topo_LDADD = $(COMMON_TEST_LDADD) \
$(top_builddir)/src/lib/libbabeltrace2.la
-noinst_PROGRAMS = test_bitfield test_bt_values \
- test_trace_ir_ref test_graph_topo
+noinst_PROGRAMS = \
+ test_bitfield \
+ test_bt_values \
+ test_bt_uuid \
+ test_trace_ir_ref \
+ test_graph_topo
test_bitfield_SOURCES = test_bitfield.c
test_bt_values_SOURCES = test_bt_values.c
+test_bt_uuid_SOURCES = test_bt_uuid.c
test_trace_ir_ref_SOURCES = test_trace_ir_ref.c
test_graph_topo_SOURCES = test_graph_topo.c
--- /dev/null
+/*
+ * test_bt_uuid.c
+ *
+ * Copyright 2019 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <tap/tap.h>
+
+#include "common/uuid.h"
+
+#define NR_TESTS 21
+
+static const char valid_str_1[] = "3d260c88-75ea-47b8-a7e2-d6077c0378d9";
+static const char valid_str_2[] = "611cf3a6-a68b-4515-834f-208bc2762592";
+static const char valid_str_3[] = "1b4855cc-96de-4ae8-abe3-86449c2a43c4";
+static const char valid_str_4[] = "8ADED5B9-ACD2-439F-A60C-897403AA2AB4";
+static const char valid_str_5[] = "f109e0a2-C619-4d18-b760-20EA20E0F69A";
+
+static bt_uuid_t valid_uuid_1 = {
+ 0x3d, 0x26, 0x0c, 0x88, 0x75, 0xea, 0x47, 0xb8,
+ 0xa7, 0xe2, 0xd6, 0x07, 0x7c, 0x03, 0x78, 0xd9
+};
+static bt_uuid_t valid_uuid_2 = {
+ 0x61, 0x1c, 0xf3, 0xa6, 0xa6, 0x8b, 0x45, 0x15,
+ 0x83, 0x4f, 0x20, 0x8b, 0xc2, 0x76, 0x25, 0x92
+};
+static bt_uuid_t valid_uuid_3 = {
+ 0x1b, 0x48, 0x55, 0xcc, 0x96, 0xde, 0x4a, 0xe8,
+ 0xab, 0xe3, 0x86, 0x44, 0x9c, 0x2a, 0x43, 0xc4
+};
+
+static const char invalid_str_1[] = "1b485!cc-96de-4XX8-abe3-86449c2a43?4";
+static const char invalid_str_2[] = "c2e6eddb&3955&4006&be3a&70bb63bd5f25";
+static const char invalid_str_3[] = "81b1cb88-ff42-45b9-ba4d-964088ee45";
+static const char invalid_str_4[] = "2d-6c6d756574-470e-9142-a4e6ad03f143";
+static const char invalid_str_5[] = "4542ad19-9e4f-4931-8261-2101c3e089ae7";
+static const char invalid_str_6[] = "XX0123";
+
+static
+void run_test_bt_uuid_from_str(void)
+{
+ int ret;
+ bt_uuid_t uuid1;
+
+ /*
+ * Parse valid UUID strings, expect success.
+ */
+ ret = bt_uuid_from_str(valid_str_1, uuid1);
+ ok(ret == 0, "bt_uuid_from_str - Parse valid string '%s', expect success", valid_str_1);
+
+ ret = bt_uuid_from_str(valid_str_2, uuid1);
+ ok(ret == 0, "bt_uuid_from_str - Parse valid string '%s', expect success", valid_str_2);
+
+ ret = bt_uuid_from_str(valid_str_3, uuid1);
+ ok(ret == 0, "bt_uuid_from_str - Parse valid string '%s', expect success", valid_str_3);
+
+ ret = bt_uuid_from_str(valid_str_4, uuid1);
+ ok(ret == 0, "bt_uuid_from_str - Parse valid string '%s', expect success", valid_str_4);
+
+ ret = bt_uuid_from_str(valid_str_5, uuid1);
+ ok(ret == 0, "bt_uuid_from_str - Parse valid string '%s', expect success", valid_str_5);
+
+ /*
+ * Parse invalid UUID strings, expect failure.
+ */
+ ret = bt_uuid_from_str(invalid_str_1, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_1);
+
+ ret = bt_uuid_from_str(invalid_str_2, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_2);
+
+ ret = bt_uuid_from_str(invalid_str_3, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_3);
+
+ ret = bt_uuid_from_str(invalid_str_4, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_4);
+
+ ret = bt_uuid_from_str(invalid_str_5, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_5);
+
+ ret = bt_uuid_from_str(invalid_str_6, uuid1);
+ ok(ret != 0, "bt_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_6);
+}
+
+static
+void run_test_bt_uuid_to_str(void)
+{
+ char uuid_str[BT_UUID_STR_LEN + 1];
+
+ bt_uuid_to_str(valid_uuid_1, uuid_str);
+ ok(strcmp(uuid_str, valid_str_1) == 0, "bt_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_1);
+
+ bt_uuid_to_str(valid_uuid_2, uuid_str);
+ ok(strcmp(uuid_str, valid_str_2) == 0, "bt_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_2);
+
+ bt_uuid_to_str(valid_uuid_3, uuid_str);
+ ok(strcmp(uuid_str, valid_str_3) == 0, "bt_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_3);
+}
+
+static
+void run_test_bt_uuid_compare(void)
+{
+ int ret;
+ bt_uuid_t uuid1, uuid2;
+
+ bt_uuid_from_str(valid_str_1, uuid1);
+ bt_uuid_from_str(valid_str_1, uuid2);
+ ret = bt_uuid_compare(uuid1, uuid2);
+ ok(ret == 0, "bt_uuid_compare - Compare same UUID, expect success");
+
+ bt_uuid_from_str(valid_str_2, uuid2);
+ ret = bt_uuid_compare(uuid1, uuid2);
+ ok(ret != 0, "bt_uuid_compare - Compare different UUID, expect failure");
+}
+
+static
+void run_test_bt_uuid_copy(void)
+{
+ int ret;
+ bt_uuid_t uuid1;
+
+ bt_uuid_copy(uuid1, valid_uuid_1);
+ ret = bt_uuid_compare(uuid1, valid_uuid_1);
+
+ ok(ret == 0, "bt_uuid_copy - Compare copied UUID with source, expect success");
+}
+
+static
+void run_test_bt_uuid_generate(void)
+{
+ int ret;
+ bt_uuid_t uuid1, uuid2;
+
+ bt_uuid_generate(uuid1);
+ bt_uuid_generate(uuid2);
+
+ ok(bt_uuid_compare(uuid1, uuid2) != 0, "bt_uuid_generate - Generated UUIDs are different");
+
+ /*
+ * Set the two most significant bits (bits 6 and 7) of the
+ * clock_seq_hi_and_reserved to zero and one, respectively.
+ */
+ ret = uuid1[8] & (1 << 6);
+ ok(ret == 0, "bt_uuid_generate - bit 6 of clock_seq_hi_and_reserved is set to zero");
+
+ ret = uuid1[8] & (1 << 7);
+ ok(ret != 0, "bt_uuid_generate - bit 7 of clock_seq_hi_and_reserved is set to one");
+
+ /*
+ * Set the four most significant bits (bits 12 through 15) of the
+ * time_hi_and_version field to the 4-bit version number from
+ * Section 4.1.3.
+ */
+ ret = uuid1[6] >> 4;
+ ok(ret == BT_UUID_VER, "bt_uuid_generate - Generated UUID version check");
+}
+
+static
+void run_test(void)
+{
+ plan_tests(NR_TESTS);
+
+ run_test_bt_uuid_from_str();
+ run_test_bt_uuid_to_str();
+ run_test_bt_uuid_compare();
+ run_test_bt_uuid_copy();
+ run_test_bt_uuid_generate();
+}
+
+int main(int argc, char **argv)
+{
+ /* Run tap-formated tests */
+ run_test();
+
+ return exit_status();
+}