lkml.org 
[lkml]   [2017]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/4] kernelshark: Adding a GUI event handler
On Fri, 10 Nov 2017 14:29:13 +0200
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> gui_event_handler is defined. Instruments for dealing
> with this handler are added.

Please add why this patch is needed in the change log.

>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
> Makefile | 6 ++---
> kshark-plugin.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> kshark-plugin.h | 22 ++++++++++++++++++
> 3 files changed, 94 insertions(+), 3 deletions(-)
> create mode 100644 kshark-plugin.c
>
> diff --git a/Makefile b/Makefile
> index 8d0f16f..992e6b0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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 \
> diff --git a/kshark-plugin.c b/kshark-plugin.c
> new file mode 100644
> index 0000000..6532512
> --- /dev/null
> +++ b/kshark-plugin.c
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright (C) 2017 VMware Inc, Yordan Karadzhov <y.karadz@gmail.com>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + * 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;
> + 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

> +}
> diff --git a/kshark-plugin.h b/kshark-plugin.h
> index 81c09b5..d65ee02 100644
> --- a/kshark-plugin.h
> +++ b/kshark-plugin.h
> @@ -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

\
 
 \ /
  Last update: 2017-11-10 15:28    [W:0.265 / U:6.708 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site