src.ctf.fs: move internal util to ctf/common/utils
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 22 Aug 2017 21:33:41 +0000 (17:33 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Aug 2017 18:31:25 +0000 (14:31 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
plugins/ctf/common/Makefile.am
plugins/ctf/common/utils/Makefile.am [new file with mode: 0644]
plugins/ctf/common/utils/logging.c [new file with mode: 0644]
plugins/ctf/common/utils/logging.h [new file with mode: 0644]
plugins/ctf/common/utils/utils.c [new file with mode: 0644]
plugins/ctf/common/utils/utils.h [new file with mode: 0644]
plugins/ctf/fs-src/fs.c

index d15957d665808de365ebab4c5e1b24de0582cfee..8df8dee9c804d72afbf233432f71bd137218d4bf 100644 (file)
@@ -699,6 +699,7 @@ AC_CONFIG_FILES([
        plugins/ctf/common/btr/Makefile
        plugins/ctf/common/metadata/Makefile
        plugins/ctf/common/notif-iter/Makefile
+       plugins/ctf/common/utils/Makefile
        plugins/ctf/fs-src/Makefile
        plugins/ctf/fs-sink/Makefile
        plugins/ctf/lttng-live/Makefile
index f40c22e1d4314f5b44032269401840a0453a11e1..63a4e302f842e88dd287fa1da58632c9a2a3aa58 100644 (file)
@@ -1,9 +1,10 @@
-SUBDIRS = btr notif-iter metadata
+SUBDIRS = utils btr notif-iter metadata
 
 noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-common.la
 libbabeltrace_plugin_ctf_common_la_SOURCES = print.h
 libbabeltrace_plugin_ctf_common_la_LIBADD =            \
-       $(builddir)/btr/libctf-btr.la           \
-       $(builddir)/metadata/libctf-parser.la   \
-       $(builddir)/metadata/libctf-ast.la      \
-       $(builddir)/notif-iter/libctf-notif-iter.la
+       $(builddir)/btr/libctf-btr.la                   \
+       $(builddir)/metadata/libctf-parser.la           \
+       $(builddir)/metadata/libctf-ast.la              \
+       $(builddir)/notif-iter/libctf-notif-iter.la     \
+       $(builddir)/utils/libctf-utils.la
diff --git a/plugins/ctf/common/utils/Makefile.am b/plugins/ctf/common/utils/Makefile.am
new file mode 100644 (file)
index 0000000..c4b62ff
--- /dev/null
@@ -0,0 +1,6 @@
+noinst_LTLIBRARIES = libctf-utils.la
+libctf_utils_la_SOURCES = \
+       logging.c \
+       logging.h \
+       utils.c \
+       utils.h
diff --git a/plugins/ctf/common/utils/logging.c b/plugins/ctf/common/utils/logging.c
new file mode 100644 (file)
index 0000000..6fc5e6c
--- /dev/null
@@ -0,0 +1,26 @@
+ /*
+ * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL utils_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(utils_log_level, "BABELTRACE_PLUGIN_CTF_UTILS_LOG_LEVEL");
diff --git a/plugins/ctf/common/utils/logging.h b/plugins/ctf/common/utils/logging.h
new file mode 100644 (file)
index 0000000..eef0625
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef CTF_UTILS_LOGGING_H
+#define CTF_UTILS_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL utils_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(utils_log_level);
+
+#endif /* CTF_UTILS_LOGGING_H */
diff --git a/plugins/ctf/common/utils/utils.c b/plugins/ctf/common/utils/utils.c
new file mode 100644 (file)
index 0000000..9af59da
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Babeltrace - CTF Utils
+ *
+ * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#define BT_LOG_TAG "PLUGIN-CTF-UTILS"
+#include "logging.h"
+
+#include "utils.h"
+
+struct bt_ctf_stream_class *ctf_utils_stream_class_from_packet_header(
+               struct bt_ctf_trace *trace,
+               struct bt_ctf_field *packet_header_field)
+{
+       struct bt_ctf_field *stream_id_field = NULL;
+       struct bt_ctf_stream_class *stream_class = NULL;
+       uint64_t stream_id = -1ULL;
+       int ret;
+
+       if (!packet_header_field) {
+               goto single_stream_class;
+       }
+
+       stream_id_field = bt_ctf_field_structure_get_field_by_name(
+               packet_header_field, "stream_id");
+       if (!stream_id_field) {
+               goto single_stream_class;
+       }
+
+       ret = bt_ctf_field_unsigned_integer_get_value(stream_id_field,
+               &stream_id);
+       if (ret) {
+               stream_id = -1ULL;
+       }
+
+       if (stream_id == -1ULL) {
+single_stream_class:
+               /* Single stream class */
+               if (bt_ctf_trace_get_stream_class_count(trace) == 0) {
+                       goto end;
+               }
+
+               stream_class = bt_ctf_trace_get_stream_class_by_index(trace, 0);
+       } else {
+               stream_class = bt_ctf_trace_get_stream_class_by_id(trace,
+                       stream_id);
+       }
+
+end:
+       bt_put(stream_id_field);
+       return stream_class;
+}
diff --git a/plugins/ctf/common/utils/utils.h b/plugins/ctf/common/utils/utils.h
new file mode 100644 (file)
index 0000000..2e9e23e
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef CTF_UTILS_H
+#define CTF_UTILS_H
+
+/*
+ * Babeltrace - CTF Utilities
+ *
+ * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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 <babeltrace/ctf-ir/stream-class.h>
+#include <babeltrace/ctf-ir/fields.h>
+#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/babeltrace-internal.h>
+
+struct bt_ctf_stream_class *ctf_utils_stream_class_from_packet_header(
+               struct bt_ctf_trace *trace,
+               struct bt_ctf_field *packet_header_field);
+
+#endif /* CTF_UTILS_H */
index 7cbd28f8af0c5ad777c8d9d7870c1ccef627a1be..32121b7360ec51117e15b93c7941d802018df5c5 100644 (file)
@@ -48,6 +48,7 @@
 #include "file.h"
 #include "../common/metadata/decoder.h"
 #include "../common/notif-iter/notif-iter.h"
+#include "../common/utils/utils.h"
 #include "query.h"
 
 #define BT_LOG_TAG "PLUGIN-CTF-FS-SRC"
@@ -403,51 +404,6 @@ end:
        return stream_instance_id;
 }
 
-struct bt_ctf_stream_class *stream_class_from_packet_header(
-               struct ctf_fs_trace *ctf_fs_trace,
-               struct bt_ctf_field *packet_header_field)
-{
-       struct bt_ctf_field *stream_id_field = NULL;
-       struct bt_ctf_stream_class *stream_class = NULL;
-       uint64_t stream_id = -1ULL;
-       int ret;
-
-       if (!packet_header_field) {
-               goto single_stream_class;
-       }
-
-       stream_id_field = bt_ctf_field_structure_get_field_by_name(
-               packet_header_field, "stream_id");
-       if (!stream_id_field) {
-               goto single_stream_class;
-       }
-
-       ret = bt_ctf_field_unsigned_integer_get_value(stream_id_field,
-               &stream_id);
-       if (ret) {
-               stream_id = -1ULL;
-       }
-
-       if (stream_id == -1ULL) {
-single_stream_class:
-               /* Single stream class */
-               if (bt_ctf_trace_get_stream_class_count(
-                               ctf_fs_trace->metadata->trace) == 0) {
-                       goto end;
-               }
-
-               stream_class = bt_ctf_trace_get_stream_class_by_index(
-                       ctf_fs_trace->metadata->trace, 0);
-       } else {
-               stream_class = bt_ctf_trace_get_stream_class_by_id(
-                       ctf_fs_trace->metadata->trace, stream_id);
-       }
-
-end:
-       bt_put(stream_id_field);
-       return stream_class;
-}
-
 uint64_t get_packet_context_timestamp_begin_ns(
                struct ctf_fs_trace *ctf_fs_trace,
                struct bt_ctf_field *packet_context_field)
@@ -698,8 +654,8 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
                packet_header_field);
        begin_ns = get_packet_context_timestamp_begin_ns(ctf_fs_trace,
                packet_context_field);
-       stream_class = stream_class_from_packet_header(ctf_fs_trace,
-               packet_header_field);
+       stream_class = ctf_utils_stream_class_from_packet_header(
+               ctf_fs_trace->metadata->trace, packet_header_field);
        if (!stream_class) {
                goto error;
        }
This page took 0.028918 seconds and 4 git commands to generate.