From f3bc20108cb89fa01f746a9f17ef22619d95920b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 23 Feb 2016 19:49:04 -0500 Subject: [PATCH] Add base plug-in skeletons MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- configure.ac | 3 +- include/babeltrace/plugin/component-class.h | 2 +- include/babeltrace/plugin/component.h | 1 + include/babeltrace/plugin/plugin-macros.h | 17 +++-- include/babeltrace/plugin/plugin.h | 8 +++ include/babeltrace/plugin/sink.h | 2 + include/babeltrace/plugin/source.h | 1 + plugins/Makefile.am | 2 +- plugins/ctf/Makefile.am | 19 +++++- plugins/ctf/live/live.c | 0 plugins/ctf/lttng-live/Makefile.am | 15 +++++ plugins/ctf/lttng-live/lttng-live-internal.h | 40 +++++++++++ plugins/ctf/lttng-live/lttng-live.c | 37 +++++++++++ plugins/ctf/reader/Makefile.am | 7 +- plugins/ctf/reader/reader-internal.h | 18 ++--- plugins/ctf/reader/reader.c | 70 +++----------------- plugins/ctf/symbols.c | 45 +++++++++++++ plugins/{ctf => }/text/Makefile.am | 0 plugins/{ctf => }/text/text.c | 1 - 19 files changed, 199 insertions(+), 89 deletions(-) delete mode 100644 plugins/ctf/live/live.c create mode 100644 plugins/ctf/lttng-live/Makefile.am create mode 100644 plugins/ctf/lttng-live/lttng-live-internal.h create mode 100644 plugins/ctf/lttng-live/lttng-live.c create mode 100644 plugins/ctf/symbols.c rename plugins/{ctf => }/text/Makefile.am (100%) rename plugins/{ctf => }/text/text.c (99%) diff --git a/configure.ac b/configure.ac index 6acf1deb..d5aa005b 100644 --- a/configure.ac +++ b/configure.ac @@ -372,7 +372,8 @@ AC_CONFIG_FILES([ plugins/Makefile plugins/ctf/Makefile plugins/ctf/reader/Makefile - plugins/ctf/text/Makefile + plugins/ctf/lttng-live/Makefile + plugins/text/Makefile babeltrace.pc babeltrace-ctf.pc ]) diff --git a/include/babeltrace/plugin/component-class.h b/include/babeltrace/plugin/component-class.h index a8826681..1526e4cb 100644 --- a/include/babeltrace/plugin/component-class.h +++ b/include/babeltrace/plugin/component-class.h @@ -67,7 +67,7 @@ extern const char *bt_component_class_get_name( * @param component_class Component class of which to get the description * @returns Description of the component class, or NULL. */ -extern const char *bt_component_class_get_name( +extern const char *bt_component_class_get_description( struct bt_component_class *component_class); /** diff --git a/include/babeltrace/plugin/component.h b/include/babeltrace/plugin/component.h index 53684dbd..5dc0e390 100644 --- a/include/babeltrace/plugin/component.h +++ b/include/babeltrace/plugin/component.h @@ -28,6 +28,7 @@ */ #include +#include #include #ifdef __cplusplus diff --git a/include/babeltrace/plugin/plugin-macros.h b/include/babeltrace/plugin/plugin-macros.h index 56916f71..26c3ebc3 100644 --- a/include/babeltrace/plugin/plugin-macros.h +++ b/include/babeltrace/plugin/plugin-macros.h @@ -39,9 +39,9 @@ #define BT_PLUGIN_INIT(_x) bt_plugin_init_func __bt_plugin_init = (_x) #define BT_PLUGIN_EXIT(_x) bt_plugin_exit_func __bt_plugin_exit = (_x) -#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN \ - enum bt_component_status __bt_plugin_register_component_classes(\ - struct bt_component_factory *factory) \ +#define BT_PLUGIN_COMPONENT_CLASSES_BEGIN \ + static enum bt_component_status __bt_plugin_register_component_classes( \ + struct bt_component_factory *factory) \ { #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(_name, description, _init) \ @@ -52,11 +52,10 @@ bt_component_factory_register_sink_component_class(factory, \ _name, _description, _init); -#define BT_PLUGIN_COMPONENT_CLASSES_END\ - \ - return BT_COMPONENT_STATUS_OK;\ -}\ - \ - BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\ +#define BT_PLUGIN_COMPONENT_CLASSES_END \ + return BT_COMPONENT_STATUS_OK; \ +} \ + \ + BT_PLUGIN_INIT(__bt_plugin_register_component_classes); \ #endif /* BABELTRACE_PLUGIN_MACROS_H */ diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index e5c69eed..8eec84e5 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -57,6 +57,14 @@ extern const char *bt_plugin_get_author(struct bt_plugin *plugin); */ extern const char *bt_plugin_get_license(struct bt_plugin *plugin); +/** + * Get the decription of a plug-in. + * + * @param plugin An instance of a plug-in + * @returns Plug-in description or NULL if none is available + */ +extern const char *bt_plugin_get_description(struct bt_plugin *plugin); + /** * Get the path of a plug-in. * diff --git a/include/babeltrace/plugin/sink.h b/include/babeltrace/plugin/sink.h index 5f188d33..ae563f67 100644 --- a/include/babeltrace/plugin/sink.h +++ b/include/babeltrace/plugin/sink.h @@ -27,6 +27,8 @@ * SOFTWARE. */ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/include/babeltrace/plugin/source.h b/include/babeltrace/plugin/source.h index 13faedd0..7329eeeb 100644 --- a/include/babeltrace/plugin/source.h +++ b/include/babeltrace/plugin/source.h @@ -28,6 +28,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 29226a30..28bd175d 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,6 +1,6 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -SUBDIRS = . ctf +SUBDIRS = . ctf text lib_LTLIBRARIES = libbabeltrace-plugin.la diff --git a/plugins/ctf/Makefile.am b/plugins/ctf/Makefile.am index b43d126e..e916b160 100644 --- a/plugins/ctf/Makefile.am +++ b/plugins/ctf/Makefile.am @@ -1,3 +1,20 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -SUBDIRS = text +SUBDIRS = reader lttng-live + +lib_LTLIBRARIES = libbabeltrace-plugin-ctf.la + +# Plug-in system library +libbabeltrace_plugin_ctf_la_SOURCES = symbols.c + +# Request that the linker keeps all static library objects. +libbabeltrace_plugin_ctf_la_LDFLAGS = \ + $(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION) +# -Wl,--whole-archive,reader/.libs/libbabeltrace-plugin-ctf-reader.a,--no-whole-archive + +libbabeltrace_plugin_ctf_la_LIBADD = \ + $(top_builddir)/lib/libbabeltrace.la \ + $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \ + $(top_builddir)/plugins/libbabeltrace-plugin.la \ + $(top_builddir)/plugins/ctf/reader/libbabeltrace-plugin-ctf-reader.la \ + $(top_builddir)/plugins/ctf/lttng-live/libbabeltrace-plugin-ctf-lttng-live.la diff --git a/plugins/ctf/live/live.c b/plugins/ctf/live/live.c deleted file mode 100644 index e69de29b..00000000 diff --git a/plugins/ctf/lttng-live/Makefile.am b/plugins/ctf/lttng-live/Makefile.am new file mode 100644 index 00000000..f1b9177f --- /dev/null +++ b/plugins/ctf/lttng-live/Makefile.am @@ -0,0 +1,15 @@ +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include + +libbabeltrace_plugin_ctf_lttng_live_la_SOURCES = lttng-live.c + +noinst_HEADERS = lttng-live-internal.h +noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-lttng-live.la + +# Request that the linker keeps all static library objects. +libbabeltrace_plugin_ctf_lttng_live_la_LDFLAGS = \ + $(LD_NO_AS_NEEDED) + +libbabeltrace_plugin_ctf_lttng_live_la_LIBADD = \ + $(top_builddir)/lib/libbabeltrace.la \ + $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \ + $(top_builddir)/plugins/libbabeltrace-plugin.la diff --git a/plugins/ctf/lttng-live/lttng-live-internal.h b/plugins/ctf/lttng-live/lttng-live-internal.h new file mode 100644 index 00000000..0cc5afb9 --- /dev/null +++ b/plugins/ctf/lttng-live/lttng-live-internal.h @@ -0,0 +1,40 @@ +#ifndef BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H +#define BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H + +/* + * BabelTrace - LTTng-live client Component + * + * Copyright 2016 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * 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 +#include + +#define LTTNG_LIVE_COMPONENT_NAME "lttng-live" +#define LTTNG_LIVE_COMPONENT_DESCRIPTION "Component implementing an LTTng-live client." + +BT_HIDDEN +enum bt_component_status lttng_live_init(struct bt_component *source, + struct bt_value *params); + +#endif /* BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H */ diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c new file mode 100644 index 00000000..4f28f484 --- /dev/null +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -0,0 +1,37 @@ +/* + * lttng-live.c + * + * Babeltrace CTF LTTng-live Client Component + * + * Copyright 2016 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * 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 "lttng-live-internal.h" +#include + +BT_HIDDEN +enum bt_component_status lttng_live_init(struct bt_component *component, + struct bt_value *params) +{ + return BT_COMPONENT_STATUS_OK; +} diff --git a/plugins/ctf/reader/Makefile.am b/plugins/ctf/reader/Makefile.am index 9d828a02..7e50953f 100644 --- a/plugins/ctf/reader/Makefile.am +++ b/plugins/ctf/reader/Makefile.am @@ -1,8 +1,7 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -SUBDIRS = . - -lib_LTLIBRARIES = libbabeltrace-plugin-ctf-reader.la +noinst_HEADERS = reader-internal.h +noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-reader.la # Plug-in system library libbabeltrace_plugin_ctf_reader_la_SOURCES = \ @@ -10,7 +9,7 @@ libbabeltrace_plugin_ctf_reader_la_SOURCES = \ # Request that the linker keeps all static librarie objects. libbabeltrace_plugin_ctf_reader_la_LDFLAGS = \ - -Wl,--no-as-needed -version-info $(BABELTRACE_LIBRARY_VERSION) + -Wl,--no-as-needed libbabeltrace_plugin_ctf_reader_la_LIBADD = \ $(top_builddir)/lib/libbabeltrace.la \ diff --git a/plugins/ctf/reader/reader-internal.h b/plugins/ctf/reader/reader-internal.h index cab8edb2..1ebae604 100644 --- a/plugins/ctf/reader/reader-internal.h +++ b/plugins/ctf/reader/reader-internal.h @@ -2,9 +2,9 @@ #define BABELTRACE_PLUGIN_CTF_READER_INTERNAL_H /* - * BabelTrace - CTF Reader plug-in internal + * BabelTrace - CTF Reader Component * - * Copyright 2015 Jérémie Galarneau + * Copyright 2016 Jérémie Galarneau * * Author: Jérémie Galarneau * @@ -27,14 +27,14 @@ * SOFTWARE. */ -#ifdef __cplusplus -extern "C" { -#endif +#include +#include +#define READER_COMPONENT_NAME "ctf" +#define READER_COMPONENT_DESCRIPTION "Component used to read on-disk CTF traces." - -#ifdef __cplusplus -} -#endif +BT_HIDDEN +enum bt_component_status ctf_init(struct bt_component *source, + struct bt_value *params); #endif /* BABELTRACE_PLUGIN_CTF_READER_INTERNAL_H */ diff --git a/plugins/ctf/reader/reader.c b/plugins/ctf/reader/reader.c index 5802b8b0..ccf860ab 100644 --- a/plugins/ctf/reader/reader.c +++ b/plugins/ctf/reader/reader.c @@ -1,9 +1,9 @@ /* * reader.c * - * Babeltrace CTF Reader Plugin + * Babeltrace CTF Reader Component * - * Copyright 2015 Jérémie Galarneau + * Copyright 2016 Jérémie Galarneau * * Author: Jérémie Galarneau * @@ -26,68 +26,14 @@ * SOFTWARE. */ -#include -#include -#include -#include -#include +#include "reader-internal.h" +#include -const char *plugin_name = "ctf"; - -struct ctf_reader { - int a; -}; - -enum bt_plugin_type bt_plugin_lib_get_type(void) +BT_HIDDEN +enum bt_component_status ctf_init(struct bt_component *component, + struct bt_value *params) { - return BT_PLUGIN_TYPE_SOURCE; + return BT_COMPONENT_STATUS_OK; } -const char *bt_plugin_lib_get_format_name(void) -{ - return plugin_name; -} -static -void ctf_reader_destroy(struct bt_plugin *plugin) -{ - struct ctf_reader *reader; - - if (!plugin) { - return; - } - - reader = bt_plugin_get_private_data(plugin); - if (!reader) { - return; - } - - g_free(reader); -} - -static -struct bt_notification_iterator *ctf_reader_iterator_create( - struct bt_plugin *plugin) -{ - return NULL; -} - -struct bt_plugin *bt_plugin_lib_create(struct bt_object *params) -{ - struct bt_plugin *plugin = NULL; - struct ctf_reader *reader = g_new0(struct ctf_reader, 1); - - plugin = bt_plugin_source_create(plugin_name, reader, - ctf_reader_destroy, ctf_reader_iterator_create); - if (!plugin) { - goto error; - } - -end: - return plugin; -error: - if (reader) { - g_free(reader); - } - goto end; -} diff --git a/plugins/ctf/symbols.c b/plugins/ctf/symbols.c new file mode 100644 index 00000000..2cc423ea --- /dev/null +++ b/plugins/ctf/symbols.c @@ -0,0 +1,45 @@ +/* + * symbols.c + * + * Babeltrace CTF Plug-in Registration Symbols + * + * Copyright 2016 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * 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 +#include "reader/reader-internal.h" +#include "lttng-live/lttng-live-internal.h" + +/* Initialize plug-in entry points. */ +BT_PLUGIN_NAME("ctf"); +BT_PLUGIN_DESCRIPTION("Babeltrace CTF plug-in."); +BT_PLUGIN_AUTHOR("Jérémie Galarneau"); +BT_PLUGIN_LICENSE("MIT"); + +BT_PLUGIN_COMPONENT_CLASSES_BEGIN +BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(READER_COMPONENT_NAME, + READER_COMPONENT_DESCRIPTION, ctf_init); +BT_PLUGIN_SOURCE_COMPONENT_CLASS_ENTRY(LTTNG_LIVE_COMPONENT_NAME, + LTTNG_LIVE_COMPONENT_DESCRIPTION, lttng_live_init); +BT_PLUGIN_COMPONENT_CLASSES_END + diff --git a/plugins/ctf/text/Makefile.am b/plugins/text/Makefile.am similarity index 100% rename from plugins/ctf/text/Makefile.am rename to plugins/text/Makefile.am diff --git a/plugins/ctf/text/text.c b/plugins/text/text.c similarity index 99% rename from plugins/ctf/text/text.c rename to plugins/text/text.c index 75574973..50d5a4bc 100644 --- a/plugins/ctf/text/text.c +++ b/plugins/text/text.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include -- 2.34.1