kernelshark: Adding infrastructure for GUI plugins
PATCH v2 1/4 kernelshark: Adding infrastructure for GUI plugins
Makefile modified in order to support building of GUI plugins.
kshark_plugin_loader and kshark_plugin_unloader are modified
kshark_plugin_reloader is defined and is called when the user loads a new trace data file.
--- Makefile | 31 ++++++++++-- kernel-shark.c | 150 +++++++++++++++++++++++++++++++++++++------------------- kshark-plugin.h | 22 ++++++++- 3 files changed, 146 insertions(+), 57 deletions(-)
Makefile +27 -4
@@ -293,6 +293,8 @@ else print_shared_lib_compile = echo ' $(GUI)COMPILE SHARED LIB '$(GOBJ); print_plugin_obj_compile = echo ' $(GUI)COMPILE PLUGIN OBJ '$(GOBJ); print_plugin_build = echo ' $(GUI)BUILD PLUGIN '$(GOBJ); + print_gui_plugin_obj_compile = echo ' $(GUI)COMPILE GUI_PLUGIN OBJ '$(GOBJ); + print_gui_plugin_build = echo ' $(GUI)BUILD GUI_PLUGIN '$(GOBJ); print_static_lib_build = echo ' $(GUI)BUILD STATIC LIB '$(GOBJ); print_install = echo ' $(GUI)INSTALL '$(GSPACE)$1' to $(DESTDIR_SQ)$2'; endif
@@ -317,6 +319,14 @@ do_plugin_build = \ ($(print_plugin_build) \ $(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $<) +do_compile_gui_plugin_obj = \ + ($(print_gui_plugin_obj_compile) \ + $(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $<) + +do_gui_plugin_build = \ + ($(print_gui_plugin_build) \ + $(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $<) + do_build_static_lib = \ ($(print_static_lib_build) \ $(RM) $@; $(AR) rcs $@ $^)
@@ -373,13 +383,17 @@ PLUGIN_OBJS += plugin_tlb.o PLUGINS := $(PLUGIN_OBJS:.o=.so) +GUI_PLUGIN_OBJS = + +GUI_PLUGINS := $(GUI_PLUGIN_OBJS:.o=.so) + ALL_OBJS = $(TRACE_CMD_OBJS) $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) \ - $(TRACE_GRAPH_MAIN_OBJS) $(TCMD_LIB_OBJS) $(PLUGIN_OBJS) + $(TRACE_GRAPH_MAIN_OBJS) $(TCMD_LIB_OBJS) $(PLUGIN_OBJS) $(GUI_PLUGIN_OBJS) CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h libparsevent.a $(LIB_FILE) \ trace-cmd $(PLUGINS) $(BUILD_PYTHON) -GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark +GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark $(GUI_PLUGINS) TARGETS = $(CMD_TARGETS) $(GUI_TARGETS)
@@ -401,7 +415,7 @@ gui: $(CMD_TARGETS) all_gui: $(GUI_TARGETS) show_gui_done -GUI_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS) +GUI_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS) $(GUI_PLUGIN_OBJS) gui_objs := $(sort $(GUI_OBJS))
@@ -447,6 +461,12 @@ $(PLUGIN_OBJS): %.o : $(src)/%.c $(PLUGINS): %.so: %.o $(Q)$(do_plugin_build) +$(GUI_PLUGIN_OBJS): %.o : $(src)/%.c + $(Q)$(do_compile_gui_plugin_obj) + +$(GUI_PLUGINS): %.so: %.o + $(Q)$(do_gui_plugin_build) + define make_version.h (echo '/* This file is automatically generated. Do not modify. */'; \ echo \#define VERSION_CODE $(shell \
@@ -549,7 +569,10 @@ cscope: force $(RM) cscope* find . -name '*.[ch]' | cscope -b -q -PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS)) +PLUGINS_INSTALL = +PLUGINS_INSTALL += $(subst .so,.install,$(PLUGINS)) +PLUGINS_INSTALL += $(subst .so,.install,$(GUI_PLUGINS)) +PLUGINS_INSTALL += $(subst .so,.install,$(PYTHON_PLUGINS)) define do_install $(print_install) \
kernel-shark.c +99 -51
186 lines not on this page · raw message
kshark-plugin.h +20 -2
@@ -17,19 +17,37 @@* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include <limits.h> + +#include "event-parse.h" +#ifndef _KSHARK_PLUGIN_H#define _KSHARK_PLUGIN_H#define KSHARK_PLUGIN_LOADER kshark_plugin_loader +#define KSHARK_PLUGIN_RELOADER kshark_plugin_reloader#define KSHARK_PLUGIN_UNLOADER kshark_plugin_unloader#define _MAKE_STR (x) #x#define MAKE_STR (x) _MAKE_STR(x)#define KSHARK_PLUGIN_LOADER_NAME MAKE_STR(KSHARK_PLUGIN_LOADER) +#define KSHARK_PLUGIN_RELOADER_NAME MAKE_STR(KSHARK_PLUGIN_RELOADER)#define KSHARK_PLUGIN_UNLOADER_NAME MAKE_STR(KSHARK_PLUGIN_UNLOADER) -typedef int (*kshark_plugin_load_func )(void *info); -typedef int (*kshark_plugin_unload_func )(void *info); +typedef int (*kshark_plugin_load_func )(void *info,void *store); +typedef int (*kshark_plugin_unload_func )(void *info,void *store); + +typedef int (*kshark_plugin_event_handler_func )(struct pevent_record *record, +int task_id, +void *val); + +typedef int (*kshark_plugin_context_update_func )(struct pevent *pevent,int task_id); +enum gui_plugin_actions { +KSHARK_PLUGIN_LOAD , +KSHARK_PLUGIN_RELOAD , +KSHARK_PLUGIN_UNLOAD , +};#endif
Signature · 1 line
2.15.0.rc0
PATCH v2 2/4 kernelshark: Adding a GUI event handler
gui_event_handler is defined. Instruments for dealing with this handler are added.
--- Makefile | 6 ++--- kshark-plugin.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ kshark-plugin.h | 22 ++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 kshark-plugin.c
Makefile +3 -3
@@ -348,17 +348,17 @@ $(obj)/%.o: $(src)/%.c $(Q)$(call check_gui) TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.o \ - trace-xml.o + trace-xml.o kshark-plugin.o TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \ trace-hash.o trace-profile.o trace-stream.o trace-record.o trace-restore.o \ trace-check-events.o trace-show.o trace-list.o -TRACE_VIEW_OBJS = trace-view.o trace-view-store.o +TRACE_VIEW_OBJS = trace-view.o trace-view-store.o kshark-plugin.o TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) \ - trace-capture.o kernel-shark.o + trace-capture.o kernel-shark.o kshark-plugin.o PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \
kshark-plugin.c new file +69 -0
69 lines not on this page · raw message
kshark-plugin.h +22 -0
@@ -50,4 +50,26 @@ enum gui_plugin_actions { KSHARK_PLUGIN_UNLOAD, }; +enum gui_event_types { +KSHARK_PLUGIN_SWITCH_EVENT , +KSHARK_PLUGIN_WAKEUP_EVENT , +}; + +struct gui_event_handler { +struct gui_event_handler *next; +int id; +int type; +kshark_plugin_event_handler_func event_func; +kshark_plugin_context_update_func context_func; +}; + +struct gui_event_handler *make_gui_event_handler (int event_id,int type, +kshark_plugin_event_handler_func evt_func, +kshark_plugin_context_update_func ctx_func); + +struct gui_event_handler *find_gui_event_handler (struct gui_event_handler *handlers, +int event_id); + +void unregister_gui_event_handler (struct gui_event_handler **handlers,int event_id); +#endif
Signature · 1 line
2.15.0.rc0
Re: [PATCH v2 2/4] kernelshark: Adding a GUI event handler
Quoted 2 lines · On Fri, 10 Nov 2017 14:29:13 +0200 "Yordan Karadzhov (VMware)"…
gui_event_handleris defined. Instruments for dealing with this handler are added.
Please add why this patch is needed in the change log.
Quoted 98 lines
Signed-off-by Yordan Karadzhov (VMware) <[email protected]>--- Makefile | 6 ++--- kshark-plugin.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ kshark-plugin.h | 22 ++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 kshark-plugin.cMakefile +3
-3@@ -348,17 +348,17 @@ $(obj)/%.o: $(src)/%.c $(Q)$(call check_gui) TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.o \ - trace-xml.o + trace-xml.o kshark-plugin.o TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \ trace-hash.o trace-profile.o trace-stream.o trace-record.o trace-restore.o \ trace-check-events.o trace-show.o trace-list.o -TRACE_VIEW_OBJS = trace-view.o trace-view-store.o +TRACE_VIEW_OBJS = trace-view.o trace-view-store.o kshark-plugin.o TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) \ - trace-capture.o kernel-shark.o + trace-capture.o kernel-shark.o kshark-plugin.o PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \kshark-plugin.c new file +58
-0@@ -0,0 +1,69 @@ +/* +* Copyright (C) 2017 VMware Inc, Yordan Karadzhov <[email protected]> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License (not later!) +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +#include <stdlib.h> + +#include "kshark-plugin.h" + +struct gui_event_handler *make_gui_event_handler (int event_id,int type, +kshark_plugin_event_handler_func evt_func, +kshark_plugin_context_update_func ctx_func) +{ +struct gui_event_handler *handler =malloc (sizeof (struct gui_event_handler )); + +if (!handler) +return NULL ; + + handler->next =NULL ; + handler->id = event_id; + handler->type = type; + handler->event_func = evt_func; + handler->context_func = ctx_func; + +return handler; +} + +struct gui_event_handler *find_gui_event_handler (struct gui_event_handler *handlers, +int event_id) +{ +while (handlers) { +if (handlers->id == event_id) +return handlers; + + handlers = handlers->next; + } + +return NULL ; +} + +void unregister_gui_event_handler (struct gui_event_handler **handlers,int event_id) +{ +struct gui_event_handler **last = handlers;
kshark-plugin.c line 68
Quoted 10 lines
kshark-plugin.c new file +10
-0+struct gui_event_handler *list; + +for (list = *handlers; list; list = list->next) { +if (list->id == event_id) { + *last = list->next; +return ; + } + + last = &list->next; + }
Is something suppose to free the gui_event_handler?
Should there be a matching register_gui_event_handler()?
-- Steve
Quoted 32 lines
kshark-plugin.c new file +1
-0+}kshark-plugin.h +22
-0@@ -50,4 +50,26 @@ enum gui_plugin_actions { KSHARK_PLUGIN_UNLOAD, }; +enum gui_event_types { +KSHARK_PLUGIN_SWITCH_EVENT , +KSHARK_PLUGIN_WAKEUP_EVENT , +}; + +struct gui_event_handler { +struct gui_event_handler *next; +int id; +int type; +kshark_plugin_event_handler_func event_func; +kshark_plugin_context_update_func context_func; +}; + +struct gui_event_handler *make_gui_event_handler (int event_id,int type, +kshark_plugin_event_handler_func evt_func, +kshark_plugin_context_update_func ctx_func); + +struct gui_event_handler *find_gui_event_handler (struct gui_event_handler *handlers, +int event_id); + +void unregister_gui_event_handler (struct gui_event_handler **handlers,int event_id); +#endif
PATCH v2 3/4 kernelshark: Adding gui_event_handlers for View and Graph
In reply to Yordan Karadzhov (VMware)gui_event_handlers are added to trace_view_store and graph_info. The handlers are used to execute plugin-specific actions during the processing of the trace data.
--- kshark-plugin.h | 3 +++ trace-graph.c | 41 +++++++++++++++++++++++++++++++++++++++++ trace-graph.h | 7 +++++++ trace-plot-task.c | 17 +++++++++++++---- trace-view-store.c | 16 ++++++++++++++++ trace-view-store.h | 5 +++++ 6 files changed, 85 insertions(+), 4 deletions(-)
kshark-plugin.h +3 -0
@@ -48,6 +48,9 @@ enum gui_plugin_actions {KSHARK_PLUGIN_LOAD ,KSHARK_PLUGIN_RELOAD ,KSHARK_PLUGIN_UNLOAD , +KSHARK_PLUGIN_GET_PID , +KSHARK_PLUGIN_GET_PREV_STATE , + KSHARK_PLUGIN_GET_COMMAND, }; enum gui_event_types {
trace-graph.c +41 -0
90 lines not on this page · raw message
trace-graph.h +7 -0
@@ -24,6 +24,7 @@#include "trace-cmd.h" #include "trace-filter-hash.h" #include "trace-xml.h" +#include "kshark-plugin.h" struct graph_info ;
@@ -258,6 +259,8 @@ struct graph_info {gint plot_data_y;gint plot_data_w;gint plot_data_h; + +struct gui_event_handler *event_handlers; };
@@ -266,6 +269,10 @@ trace_graph_create(struct tracecmd_input *handle);struct graph_info *trace_graph_create_with_callbacks (struct tracecmd_input *handle,struct graph_callbacks *cbs); + +void trace_graph_register_gui_handler (struct graph_info *info, +struct gui_event_handler *handler); +void trace_graph_select_by_time (struct graph_info *ginfo,guint64 time); void trace_graph_event_filter_callback(gboolean accept,
trace-plot-task.c +13 -4
@@ -68,11 +68,20 @@ static gboolean is_running(struct graph_info *ginfo, struct pevent_record *recorint id; id =pevent_data_type (ginfo->pevent, record); -if (id != ginfo->event_sched_switch_id) -return FALSE; -pevent_read_number_field (ginfo->event_prev_state, record->data, &val); -return val & ((1 <<11 ) -1 )? FALSE : TRUE; +if (id == ginfo->event_sched_switch_id) { +pevent_read_number_field (ginfo->event_prev_state, record->data, &val); +return val & ((1 <<11 ) -1 )? FALSE : TRUE; + } + +struct gui_event_handler *handler = +find_gui_event_handler (ginfo->event_handlers, id); +if (handler) { +if (handler->type ==KSHARK_PLUGIN_SWITCH_EVENT ) +return handler->event_func (record,KSHARK_PLUGIN_GET_PREV_STATE ,NULL ); + } + +return FALSE; } static gboolean record_matches_pid(struct graph_info *ginfo,
trace-view-store.c +16 -0
@@ -70,6 +70,12 @@ static gboolean trace_view_store_iter_parent (GtkTreeModel *tree_model,static GObjectClass *parent_class =NULL ;/* GObject stuff - nothing to worry about */ +void trace_view_store_register_gui_handler (TraceViewStore *store,struct gui_event_handler *handler) +{ + handler->next = store->event_handlers; + store->event_handlers = handler; +} +/***************************************************************************** * * trace_view_store_get_type: here we register our new type and its interfaces
@@ -866,6 +872,7 @@ trace_view_store_new (struct tracecmd_input *handle)g_assert ( newstore !=NULL ); + newstore->event_handlers =NULL ; newstore->handle = handle; newstore->cpus =tracecmd_cpus (handle);tracecmd_ref (handle);
@@ -1194,6 +1201,7 @@ static gboolean show_task(TraceViewStore *store, struct pevent *pevent, struct pevent_record *record, gint pid) {gint event_id; +struct gui_event_handler *ge_handler;if (view_task (store, pid))return TRUE;
@@ -1224,6 +1232,14 @@ static gboolean show_task(TraceViewStore *store, struct pevent *pevent,return TRUE; } + ge_handler =find_gui_event_handler (store->event_handlers, event_id); + +if (ge_handler) { +if (ge_handler->event_func (record,KSHARK_PLUGIN_GET_PID , &pid)) +if (view_task (store, pid)) +return TRUE; + } +return FALSE; }
trace-view-store.h +5 -0
@@ -23,6 +23,7 @@#include <gtk/gtk.h> #include "trace-cmd.h" #include "trace-filter-hash.h" +#include "kshark-plugin.h" /* Some boilerplate GObject defines. 'klass' is used * instead of 'class', because 'class' is a C++ keyword */
@@ -125,8 +126,12 @@ struct trace_view_storeguint64 *cpu_mask;/* cpus that are enabled */ gint stamp;/* Random integer to check whether an iter belongs to our model */ + +struct gui_event_handler *event_handlers; }; +void trace_view_store_register_gui_handler (TraceViewStore *store,struct gui_event_handler *handler); +gboolean trace_view_store_cpu_isset (TraceViewStore *store,gint cpu);void trace_view_store_set_all_cpus (TraceViewStore *store);
Signature · 1 line
2.15.0.rc0
Re: [PATCH v2 3/4] kernelshark: Adding gui_event_handlers for View and Graph
Quoted 5 lines · On Fri, 10 Nov 2017 14:29:14 +0200 "Yordan Karadzhov (VMware)"…
trace-view-store.c +5
-0+void trace_graph_register_gui_handler (struct graph_info *info, +struct gui_event_handler *handler) { + handler->next = info->event_handlers; + info->event_handlers = handler; +}
trace-view-store.c static gboolean trace_view_store_iter_parent (GtkTreeModel *tree_model, · line 78
Quoted 10 lines
trace-view-store.c +7
-0+ +void trace_view_store_register_gui_handler (TraceViewStore *store,struct gui_event_handler *handler) +{ + handler->next = store->event_handlers; + store->event_handlers = handler; +} +
Hmm, and in the last patch we have:
+ trace_view_store_register_gui_handler(ks_store, switch_handler);
+ trace_view_store_register_gui_handler(ks_store, wakeup_handler);
+
+ trace_graph_register_gui_handler(ks_info->ginfo, switch_handler);
+ trace_graph_register_gui_handler(ks_info->ginfo, wakeup_handler);
I think I see an issue here. ;-)
(Hint, what's the state of switch_handler->next and
wakeup_handler->next, when this is done?)
-- Steve
Re: [PATCH v2 3/4] kernelshark: Adding gui_event_handlers for View and Graph
Quoted 27 lines · Steven Rostedt
Quoted 4 lines · On Fri, 10 Nov 2017 14:29:14 +0200 "Yordan Karadzhov (VMware)"…
trace-view-store.c +4
-0+void trace_graph_register_gui_handler (struct graph_info *info, +struct gui_event_handler *handler) { + handler->next = info->event_handlers; + info->event_handlers = handler;trace-view-store.c static gboolean trace_view_store_iter_parent (GtkTreeModel *tree_model, · line 78
Quoted 10 lines
trace-view-store.c +8
-0+} + +void trace_view_store_register_gui_handler (TraceViewStore *store,struct gui_event_handler *handler) +{ + handler->next = store->event_handlers; + store->event_handlers = handler; +} +Hmm, and in the last patch we have:
(quoted diff) +5
-0+ trace_view_store_register_gui_handler(ks_store, switch_handler); + trace_view_store_register_gui_handler(ks_store, wakeup_handler); + + trace_graph_register_gui_handler(ks_info->ginfo, switch_handler); + trace_graph_register_gui_handler(ks_info->ginfo, wakeup_handler);
Quoted 4 lines
I think I see an issue here. ;-)
(Hint, what's the state of
switch_handler->nextand
wakeup_handler->next, when this is done?)
I see the issue now.
Thank you very much!
Yordan
Quoted 1 line
-- Steve
PATCH v2 4/4 kernelshark: Adding a GUI plugin for xenomai events
In reply to Yordan Karadzhov (VMware)A plugin for processing xenomai events "cobalt_switch_context" and "cobalt_thread_resume" is added.
--- Makefile | 1 + kshark-plugin.h | 10 ++ plugin_xenomai_gui.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+) create mode 100644 plugin_xenomai_gui.c
Makefile +1 -0
@@ -384,6 +384,7 @@ PLUGIN_OBJS += plugin_tlb.o PLUGINS := $(PLUGIN_OBJS:.o=.so) GUI_PLUGIN_OBJS = +GUI_PLUGIN_OBJS += plugin_xenomai_gui.o GUI_PLUGINS := $(GUI_PLUGIN_OBJS:.o=.so)
kshark-plugin.h +10 -0
@@ -53,6 +53,16 @@ enum gui_plugin_actions { KSHARK_PLUGIN_GET_COMMAND, }; +enum gui_plugin_ctx_updates { +KSHARK_PLUGIN_UPDATE_SWITCH_EVENT = (1 <<0 ), +KSHARK_PLUGIN_UPDATE_WAKEUP_EVENT = (1 <<1 ), +KSHARK_PLUGIN_UPDATE_WAKEUP_PID = (1 <<2 ), +KSHARK_PLUGIN_UPDATE_SWITCH_PID = (1 <<3 ), +KSHARK_PLUGIN_UPDATE_PREV_STATE = (1 <<4 ), +KSHARK_PLUGIN_UPDATE_NEXT_NAME = (1 <<5 ), +KSHARK_PLUGIN_UPDATE_ALL =INT_MAX +}; +enum gui_event_types {KSHARK_PLUGIN_SWITCH_EVENT ,KSHARK_PLUGIN_WAKEUP_EVENT ,
plugin_xenomai_gui.c new file +300 -0
300 lines not on this page · raw message
Signature · 1 line
2.15.0.rc0
Quoted 86 lines · On Fri, 10 Nov 2017 14:29:12 +0200 "Yordan Karadzhov (VMware)"…
kernel-shark.c +80
-0@@ -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)) {
kernel-shark.c int kernelshark_load_file(struct shark_info *info, const char *file) · line 431
Quoted 10 lines
kernel-shark.c +10
-0+ 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
Quoted 68 lines
kernel-shark.c +3
-50static 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); - } -}