From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] kernelshark: Adding infrastructure for GUI plugins
Date: Fri, 10 Nov 2017 09:23:36 -0500 [thread overview]
Message-ID: <20171110092336.5ea1c99a@gandalf.local.home> (raw)
In-Reply-To: <20171110122915.24929-1-y.karadz@gmail.com>
On Fri, 10 Nov 2017 14:29:12 +0200
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> --- a/kernel-shark.c
> +++ b/kernel-shark.c
> @@ -339,6 +339,96 @@ int kernelshark_load_file(struct shark_info *info, const char *file)
> return 0;
> }
>
> +static struct plugin_list {
> + struct plugin_list *next;
> + const char *file;
> +} *plugins;
> +static struct plugin_list **plugin_next = &plugins;
> +
> +static void add_plugin(const char *file)
> +{
> + struct stat st;
> + int ret;
> +
> + ret = stat(file, &st);
> + if (ret < 0) {
> + warning("plugin %s not found", file);
> + return;
> + }
> +
> + *plugin_next = calloc(sizeof(struct plugin_list), 1);
> + if (!*plugin_next) {
> + warning("failed to allocat memory for plugin");
> + return;
> + }
> +
> + (*plugin_next)->file = file;
> + plugin_next = &(*plugin_next)->next;
> +}
> +
> +static void handle_plugins(struct shark_info *info,
> + struct trace_view_store *store,
> + int task_id)
> +{
> + kshark_plugin_load_func func;
> + struct plugin_list *plugin;
> + void *handle;
> + char* func_name;
> + int fn_size = 0;
> +
> + switch (task_id) {
> + case KSHARK_PLUGIN_LOAD:
> + fn_size = asprintf(&func_name, KSHARK_PLUGIN_LOADER_NAME);
> + break;
> +
> + case KSHARK_PLUGIN_RELOAD:
> + fn_size = asprintf(&func_name, KSHARK_PLUGIN_RELOADER_NAME);
> + break;
> +
> + case KSHARK_PLUGIN_UNLOAD:
> + fn_size = asprintf(&func_name, KSHARK_PLUGIN_UNLOADER_NAME);
> + break;
> +
> + default:
> + return;
> + }
> +
> + if (fn_size <= 0) {
> + warning("failed to allocat memory for plugin function name");
> + return;
> + }
> +
> + for (plugin = plugins; plugin; plugin = plugin->next) {
> + handle = dlopen(plugin->file, RTLD_NOW | RTLD_GLOBAL);
> +
> + if (!handle) {
> + warning("cound not load plugin '%s'\n%s\n",
> + plugin->file, dlerror());
> + continue;
> + }
> +
> + func = dlsym(handle, func_name);
> + if (!func) {
> + warning("cound not find func '%s' in plugin '%s'\n%s\n",
> + func_name, plugin->file, dlerror());
> + continue;
> + }
> +
> + func(info, store);
> + }
> +
> + if (task_id == KSHARK_PLUGIN_UNLOAD) {
> + while ((plugin = plugins)) {
> + plugins = plugin->next;
> + free(plugin);
> + }
> +
> + plugin_next = &plugins;
> + }
> +
> + free(func_name);
> +}
> +
Break the move of the above functions into their own patch first, then
it is easier to see what changed here.
-- Steve
> static void
> /* Callback for the clicked signal of the Load button */
> load_clicked (gpointer data)
> @@ -353,6 +443,9 @@ load_clicked (gpointer data)
>
> kernelshark_load_file(info, filename);
>
> + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(info->treeview));
> + handle_plugins(info, TRACE_VIEW_STORE(model), KSHARK_PLUGIN_RELOAD);
> +
> g_free(filename);
> }
>
> @@ -1805,56 +1898,6 @@ button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
> return FALSE;
> }
>
> -static struct plugin_list {
> - struct plugin_list *next;
> - const char *file;
> -} *plugins;
> -static struct plugin_list **plugin_next = &plugins;
> -
> -static void add_plugin(const char *file)
> -{
> - struct stat st;
> - int ret;
> -
> - ret = stat(file, &st);
> - if (ret < 0) {
> - warning("plugin %s not found", file);
> - return;
> - }
> -
> - *plugin_next = calloc(sizeof(struct plugin_list), 1);
> - if (!*plugin_next)
> - die("failed to allocat memory for plugin");
> -
> - (*plugin_next)->file = file;
> - plugin_next = &(*plugin_next)->next;
> -}
> -
> -static void handle_plugins(struct shark_info *info)
> -{
> - kshark_plugin_load_func func;
> - struct plugin_list *plugin;
> - void *handle;
> -
> - while ((plugin = plugins)) {
> - plugins = plugin->next;
> -
> - handle = dlopen(plugin->file, RTLD_NOW | RTLD_GLOBAL);
> - free(plugin);
> - if (!handle) {
> - warning("cound not load plugin '%s'\n%s\n",
> - plugin->file, dlerror());
> - continue;
> - }
> - func = dlsym(handle, KSHARK_PLUGIN_LOADER_NAME);
> - if (!func) {
> - warning("cound not find func '%s' in plugin '%s'\n%s\n",
> - KSHARK_PLUGIN_LOADER_NAME, plugin->file, dlerror());
> - continue;
> - }
> - func(info);
> - }
> -}
>
prev parent reply other threads:[~2017-11-10 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 12:29 Yordan Karadzhov (VMware)
2017-11-10 12:29 ` [PATCH v2 2/4] kernelshark: Adding a GUI event handler Yordan Karadzhov (VMware)
2017-11-10 14:27 ` Steven Rostedt
2017-11-10 12:29 ` [PATCH v2 3/4] kernelshark: Adding gui_event_handlers for View and Graph Yordan Karadzhov (VMware)
2017-11-10 15:28 ` Steven Rostedt
2017-11-10 17:58 ` Yordan Karadzhov
2017-11-10 12:29 ` [PATCH v2 4/4] kernelshark: Adding a GUI plugin for xenomai events Yordan Karadzhov (VMware)
2017-11-10 14:23 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171110092336.5ea1c99a@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=jan.kiszka@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®