Message ID | 20190308171405.15266-2-ykaradzhov@vmware.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add dialog for loading user-defined plugins | expand |
On Fri, Mar 8, 2019 at 7:14 PM Yordan Karadzhov <ykaradzhov@vmware.com> wrote: > > The method can be used to register and load a user-defined plugin. > All other previously loaded plugins will be reloaded. > > Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> > --- > kernel-shark/src/KsUtils.cpp | 17 +++++++++++++++++ > kernel-shark/src/KsUtils.hpp | 3 +++ > 2 files changed, 20 insertions(+) > > diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp > index d7b1753..4d05bda 100644 > --- a/kernel-shark/src/KsUtils.cpp > +++ b/kernel-shark/src/KsUtils.cpp > @@ -596,6 +596,23 @@ void KsPluginManager::unregisterPlugin(const QString &plugin) > } > } > > +/** @brief Add to the list and load a user-provided plugin. All other > + * previously loaded plugins will be reloaded. > + * > + * @param fileName: the library file (.so) of the plugin. > +*/ > +void KsPluginManager::addPlugin(const QString &fileName) > +{ > + kshark_context *kshark_ctx(nullptr); > + > + if (!kshark_instance(&kshark_ctx)) > + return; > + > + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_CLOSE); > + registerPlugin(fileName); > + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_INIT); > +} Calling addPlugin() several times in a row will reinitialize all already registered plugins several times and lead to quadratic complexity. This seems wrong to me. Maybe we should split adding plugins from (re-)initializing them so that one can add several plugins and then have initialized once when they are actually needed to run. Wdyt? --Slavi > + > /** Unload all plugins. */ > void KsPluginManager::unloadAll() > { > diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp > index cb95b4f..ae7f6d1 100644 > --- a/kernel-shark/src/KsUtils.hpp > +++ b/kernel-shark/src/KsUtils.hpp > @@ -210,6 +210,9 @@ public: > > void registerPlugin(const QString &plugin); > void unregisterPlugin(const QString &plugin); > + > + void addPlugin(const QString &fileName); > + > void unloadAll(); > > void updatePlugins(QVector<int> pluginId); > -- > 2.19.1 >
On 11.03.19 г. 14:31 ч., Slavomir Kaslev wrote: > On Fri, Mar 8, 2019 at 7:14 PM Yordan Karadzhov <ykaradzhov@vmware.com> wrote: >> >> The method can be used to register and load a user-defined plugin. >> All other previously loaded plugins will be reloaded. >> >> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> >> --- >> kernel-shark/src/KsUtils.cpp | 17 +++++++++++++++++ >> kernel-shark/src/KsUtils.hpp | 3 +++ >> 2 files changed, 20 insertions(+) >> >> diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp >> index d7b1753..4d05bda 100644 >> --- a/kernel-shark/src/KsUtils.cpp >> +++ b/kernel-shark/src/KsUtils.cpp >> @@ -596,6 +596,23 @@ void KsPluginManager::unregisterPlugin(const QString &plugin) >> } >> } >> >> +/** @brief Add to the list and load a user-provided plugin. All other >> + * previously loaded plugins will be reloaded. >> + * >> + * @param fileName: the library file (.so) of the plugin. >> +*/ >> +void KsPluginManager::addPlugin(const QString &fileName) >> +{ >> + kshark_context *kshark_ctx(nullptr); >> + >> + if (!kshark_instance(&kshark_ctx)) >> + return; >> + >> + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_CLOSE); >> + registerPlugin(fileName); >> + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_INIT); >> +} > > Calling addPlugin() several times in a row will reinitialize all > already registered plugins several times and lead to quadratic > complexity. This seems wrong to me. > > Maybe we should split adding plugins from (re-)initializing them so > that one can add several plugins and then have initialized once when > they are actually needed to run. Wdyt? > Hi Slavi, KsPluginManager is a helper class for the GUI. It only does what the GUI is supposed to do. Currently the dialog that allows to load user plugins provides loading only one plugin at a time, so the KsPluginManager provides only this functionality. So the questions is: do we want a dialog that loads multiple plugins with one click? On the other hand we do encourage the users to use the KernelShark library for making custom applications. This is the motivation for having the C API, but KsPluginManager it is not part of this API. KsPluginManager operates on top of the API and is intended to be used only by the GUI code. Indeed the C API itself separates adding plugins from there initializing. Thanks a lot! Y. > --Slavi > >> + >> /** Unload all plugins. */ >> void KsPluginManager::unloadAll() >> { >> diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp >> index cb95b4f..ae7f6d1 100644 >> --- a/kernel-shark/src/KsUtils.hpp >> +++ b/kernel-shark/src/KsUtils.hpp >> @@ -210,6 +210,9 @@ public: >> >> void registerPlugin(const QString &plugin); >> void unregisterPlugin(const QString &plugin); >> + >> + void addPlugin(const QString &fileName); >> + >> void unloadAll(); >> >> void updatePlugins(QVector<int> pluginId); >> -- >> 2.19.1 >> > >
On Mon, 11 Mar 2019 17:39:11 +0000 Yordan Karadzhov <ykaradzhov@vmware.com> wrote: > > Calling addPlugin() several times in a row will reinitialize all > > already registered plugins several times and lead to quadratic > > complexity. This seems wrong to me. > > > > Maybe we should split adding plugins from (re-)initializing them so > > that one can add several plugins and then have initialized once when > > they are actually needed to run. Wdyt? > > > > Hi Slavi, > > KsPluginManager is a helper class for the GUI. It only does what the GUI > is supposed to do. Currently the dialog that allows to load user plugins > provides loading only one plugin at a time, so the KsPluginManager > provides only this functionality. > > So the questions is: do we want a dialog that loads multiple plugins > with one click? What would be the issue with allowing that? > > On the other hand we do encourage the users to use the KernelShark > library for making custom applications. This is the motivation for > having the C API, but KsPluginManager it is not part of this API. > KsPluginManager operates on top of the API and is intended to be used > only by the GUI code. > > Indeed the C API itself separates adding plugins from there initializing. Just like clicking the plugin dialog, where you select the plugins to add or remove and hit apply. Couldn't this be the same, or am I missing something? -- Steve
diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index d7b1753..4d05bda 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -596,6 +596,23 @@ void KsPluginManager::unregisterPlugin(const QString &plugin) } } +/** @brief Add to the list and load a user-provided plugin. All other + * previously loaded plugins will be reloaded. + * + * @param fileName: the library file (.so) of the plugin. +*/ +void KsPluginManager::addPlugin(const QString &fileName) +{ + kshark_context *kshark_ctx(nullptr); + + if (!kshark_instance(&kshark_ctx)) + return; + + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_CLOSE); + registerPlugin(fileName); + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_INIT); +} + /** Unload all plugins. */ void KsPluginManager::unloadAll() { diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index cb95b4f..ae7f6d1 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -210,6 +210,9 @@ public: void registerPlugin(const QString &plugin); void unregisterPlugin(const QString &plugin); + + void addPlugin(const QString &fileName); + void unloadAll(); void updatePlugins(QVector<int> pluginId);
The method can be used to register and load a user-defined plugin. All other previously loaded plugins will be reloaded. Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark/src/KsUtils.cpp | 17 +++++++++++++++++ kernel-shark/src/KsUtils.hpp | 3 +++ 2 files changed, 20 insertions(+)