From: Jérémie Galarneau Date: Wed, 24 Feb 2016 00:49:04 +0000 (-0500) Subject: Add base plug-in skeletons X-Git-Tag: v2.0.0-pre1~834 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=f3bc20108cb89fa01f746a9f17ef22619d95920b;hp=7c7c0433f4507935fbe2adab29d942df22ee8168;p=babeltrace.git Add base plug-in skeletons Signed-off-by: Jérémie Galarneau --- 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/ctf/text/Makefile.am deleted file mode 100644 index eb7cd197..00000000 --- a/plugins/ctf/text/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include - -SUBDIRS = . - -lib_LTLIBRARIES = libbabeltrace-plugin-ctf-text.la - -# Plug-in system library -libbabeltrace_plugin_ctf_text_la_SOURCES = \ - text.c - -# Request that the linker keeps all static library objects. -libbabeltrace_plugin_ctf_text_la_LDFLAGS = \ - $(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION) - -libbabeltrace_plugin_ctf_text_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/text/text.c b/plugins/ctf/text/text.c deleted file mode 100644 index 75574973..00000000 --- a/plugins/ctf/text/text.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * text.c - * - * Babeltrace CTF Text Output Plugin - * - * 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 -#include -#include -#include -#include -#include - -static -enum bt_component_status ctf_text_init(struct bt_component *, - struct bt_value *params); - -/* Initialize plug-in entry points. */ -BT_PLUGIN_NAME("ctf-text"); -BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in."); -BT_PLUGIN_AUTHOR("Jérémie Galarneau"); -BT_PLUGIN_LICENSE("MIT"); - -BT_PLUGIN_COMPONENT_CLASSES_BEGIN -BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY("text", "Formats CTF-IR to text. Formerly known as ctf-text.", ctf_text_init) -BT_PLUGIN_COMPONENT_CLASSES_END - -enum loglevel { - LOGLEVEL_EMERG = 0, - LOGLEVEL_ALERT = 1, - LOGLEVEL_CRIT = 2, - LOGLEVEL_ERR = 3, - LOGLEVEL_WARNING = 4, - LOGLEVEL_NOTICE = 5, - LOGLEVEL_INFO = 6, - LOGLEVEL_DEBUG_SYSTEM = 7, - LOGLEVEL_DEBUG_PROGRAM = 8, - LOGLEVEL_DEBUG_PROCESS = 9, - LOGLEVEL_DEBUG_MODULE = 10, - LOGLEVEL_DEBUG_UNIT = 11, - LOGLEVEL_DEBUG_FUNCTION = 12, - LOGLEVEL_DEBUG_LINE = 13, - LOGLEVEL_DEBUG = 14, -}; - -static -const char *loglevel_str [] = { - [LOGLEVEL_EMERG] = "TRACE_EMERG", - [LOGLEVEL_ALERT] = "TRACE_ALERT", - [LOGLEVEL_CRIT] = "TRACE_CRIT", - [LOGLEVEL_ERR] = "TRACE_ERR", - [LOGLEVEL_WARNING] = "TRACE_WARNING", - [LOGLEVEL_NOTICE] = "TRACE_NOTICE", - [LOGLEVEL_INFO] = "TRACE_INFO", - [LOGLEVEL_DEBUG_SYSTEM] = "TRACE_DEBUG_SYSTEM", - [LOGLEVEL_DEBUG_PROGRAM] = "TRACE_DEBUG_PROGRAM", - [LOGLEVEL_DEBUG_PROCESS] = "TRACE_DEBUG_PROCESS", - [LOGLEVEL_DEBUG_MODULE] = "TRACE_DEBUG_MODULE", - [LOGLEVEL_DEBUG_UNIT] = "TRACE_DEBUG_UNIT", - [LOGLEVEL_DEBUG_FUNCTION] = "TRACE_DEBUG_FUNCTION", - [LOGLEVEL_DEBUG_LINE] = "TRACE_DEBUG_LINE", - [LOGLEVEL_DEBUG] = "TRACE_DEBUG", -}; - -struct ctf_text_component { - bool opt_print_all_field_names : 1; - bool opt_print_scope_field_names : 1; - bool opt_print_header_field_names : 1; - bool opt_print_context_field_names : 1; - bool opt_print_payload_field_names : 1; - bool opt_print_all_fields : 1; - bool opt_print_trace_field : 1; - bool opt_print_trace_domain_field : 1; - bool opt_print_trace_procname_field : 1; - bool opt_print_trace_vpid_field : 1; - bool opt_print_trace_hostname_field : 1; - bool opt_print_trace_default_fields : 1; - bool opt_print_loglevel_field : 1; - bool opt_print_emf_field : 1; - bool opt_print_delta_field : 1; -}; - -static -enum bt_component_status ctf_text_init( - struct bt_component *component, struct bt_value *params) -{ - printf("ctf_text_init\n"); - return BT_COMPONENT_STATUS_OK; -} diff --git a/plugins/text/Makefile.am b/plugins/text/Makefile.am new file mode 100644 index 00000000..eb7cd197 --- /dev/null +++ b/plugins/text/Makefile.am @@ -0,0 +1,18 @@ +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include + +SUBDIRS = . + +lib_LTLIBRARIES = libbabeltrace-plugin-ctf-text.la + +# Plug-in system library +libbabeltrace_plugin_ctf_text_la_SOURCES = \ + text.c + +# Request that the linker keeps all static library objects. +libbabeltrace_plugin_ctf_text_la_LDFLAGS = \ + $(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION) + +libbabeltrace_plugin_ctf_text_la_LIBADD = \ + $(top_builddir)/lib/libbabeltrace.la \ + $(top_builddir)/formats/ctf/libbabeltrace-ctf.la \ + $(top_builddir)/plugins/libbabeltrace-plugin.la diff --git a/plugins/text/text.c b/plugins/text/text.c new file mode 100644 index 00000000..50d5a4bc --- /dev/null +++ b/plugins/text/text.c @@ -0,0 +1,111 @@ +/* + * text.c + * + * Babeltrace CTF Text Output Plugin + * + * 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 +#include +#include +#include +#include + +static +enum bt_component_status ctf_text_init(struct bt_component *, + struct bt_value *params); + +/* Initialize plug-in entry points. */ +BT_PLUGIN_NAME("ctf-text"); +BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in."); +BT_PLUGIN_AUTHOR("Jérémie Galarneau"); +BT_PLUGIN_LICENSE("MIT"); + +BT_PLUGIN_COMPONENT_CLASSES_BEGIN +BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY("text", "Formats CTF-IR to text. Formerly known as ctf-text.", ctf_text_init) +BT_PLUGIN_COMPONENT_CLASSES_END + +enum loglevel { + LOGLEVEL_EMERG = 0, + LOGLEVEL_ALERT = 1, + LOGLEVEL_CRIT = 2, + LOGLEVEL_ERR = 3, + LOGLEVEL_WARNING = 4, + LOGLEVEL_NOTICE = 5, + LOGLEVEL_INFO = 6, + LOGLEVEL_DEBUG_SYSTEM = 7, + LOGLEVEL_DEBUG_PROGRAM = 8, + LOGLEVEL_DEBUG_PROCESS = 9, + LOGLEVEL_DEBUG_MODULE = 10, + LOGLEVEL_DEBUG_UNIT = 11, + LOGLEVEL_DEBUG_FUNCTION = 12, + LOGLEVEL_DEBUG_LINE = 13, + LOGLEVEL_DEBUG = 14, +}; + +static +const char *loglevel_str [] = { + [LOGLEVEL_EMERG] = "TRACE_EMERG", + [LOGLEVEL_ALERT] = "TRACE_ALERT", + [LOGLEVEL_CRIT] = "TRACE_CRIT", + [LOGLEVEL_ERR] = "TRACE_ERR", + [LOGLEVEL_WARNING] = "TRACE_WARNING", + [LOGLEVEL_NOTICE] = "TRACE_NOTICE", + [LOGLEVEL_INFO] = "TRACE_INFO", + [LOGLEVEL_DEBUG_SYSTEM] = "TRACE_DEBUG_SYSTEM", + [LOGLEVEL_DEBUG_PROGRAM] = "TRACE_DEBUG_PROGRAM", + [LOGLEVEL_DEBUG_PROCESS] = "TRACE_DEBUG_PROCESS", + [LOGLEVEL_DEBUG_MODULE] = "TRACE_DEBUG_MODULE", + [LOGLEVEL_DEBUG_UNIT] = "TRACE_DEBUG_UNIT", + [LOGLEVEL_DEBUG_FUNCTION] = "TRACE_DEBUG_FUNCTION", + [LOGLEVEL_DEBUG_LINE] = "TRACE_DEBUG_LINE", + [LOGLEVEL_DEBUG] = "TRACE_DEBUG", +}; + +struct ctf_text_component { + bool opt_print_all_field_names : 1; + bool opt_print_scope_field_names : 1; + bool opt_print_header_field_names : 1; + bool opt_print_context_field_names : 1; + bool opt_print_payload_field_names : 1; + bool opt_print_all_fields : 1; + bool opt_print_trace_field : 1; + bool opt_print_trace_domain_field : 1; + bool opt_print_trace_procname_field : 1; + bool opt_print_trace_vpid_field : 1; + bool opt_print_trace_hostname_field : 1; + bool opt_print_trace_default_fields : 1; + bool opt_print_loglevel_field : 1; + bool opt_print_emf_field : 1; + bool opt_print_delta_field : 1; +}; + +static +enum bt_component_status ctf_text_init( + struct bt_component *component, struct bt_value *params) +{ + printf("ctf_text_init\n"); + return BT_COMPONENT_STATUS_OK; +}