@@ -544,13 +544,12 @@ void KsPluginManager::_parsePluginList()
*/
void KsPluginManager::registerFromList(kshark_context *kshark_ctx)
{
- auto lamRegBuiltIn = [&kshark_ctx](const QString &plugin)
+ auto lamRegBuiltIn = [&kshark_ctx, this](const QString &plugin)
{
char *lib;
int n;
- n = asprintf(&lib, "%s/lib/plugin-%s.so",
- KS_DIR, plugin.toStdString().c_str());
+ lib = _pluginLibFromName(plugin, n);
if (n <= 0)
return;
@@ -579,13 +578,12 @@ void KsPluginManager::registerFromList(kshark_context *kshark_ctx)
*/
void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx)
{
- auto lamUregBuiltIn = [&kshark_ctx](const QString &plugin)
+ auto lamUregBuiltIn = [&kshark_ctx, this](const QString &plugin)
{
char *lib;
int n;
- n = asprintf(&lib, "%s/lib/plugin-%s.so",
- KS_DIR, plugin.toStdString().c_str());
+ lib = _pluginLibFromName(plugin, n);
if (n <= 0)
return;
@@ -608,6 +606,26 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx)
lamUregUser);
}
+char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n)
+{
+ QString appPath = QCoreApplication::applicationDirPath();
+ QString libPath = appPath + "/../../kernel-shark/lib";
+ std::string pluginStr = plugin.toStdString();
+ char *lib;
+
+ libPath = QDir::cleanPath(libPath);
+ if (!KsUtils::isInstalled() && QDir(libPath).exists()) {
+ std::string pathStr = libPath.toStdString();
+ n = asprintf(&lib, "%s/plugin-%s.so",
+ pathStr.c_str(), pluginStr.c_str());
+ } else {
+ n = asprintf(&lib, "%s/lib/kshark/plugins/plugin-%s.so",
+ _INSTALL_PREFIX, pluginStr.c_str());
+ }
+
+ return lib;
+}
+
/**
* @brief Register a Plugin.
*
@@ -629,8 +647,7 @@ void KsPluginManager::registerPlugin(const QString &plugin)
* The argument is the name of the plugin. From the
* name get the library .so file.
*/
- n = asprintf(&lib, "%s/lib/plugin-%s.so",
- KS_DIR, plugin.toStdString().c_str());
+ lib = _pluginLibFromName(plugin, n);
if (n > 0) {
kshark_register_plugin(kshark_ctx, lib);
_registeredKsPlugins[i] = true;
@@ -691,8 +708,7 @@ void KsPluginManager::unregisterPlugin(const QString &plugin)
* The argument is the name of the plugin. From the
* name get the library .so file.
*/
- n = asprintf(&lib, "%s/lib/plugin-%s.so", KS_DIR,
- plugin.toStdString().c_str());
+ lib = _pluginLibFromName(plugin, n);
if (n > 0) {
kshark_unregister_plugin(kshark_ctx, lib);
_registeredKsPlugins[i] = false;
@@ -700,7 +716,7 @@ void KsPluginManager::unregisterPlugin(const QString &plugin)
}
return;
- } else if (plugin.contains("/lib/plugin-" +
+ } else if (plugin.contains("/lib/plugin-" +
_ksPluginList[i], Qt::CaseInsensitive)) {
/*
* The argument is the name of the library .so file.
@@ -241,6 +241,8 @@ signals:
private:
void _parsePluginList();
+ char *_pluginLibFromName(const QString &plugin, int &n);
+
template <class T>
void _forEachInList(const QStringList &pl,
const QVector<bool> ®,
@@ -29,6 +29,6 @@ BUILD_PLUGIN(NAME missed_events
list(APPEND PLUGIN_LIST "missed_events default") # This plugin will be loaded by default
install(TARGETS sched_events missed_events
- LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/)
+ LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/plugins/)
set(PLUGINS ${PLUGIN_LIST} PARENT_SCOPE)