mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2 2/4] kernelshark: Adding a GUI event handler
Date: Fri, 10 Nov 2017 14:29:13 +0200	[thread overview]
Message-ID: <20171110122915.24929-2-y.karadz@gmail.com> (raw)
In-Reply-To: <20171110122915.24929-1-y.karadz@gmail.com>

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

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;
+	}
+}
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
-- 
2.15.0.rc0

  reply	other threads:[~2017-11-10 12:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 12:29 [PATCH v2 1/4] kernelshark: Adding infrastructure for GUI plugins Yordan Karadzhov (VMware)
2017-11-10 12:29 ` Yordan Karadzhov (VMware) [this message]
2017-11-10 14:27   ` [PATCH v2 2/4] kernelshark: Adding a GUI event handler 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 ` [PATCH v2 1/4] kernelshark: Adding infrastructure for GUI plugins Steven Rostedt

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=20171110122915.24929-2-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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®