From 480dc8ed5a5b254201fd5df59b4ac750c34987c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Jul 2015 16:54:47 -0400 Subject: [PATCH] ctf-text plugin stub MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/babeltrace/plugin/plugin-system.h | 6 +- include/babeltrace/plugin/plugin.h | 5 +- plugins/Makefile.am | 2 +- plugins/ctf/Makefile.am | 17 +-- plugins/ctf/text/text.c | 154 +++++++--------------- 5 files changed, 59 insertions(+), 125 deletions(-) diff --git a/include/babeltrace/plugin/plugin-system.h b/include/babeltrace/plugin/plugin-system.h index d2970b58..b5158d8b 100644 --- a/include/babeltrace/plugin/plugin-system.h +++ b/include/babeltrace/plugin/plugin-system.h @@ -55,8 +55,9 @@ typedef void (*bt_component_destroy_cb)(struct bt_component *component); * deinitialization callback must be set by this function. * * @param component Component instance + * @returns One of #bt_component_status values */ -typedef struct bt_component *(*bt_component_source_init_cb)( +typedef enum bt_component_status (*bt_component_source_init_cb)( struct bt_component *component); /** @@ -66,8 +67,9 @@ typedef struct bt_component *(*bt_component_source_init_cb)( * deinitialization callback must be set by this function. * * @param component Component instance + * @returns One of #bt_component_status values */ -typedef struct bt_component *(*bt_component_sink_init_cb)( +typedef enum bt_component_status (*bt_component_sink_init_cb)( struct bt_component *component); /** diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index 945deb94..1642b7a0 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -39,8 +39,8 @@ typedef void (*bt_plugin_exit_func)(void); #define BT_PLUGIN_NAME(_x) const char *__bt_plugin_name = (_x) #define BT_PLUGIN_AUTHOR(_x) const char *__bt_plugin_author = (_x) #define BT_PLUGIN_LICENSE(_x) const char *__bt_plugin_license = (_x) -#define BT_PLUGIN_INIT(_x) bt_plugin_init __bt_plugin_init = (_x) -#define BT_PLUGIN_EXIT(_x) bt_plugin_exit __bt_plugin_exit = (_x) +#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(\ @@ -61,6 +61,5 @@ typedef void (*bt_plugin_exit_func)(void); }\ \ BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\ - BT_PLUGIN_EXIT(NULL); #endif /* BABELTRACE_PLUGIN_H */ diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 88643977..a3fe4270 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,6 +1,6 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -SUBDIRS = . +SUBDIRS = . ctf lib_LTLIBRARIES = libbabeltrace-plugin.la diff --git a/plugins/ctf/Makefile.am b/plugins/ctf/Makefile.am index 072d8175..b43d126e 100644 --- a/plugins/ctf/Makefile.am +++ b/plugins/ctf/Makefile.am @@ -1,18 +1,3 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -SUBDIRS = reader text - -# Shared code between all CTF plug-ins -#libbabeltrace_plugin_ctf_la_SOURCES = \ - plugin.c \ - source.c \ - sink.c \ - iterator.c - -# Request that the linker keeps all static librarie objects. -#libbabeltrace_plugin_la_LDFLAGS = \ - -Wl,--no-as-needed -version-info $(BABELTRACE_LIBRARY_VERSION) - -#libbabeltrace_plugin_ctf_la_LIBADD = \ - $(top_builddir)/lib/libbabeltrace.la \ - $(top_builddir)/ctf/ir/libctf-ir.la +SUBDIRS = text diff --git a/plugins/ctf/text/text.c b/plugins/ctf/text/text.c index f80ed589..03086ad5 100644 --- a/plugins/ctf/text/text.c +++ b/plugins/ctf/text/text.c @@ -26,15 +26,28 @@ * SOFTWARE. */ -#include -#include #include +#include #include +#include #include #include const char *plugin_name = "ctf-text"; +static enum bt_component_status ctf_text_init(struct bt_component *); +static void ctf_text_exit(void); + +BT_PLUGIN_NAME("ctf-text"); +BT_PLUGIN_AUTHOR("Jérémie Galarneau"); +BT_PLUGIN_LICENSE("MIT License"); +BT_PLUGIN_EXIT(ctf_text_exit); + +BT_PLUGIN_COMPONENT_CLASSES_BEGIN +BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(plugin_name, ctf_text_init) +BT_PLUGIN_COMPONENT_CLASSES_END + + enum loglevel { LOGLEVEL_EMERG = 0, LOGLEVEL_ALERT = 1, @@ -54,115 +67,50 @@ enum loglevel { }; 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", + [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 { - int opt_print_all_field_names; - int opt_print_scope_field_names; - int opt_print_header_field_names; - int opt_print_context_field_names; - int opt_print_payload_field_names; - int opt_print_all_fields; - int opt_print_trace_field; - int opt_print_trace_domain_field; - int opt_print_trace_procname_field; - int opt_print_trace_vpid_field; - int opt_print_trace_hostname_field; - int opt_print_trace_default_fields; - int opt_print_loglevel_field; - int opt_print_emf_field; - int opt_print_callsite_field; - int opt_print_delta_field; +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_callsite_field : 1; + bool opt_print_delta_field : 1; }; static -void ctf_text_destroy(struct bt_plugin *plugin) +enum bt_component_status ctf_text_init(struct bt_component *component) { - struct ctf_text *text; - - if (!plugin) { - return; - } - - text = bt_plugin_get_private_data(plugin); - if (!text) { - return; - } - - g_free(text); + return BT_COMPONENT_STATUS_OK; } static -int ctf_text_handle_notification(struct bt_plugin *plugin, - struct bt_notification *notification) -{ - return BT_PLUGIN_STATUS_OK; -} - -enum bt_plugin_type bt_plugin_lib_get_type(void) -{ - return BT_PLUGIN_TYPE_SINK; -} - -const char *bt_plugin_lib_get_format_name(void) +void ctf_text_exit(void) { - return plugin_name; -} - -static -int text_init(struct ctf_text *text, struct bt_object *params) -{ - int ret = 0; - - if (!text || !params) { - ret = -1; - goto end; - } - - text->opt_print_trace_default_fields = 1; - text->opt_print_delta_field = 1; -end: - return ret; -} - -struct bt_plugin *bt_plugin_lib_create(struct bt_object *params) -{ - int ret; - struct bt_plugin *plugin = NULL; - struct ctf_text *text = g_new0(struct ctf_text, 1); - - /* Set default text output options */ - ret = text_init(text, params); - if (ret) { - goto error; - } - - plugin = bt_plugin_sink_create(plugin_name, text, - ctf_text_destroy, ctf_text_handle_notification); - if (!plugin) { - goto error; - } - -end: - return plugin; -error: - if (text) { - g_free(text); - } - goto end; + printf("in ctf_text_exit\n"); } -- 2.34.1