All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin
@ 2022-02-16  8:29 Yordan Karadzhov (VMware)
  2022-02-16  8:29 ` [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp Yordan Karadzhov (VMware)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yordan Karadzhov (VMware) @ 2022-02-16  8:29 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: hongzhan.chen, jan.kiszka, Yordan Karadzhov (VMware)

Yordan Karadzhov (VMware) (2):
  kernel-shark: Add KsPluginsGUI.hpp/.cpp
  kernel-shark: Load 'ctrl' interface for user plugins

 src/CMakeLists.txt   |  5 +++++
 src/KsPluginsGUI.cpp | 27 +++++++++++++++++++++++++++
 src/KsPluginsGUI.hpp | 22 ++++++++++++++++++++++
 src/KsUtils.cpp      | 35 +++++++++++++++++++++++++----------
 src/KsUtils.hpp      |  2 ++
 5 files changed, 81 insertions(+), 10 deletions(-)
 create mode 100644 src/KsPluginsGUI.cpp
 create mode 100644 src/KsPluginsGUI.hpp

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp
  2022-02-16  8:29 [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov (VMware)
@ 2022-02-16  8:29 ` Yordan Karadzhov (VMware)
  2022-02-16  8:29 ` [PATCH 2/2] kernel-shark: Load 'ctrl' interface for user plugins Yordan Karadzhov (VMware)
  2022-02-21 12:31 ` [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov
  2 siblings, 0 replies; 4+ messages in thread
From: Yordan Karadzhov (VMware) @ 2022-02-16  8:29 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: hongzhan.chen, jan.kiszka, Yordan Karadzhov (VMware)

Here we will place all GUI-related APIs that will be exposed to
the external plugins. For the moment we add only two such APIs
that will allow the plugins to manipulate the markers.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/CMakeLists.txt   |  5 +++++
 src/KsPluginsGUI.cpp | 27 +++++++++++++++++++++++++++
 src/KsPluginsGUI.hpp | 22 ++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 src/KsPluginsGUI.cpp
 create mode 100644 src/KsPluginsGUI.hpp

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fbf3819..0ee62c8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -105,6 +105,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                                                             KsTraceGraph.cpp
                                                             KsTraceViewer.cpp
                                                             KsMainWindow.cpp
+                                                            KsPluginsGUI.cpp
                                                             KsCaptureDialog.cpp
                                                             KsQuickContextMenu.cpp
                                                             KsAdvFilteringDialog.cpp)
@@ -147,6 +148,10 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
             DESTINATION ${_INSTALL_PREFIX}/bin/
                 COMPONENT                 kernelshark)
 
+    install(FILES "${KS_DIR}/src/KsPluginsGUI.hpp"
+            DESTINATION ${KS_INCLUDS_DESTINATION}
+                COMPONENT libkshark-devel)
+
     add_subdirectory(plugins)
     set(PLUGINS ${PLUGINS} PARENT_SCOPE)
 
diff --git a/src/KsPluginsGUI.cpp b/src/KsPluginsGUI.cpp
new file mode 100644
index 0000000..a964510
--- /dev/null
+++ b/src/KsPluginsGUI.cpp
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright 2022 VMware Inc, Yordan Karadzhov (VMware) <y.karadz@gmail.com>
+ */
+
+/**
+  *  @file    KsPluginsGUI.cpp
+  *  @brief   KernelShark C++ plugin declarations.
+  */
+
+// KernelShark
+#include "KsPluginsGUI.hpp"
+#include "KsMainWindow.hpp"
+#include "KsDualMarker.hpp"
+
+void markEntryA(void *ks_ptr, const kshark_entry *e)
+{
+	KsMainWindow *ks = static_cast<KsMainWindow *>(ks_ptr);
+	ks->markEntry(e, DualMarkerState::A);
+}
+
+void markEntryB(void *ks_ptr, const kshark_entry *e)
+{
+	KsMainWindow *ks = static_cast<KsMainWindow *>(ks_ptr);
+	ks->markEntry(e, DualMarkerState::B);
+}
diff --git a/src/KsPluginsGUI.hpp b/src/KsPluginsGUI.hpp
new file mode 100644
index 0000000..808a951
--- /dev/null
+++ b/src/KsPluginsGUI.hpp
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+
+/*
+ * Copyright 2022 VMware Inc, Yordan Karadzhov <y.karadz@gmail.com>
+ */
+
+/**
+  *  @file    KsPluginsGUI.hpp
+  *  @brief   KernelShark C++ plugin declarations.
+  */
+
+#ifndef _KS_PLUGINS_GUI_H
+#define _KS_PLUGINS_GUI_H
+
+// KernelShark
+#include "libkshark.h"
+
+void markEntryA(void *ks_ptr, const kshark_entry *e);
+
+void markEntryB(void *ks_ptr, const kshark_entry *e);
+
+#endif
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] kernel-shark: Load 'ctrl' interface for user plugins
  2022-02-16  8:29 [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov (VMware)
  2022-02-16  8:29 ` [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp Yordan Karadzhov (VMware)
@ 2022-02-16  8:29 ` Yordan Karadzhov (VMware)
  2022-02-21 12:31 ` [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov
  2 siblings, 0 replies; 4+ messages in thread
From: Yordan Karadzhov (VMware) @ 2022-02-16  8:29 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: hongzhan.chen, jan.kiszka, Yordan Karadzhov (VMware)

Currently, the 'ctrl' interface of all plugins gets called in the
constructor of the MainWindow widget. This works well for the built-in
plugins because the list of those plugins is known in advance. However,
the list of user plugins is populated dynamically, hence it is not known
by the time the constructor of the widget is called. The problem is
solved by making sure we call the 'ctrl' interface every time we load
a user plugin from the menus of the GUI or at start as a command line
option.

Reported-by: Hongzhan Chen <hongzhan.chen@intel.com>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/KsUtils.cpp | 35 +++++++++++++++++++++++++----------
 src/KsUtils.hpp |  2 ++
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/KsUtils.cpp b/src/KsUtils.cpp
index a22c445..e3e16ae 100644
--- a/src/KsUtils.cpp
+++ b/src/KsUtils.cpp
@@ -1190,6 +1190,20 @@ QVector<int> KsPluginManager::getPluginsByStatus(int sd, int status) const
 	return vec;
 }
 
+void KsPluginManager::_registerCtrlInterface(kshark_plugin_list *plugin)
+{
+	if (!plugin->handle || !plugin->ctrl_interface)
+		return;
+
+	void *dialogPtr = plugin->ctrl_interface(parent());
+	if (dialogPtr) {
+		QWidget *dialog = static_cast<QWidget *>(dialogPtr);
+
+		if (dialog && _pluginDialogs.indexOf(dialog) < 0)
+			_pluginDialogs.append(dialog);
+	}
+}
+
 /**
  * @brief Loop over the registered plugins and register all plugin-defined
  *	  menus (if any).
@@ -1203,14 +1217,7 @@ void KsPluginManager::registerPluginMenues()
 		return;
 
 	for (plugin = kshark_ctx->plugins; plugin; plugin = plugin->next)
-		if (plugin->handle && plugin->ctrl_interface) {
-			void *dialogPtr = plugin->ctrl_interface(parent());
-			if (dialogPtr) {
-				QWidget *dialog =
-					static_cast<QWidget *>(dialogPtr);
-				_pluginDialogs.append(dialog);
-			}
-		}
+		_registerCtrlInterface(plugin);
 }
 
 std::string KsPluginManager::_pluginLibFromName(const QString &plugin)
@@ -1247,11 +1254,17 @@ std::string KsPluginManager::_pluginNameFromLib(const QString &plugin)
  * @param pluginNames: Provide here the names of the plugin (as in the
  *		       CMake-generated header file) or the names of the
  *		       plugin's library files (.so including path).
- * 		       The names must be comma separated.
+ *		       The names must be comma separated.
  */
 void KsPluginManager::registerPlugins(const QString &pluginNames)
 {
-	_userPlugins.append(_loadPluginList(pluginNames.split(',')));
+	QVector<kshark_plugin_list *> plugins;
+
+	plugins = _loadPluginList(pluginNames.split(','));
+	for (auto const &p: plugins)
+		_registerCtrlInterface(p);
+
+	_userPlugins.append(plugins);
 }
 
 /**
@@ -1369,6 +1382,8 @@ void KsPluginManager::addPlugins(const QStringList &fileNames,
 		return;
 
 	plugins = _loadPluginList(fileNames);
+	for (auto const &p: plugins)
+		_registerCtrlInterface(p);
 	_userPlugins.append(plugins);
 
 	if (streamIds.isEmpty())
diff --git a/src/KsUtils.hpp b/src/KsUtils.hpp
index 1a97d9e..e42b6da 100644
--- a/src/KsUtils.hpp
+++ b/src/KsUtils.hpp
@@ -330,6 +330,8 @@ private:
 	QVector<kshark_plugin_list *>
 	_loadPluginList(const QStringList &plugins);
 
+	void _registerCtrlInterface(kshark_plugin_list *plugin);
+
 	std::string _pluginLibFromName(const QString &plugin);
 
 	std::string _pluginNameFromLib(const QString &plugin);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin
  2022-02-16  8:29 [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov (VMware)
  2022-02-16  8:29 ` [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp Yordan Karadzhov (VMware)
  2022-02-16  8:29 ` [PATCH 2/2] kernel-shark: Load 'ctrl' interface for user plugins Yordan Karadzhov (VMware)
@ 2022-02-21 12:31 ` Yordan Karadzhov
  2 siblings, 0 replies; 4+ messages in thread
From: Yordan Karadzhov @ 2022-02-21 12:31 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: hongzhan.chen, jan.kiszka

Hi Hongzan and Jan,

The modifications needed by the plugin are now upstream and I would like to ask you to do one last thing. When you are 
ready with the plugin and its stand-alone repo, please send me a patch, adding to the README file of kernelshark a short 
description of your plugin (couple of sentences) and a link for its repo. This way others can take ideas and inspiration 
from what you did.

thanks!
Yordan

On 16.02.22 г. 10:29 ч., Yordan Karadzhov (VMware) wrote:
> Yordan Karadzhov (VMware) (2):
>    kernel-shark: Add KsPluginsGUI.hpp/.cpp
>    kernel-shark: Load 'ctrl' interface for user plugins
> 
>   src/CMakeLists.txt   |  5 +++++
>   src/KsPluginsGUI.cpp | 27 +++++++++++++++++++++++++++
>   src/KsPluginsGUI.hpp | 22 ++++++++++++++++++++++
>   src/KsUtils.cpp      | 35 +++++++++++++++++++++++++----------
>   src/KsUtils.hpp      |  2 ++
>   5 files changed, 81 insertions(+), 10 deletions(-)
>   create mode 100644 src/KsPluginsGUI.cpp
>   create mode 100644 src/KsPluginsGUI.hpp
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-21 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16  8:29 [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov (VMware)
2022-02-16  8:29 ` [PATCH 1/2] kernel-shark: Add KsPluginsGUI.hpp/.cpp Yordan Karadzhov (VMware)
2022-02-16  8:29 ` [PATCH 2/2] kernel-shark: Load 'ctrl' interface for user plugins Yordan Karadzhov (VMware)
2022-02-21 12:31 ` [PATCH 0/2] kernel-shark: Fixes needed by the Xenomai plugin Yordan Karadzhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.