kernel-shark: Fixes needed by the Xenomai plugin
cover kernel-shark: Fixes needed by the Xenomai plugin
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
Signature · 1 line
2.32.0
PATCH 1/2 kernel-shark: Add KsPluginsGUI.hpp/.cpp
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.
--- 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
src/CMakeLists.txt +5 -0
@@ -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)
src/KsPluginsGUI.cpp new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: LGPL-2.1 + +/* + * Copyright 2022 VMware Inc, Yordan Karadzhov (VMware) <[email protected]> + */ + +/** + * @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); +}
src/KsPluginsGUI.hpp new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ + +/* + * Copyright 2022 VMware Inc, Yordan Karadzhov <[email protected]> + */ + +/** + * @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
Signature · 1 line
2.32.0
PATCH 2/2 kernel-shark: Load 'ctrl' interface for user plugins
In reply to 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.
--- src/KsUtils.cpp | 35 +++++++++++++++++++++++++---------- src/KsUtils.hpp | 2 ++ 2 files changed, 27 insertions(+), 10 deletions(-)
src/KsUtils.cpp +25 -10
@@ -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())
src/KsUtils.hpp +2 -0
@@ -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);
Signature · 1 line
2.32.0
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
Quoted 13 lines · Yordan Karadzhov (VMware)
Yordan Karadzhov (VMware) (2):
kernel-shark: Add KsPluginsGUI.hpp/.cpp
kernel-shark: Load 'ctrl' interface for user pluginssrc/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