Skip to contentSkip to conversation

Modifications needed for KS 1.0

PATCH In review Yordan Karadzhov 3 participants 13 messages May 2, 2019 – May 4, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Modifications needed for KS 1.0

The patch-set contains reimplementation (almost from scratch) of patches that have been sent already. The aims is to optimize the workflow of the user when running the application from its build (source code) location or installation location.

Changes in v2:
- Patches 6, 7 and 8 are new and are based on the suggestions made by Troy Engel in his review of v1.

Yordan Karadzhov (8):
kernel-shark: Add INSTALL PREFIX to the Cmake-generated header file.
kernel-shark: Add logic for the initial path of Open-File dialogs
kernel-shark: Add logic for the plugins search path
kernel-shark: Remove the definition of KS_DIR
kernel-shark: Remember the paths used by the Open-File dialogs.
kernel-shark: Add logic for selecting the trace-cmd executable used
kernel-shark: Remove hard-coded install paths for libraries and
plugins
kernel-shark: Use XDG compliant path when saving cached data

 kernel-shark/CMakeLists.txt             |   7 +-
 kernel-shark/build/deff.h.cmake         |   7 +-
 kernel-shark/src/CMakeLists.txt         |  12 +-
 kernel-shark/src/KsCaptureDialog.cpp    |  41 +++---
 kernel-shark/src/KsCaptureDialog.hpp    |   2 +
 kernel-shark/src/KsMainWindow.cpp       |  87 ++++++-------
 kernel-shark/src/KsMainWindow.hpp       |   6 +-
 kernel-shark/src/KsUtils.cpp            | 161 ++++++++++++++++++++++--
 kernel-shark/src/KsUtils.hpp            |  21 ++++
 kernel-shark/src/plugins/CMakeLists.txt |   3 +-
 10 files changed, 255 insertions(+), 92 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/8 kernel-shark: Add INSTALL PREFIX to the Cmake-generated header file.

To be used to check if the aplication runs from its installation location.

---
 kernel-shark/build/deff.h.cmake | 3 +++
 1 file changed, 3 insertions(+)
kernel-shark/build/deff.h.cmake +3 -0
index 8041cfc..ba211f4 100644
@@ -14,6 +14,9 @@
 /** KernelShark source code path. */
 #cmakedefine KS_DIR "@KS_DIR@"
 
+/** KernelShark installation prefix path. */
+#cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@"
+
 /** Location of the trace-cmd executable. */
 #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 2/8 kernel-shark: Add logic for the initial path of Open-File dialogs

In reply to Yordan Karadzhov

If the application has been started from its installation location, all Open File dialogs will start at ${HOME}. Otherwise the dialogs will start at ${PWD}. If a given dialog has been used already to select a file, next time the dialog will start in the directory of this file.

---
 kernel-shark/src/KsCaptureDialog.cpp |  34 +++-----
 kernel-shark/src/KsCaptureDialog.hpp |   2 +
 kernel-shark/src/KsMainWindow.cpp    |  70 ++++++----------
 kernel-shark/src/KsMainWindow.hpp    |   4 +-
 kernel-shark/src/KsUtils.cpp         | 121 +++++++++++++++++++++++++++
 kernel-shark/src/KsUtils.hpp         |  17 ++++
 6 files changed, 183 insertions(+), 65 deletions(-)
kernel-shark/src/KsCaptureDialog.cpp +13 -21
index 1272c2e..2976a3b 100644
@@ -206,10 +206,9 @@ void KsCaptureControl::_importSettings()
 	events = tep_list_events(_localTEP, TEP_EVENT_SORT_SYSTEM);
 
 	/* Get the configuration document. */
-	fileName = QFileDialog::getOpenFileName(this,
-						"Import from Filter",
-						KS_DIR,
-						"Kernel Shark Config files (*.json);;");
+	fileName = KsUtils::getFile(this, "Import from Filter",
+				    "Kernel Shark Config files (*.json);;",
+				    _lastFilePath);
 
 	if (fileName.isEmpty())
 		return;
@@ -256,23 +255,16 @@ void KsCaptureControl::_exportSettings()
 	json_object *jplugin;
 	QString plugin, out, comm;
 	QVector<int> ids;
-	QString fileName =
-		QFileDialog::getSaveFileName(this,
-					     "Export to File",
-					     KS_DIR,
-					     "Kernel Shark Config files (*.json);;");
+	QString fileName;
+
+	fileName = KsUtils::getSaveFile(this, "Export to File",
+					"Kernel Shark Config files (*.json);;",
+					".json",
+					_lastFilePath);
 
 	if (fileName.isEmpty())
 		return;
 
-	if (!fileName.endsWith(".json")) {
-		fileName += ".json";
-		if (QFileInfo(fileName).exists()) {
-			if (!KsWidgetsLib::fileExistsDialog(fileName))
-				return;
-		}
-	}
-
 	/* Create a configuration document. */
 	conf = kshark_record_config_new(KS_CONFIG_JSON);
 	events = kshark_filter_config_new(KS_CONFIG_JSON);
@@ -312,10 +304,10 @@ void KsCaptureControl::_exportSettings()
 void KsCaptureControl::_browse()
 {
 	QString fileName =
-		QFileDialog::getSaveFileName(this,
-					     "Save File",
-					     KS_DIR,
-					     "trace-cmd files (*.dat);;All files (*)");
+		KsUtils::getSaveFile(this, "Save File",
+				     "trace-cmd files (*.dat);;All files (*)",
+				     ".dat",
+				     _lastFilePath);
 
 	if (!fileName.isEmpty())
 		_outputLineEdit.setText(fileName);
kernel-shark/src/KsCaptureDialog.hpp +2 -0
index d65f475..2265704 100644
@@ -61,6 +61,8 @@ private:
 
 	QPushButton	_outputBrowseButton;
 
+	QString		_lastFilePath;
+
 	QStringList _getPlugins();
 
 	void _importSettings();
kernel-shark/src/KsMainWindow.cpp +27 -43

115 lines not on this page · raw message

kernel-shark/src/KsMainWindow.hpp +3 -1
index ec6506e..2bf3285 100644
@@ -151,7 +151,9 @@ private:
 
 	QAction		_contentsAction;
 
-	QShortcut        _deselectShortcut;
+	QShortcut	_deselectShortcut;
+
+	QString		_lastDataFilePath, _lastConfFilePath, _lastPluginFilePath;
 
 	void _open();
 
kernel-shark/src/KsUtils.cpp +121 -0

133 lines not on this page · raw message

kernel-shark/src/KsUtils.hpp +17 -0
index c8b5e88..7b80b21 100644
@@ -111,6 +111,23 @@ inline QString Ts2String(int64_t ts, int prec)
 
 bool matchCPUVisible(struct kshark_context *kshark_ctx,
 			      struct kshark_entry *e, int cpu);
+
+QString getFile(QWidget *parent,
+		const QString &windowName,
+		const QString &filter,
+		QString &lastFilePath);
+
+QStringList getFiles(QWidget *parent,
+		     const QString &windowName,
+		     const QString &filter,
+		     QString &lastFilePath);
+
+QString getSaveFile(QWidget *parent,
+		    const QString &windowName,
+		    const QString &filter,
+		    const QString &extension,
+		    QString &lastFilePath);
+
 }; // KsUtils
 
 /** Identifier of the Dual Marker active state. */
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 3/8 kernel-shark: Add logic for the plugins search path

In reply to Yordan Karadzhov

If the application has not been started from its installation location and the the directory

app_file_path + "../../kernel-shark/lib"

exists, all build-in plugins will be loaded from this directory. In any other case all build-in plugins will be loaded from

_INSTALL_PREFIX/lib/kshark/plugins/

---
 kernel-shark/src/KsUtils.cpp            | 40 ++++++++++++++++++-------
 kernel-shark/src/KsUtils.hpp            |  2 ++
 kernel-shark/src/plugins/CMakeLists.txt |  2 +-
 3 files changed, 32 insertions(+), 12 deletions(-)
kernel-shark/src/KsUtils.cpp +29 -11
index 8c42206..f62e53a 100644
@@ -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,28 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx)
 			lamUregUser);
 }
 
+char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n)
+{
+	QString execPath = QCoreApplication::applicationFilePath();
+	QString path = QFileInfo(execPath).path();
+	std::string pluginStr = plugin.toStdString();
+	char *lib;
+	QDir dir;
+
+	dir.setCurrent(path);
+	if (!KsUtils::isInstalled() && dir.cd("../../kernel-shark/lib")) {
+		std::string pathStr = dir.path().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 +649,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 +710,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 +718,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.
kernel-shark/src/KsUtils.hpp +2 -0
index 7b80b21..1c87271 100644
@@ -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> &reg,
kernel-shark/src/plugins/CMakeLists.txt +1 -1
index 6098275..64cf98d 100644
@@ -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)
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH v2 3/8] kernel-shark: Add logic for the plugins search path

Quoted 10 lines · On Thu, 2 May 2019 15:40:04 +0300 Yordan Karadzhov <[email protected]>…

If the application has not been started from its installation location and the the directory

app_file_path + "../../kernel-shark/lib"

exists, all build-in plugins will be loaded from this directory. In any other case all build-in plugins will be loaded from

_INSTALL_PREFIX/lib/kshark/plugins/

Quoted 9 lines
---
 kernel-shark/src/KsUtils.cpp            | 40 ++++++++++++++++++-------
 kernel-shark/src/KsUtils.hpp            |  2 ++
 kernel-shark/src/plugins/CMakeLists.txt |  2 +-
 3 files changed, 32 insertions(+), 12 deletions(-)

Hi Yordan,

After applying this patch, kernelshark's behavior for loading trace.dat changed. It no longer looks for the file in the current directory. If I run:

 # trace-cmd record -e sched_switch sleep 1
 # kernelshark

It loads without loading the produced trace.dat.

If I run:

 # kernelshark trace.dat

I get an error message stating:

"Unable to find file trace.dat"

-- Steve

#5 lore raw

Re: [PATCH v2 3/8] kernel-shark: Add logic for the plugins search path

Quoted 34 lines · Steven Rostedt
Quoted 10 lines · On Thu, 2 May 2019 15:40:04 +0300 Yordan Karadzhov <[email protected]>…

If the application has not been started from its installation location and the the directory

app_file_path + "../../kernel-shark/lib"

exists, all build-in plugins will be loaded from this directory. In any other case all build-in plugins will be loaded from

_INSTALL_PREFIX/lib/kshark/plugins/

Quoted 9 lines
---
  kernel-shark/src/KsUtils.cpp            | 40 ++++++++++++++++++-------
  kernel-shark/src/KsUtils.hpp            |  2 ++
  kernel-shark/src/plugins/CMakeLists.txt |  2 +-
  3 files changed, 32 insertions(+), 12 deletions(-)

Hi Yordan,

After applying this patch, kernelshark's behavior for loading trace.dat changed. It no longer looks for the file in the current directory. If I run:

  # trace-cmd record -e sched_switch sleep 1
  # kernelshark

It loads without loading the produced trace.dat.

Quoted 7 lines

If I run:

  # kernelshark trace.dat

I get an error message stating:

"Unable to find file trace.dat"

I see the problem. Have you pushed this patch already? I can send you a corrected version of the patch or a separate patch with the fix.

Thanks!
Yordan

Quoted 3 lines

-- Steve

#6 lore raw

Re: [PATCH v2 3/8] kernel-shark: Add logic for the plugins search path

Quoted 5 lines · Yordan Karadzhov (VMware)

I see the problem. Have you pushed this patch already? I can send you a

corrected version of the patch or a separate patch with the fix.

I have not pushed yet. Please send a new version of this patch.

Thanks,

-- Steve

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity and top posting.
#7 lore raw

Re: [PATCH v2 3/8] kernel-shark: Add logic for the plugins search path

In reply to Steven Rostedt
Quoted 34 lines · Steven Rostedt
Quoted 10 lines · On Thu, 2 May 2019 15:40:04 +0300 Yordan Karadzhov <[email protected]>…

If the application has not been started from its installation location and the the directory

app_file_path + "../../kernel-shark/lib"

exists, all build-in plugins will be loaded from this directory. In any other case all build-in plugins will be loaded from

_INSTALL_PREFIX/lib/kshark/plugins/

Quoted 9 lines
---
  kernel-shark/src/KsUtils.cpp            | 40 ++++++++++++++++++-------
  kernel-shark/src/KsUtils.hpp            |  2 ++
  kernel-shark/src/plugins/CMakeLists.txt |  2 +-
  3 files changed, 32 insertions(+), 12 deletions(-)

Hi Yordan,

After applying this patch, kernelshark's behavior for loading trace.dat changed. It no longer looks for the file in the current directory. If I run:

  # trace-cmd record -e sched_switch sleep 1
  # kernelshark

It loads without loading the produced trace.dat.

Quoted 7 lines

If I run:

  # kernelshark trace.dat

I get an error message stating:

"Unable to find file trace.dat"

I see the problem. Have you pushed this patch already? I can send you a corrected version of the patch or a separate patch with the fix.

Thanks!
Yordan

Quoted 3 lines

-- Steve

#8 lore raw

PATCH v2 4/8 kernel-shark: Remove the definition of KS_DIR

In reply to Yordan Karadzhov

KS_DIR is no longer used, so we do not need to define it in the Cmake-generated header file.

---
 kernel-shark/build/deff.h.cmake | 3 ---
 1 file changed, 3 deletions(-)
kernel-shark/build/deff.h.cmake +0 -3
index ba211f4..1cf8a80 100644
@@ -11,9 +11,6 @@
 /** KernelShark Version number. */
 #cmakedefine KS_VERSION_STRING "@KS_VERSION_STRING@"
 
-/** KernelShark source code path. */
-#cmakedefine KS_DIR "@KS_DIR@"
-
 /** KernelShark installation prefix path. */
 #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@"
 
Signature · 1 line
2.20.1
#9 lore raw

PATCH v2 5/8 kernel-shark: Remember the paths used by the Open-File dialogs

In reply to Yordan Karadzhov

The application will remember the used file paths across different executions.

---
 kernel-shark/src/KsMainWindow.cpp | 11 ++++++++++-
 kernel-shark/src/KsMainWindow.hpp |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)
kernel-shark/src/KsMainWindow.cpp +10 -1
index 748bacd..5f326f5 100644
@@ -67,7 +67,8 @@ KsMainWindow::KsMainWindow(QWidget *parent)
   _fullScreenModeAction("Full Screen Mode", this),
   _aboutAction("About", this),
   _contentsAction("Contents", this),
-  _deselectShortcut(this)
+  _deselectShortcut(this),
+  _settings("kernelshark.org", "Kernel Shark") // organization , application
 {
 	setWindowTitle("Kernel Shark");
 	_createActions();
@@ -126,6 +127,10 @@ KsMainWindow::KsMainWindow(QWidget *parent)
 	connect(&_mState,	&KsDualMarkerSM::deselectB,
 		this,		&KsMainWindow::_deselectB);
 
+	_lastDataFilePath = _settings.value("dataPath").toString();
+	_lastConfFilePath = _settings.value("confPath").toString();
+	_lastPluginFilePath = _settings.value("pluginPath").toString();
+
 	_resizeEmpty();
 }
 
@@ -143,6 +148,10 @@ KsMainWindow::~KsMainWindow()
 					_session.getConfDocPtr());
 	}
 
+	_settings.setValue("dataPath", _lastDataFilePath);
+	_settings.setValue("confPath", _lastConfFilePath);
+	_settings.setValue("pluginPath", _lastPluginFilePath);
+
 	_data.clear();
 
 	if (kshark_instance(&kshark_ctx))
kernel-shark/src/KsMainWindow.hpp +2 -0
index 2bf3285..962de2d 100644
@@ -155,6 +155,8 @@ private:
 
 	QString		_lastDataFilePath, _lastConfFilePath, _lastPluginFilePath;
 
+	QSettings	_settings;
+
 	void _open();
 
 	void _restoreSession();
Signature · 1 line
2.20.1
#10 lore raw

PATCH v2 6/8 kernel-shark: Add logic for selecting the trace-cmd executable used

In reply to Yordan Karadzhov

If kshark-record has been started from its installation location it will use the installed version of trace-cmd. Otherwise the trace-cmd executable found by Cmake when building KernelShark (see FindTraceCmd.cmake) will be used.

---
 kernel-shark/src/KsCaptureDialog.cpp | 7 ++++++-
 kernel-shark/src/KsUtils.cpp         | 4 ++--
 kernel-shark/src/KsUtils.hpp         | 2 ++
 3 files changed, 10 insertions(+), 3 deletions(-)
kernel-shark/src/KsCaptureDialog.cpp +6 -1
index 2976a3b..b107595 100644
@@ -473,7 +473,7 @@ KsCaptureDialog::KsCaptureDialog(QWidget *parent)
   _captureMon(this),
   _captureProc(this)
 {
-	QString captureExe(TRACECMD_BIN_DIR);
+	QString captureExe;
 
 	this->setWindowTitle("Capture");
 	_layout.addWidget(&_captureCtrl);
@@ -489,6 +489,11 @@ KsCaptureDialog::KsCaptureDialog(QWidget *parent)
 	connect(&_captureCtrl._closeButton,	&QPushButton::pressed,
 		this,				&KsCaptureDialog::close);
 
+	if (KsUtils::isInstalled())
+		captureExe = QString(_INSTALL_PREFIX) + QString("/bin");
+	else
+		captureExe = TRACECMD_BIN_DIR;
+
 	captureExe += "/trace-cmd";
 	_captureProc.setProgram(captureExe);
 
kernel-shark/src/KsUtils.cpp +2 -2
index f62e53a..ee481bf 100644
@@ -142,10 +142,10 @@ bool matchCPUVisible(struct kshark_context *kshark_ctx,
  */
 bool isInstalled()
 {
-	QString appPath = QCoreApplication::applicationFilePath();
+	QString appPath = QCoreApplication::applicationDirPath();
 	QString installPath(_INSTALL_PREFIX);
 
-	installPath += "/bin/kernelshark";
+	installPath += "/bin";
 	installPath = QDir::cleanPath(installPath);
 
 	return appPath == installPath;
kernel-shark/src/KsUtils.hpp +2 -0
index 1c87271..b4663da 100644
@@ -112,6 +112,8 @@ inline QString Ts2String(int64_t ts, int prec)
 bool matchCPUVisible(struct kshark_context *kshark_ctx,
 			      struct kshark_entry *e, int cpu);
 
+bool isInstalled();
+
 QString getFile(QWidget *parent,
 		const QString &windowName,
 		const QString &filter,
Signature · 1 line
2.20.1
#11 lore raw

PATCH v2 7/8 kernel-shark: Remove hard-coded install paths for libraries and plugins

In reply to Yordan Karadzhov

The definition of KS_APP_NAME is used to derive standard installation paths for the KernelShark libraries and plugins.

---
 kernel-shark/CMakeLists.txt             |  7 +++++--
 kernel-shark/build/deff.h.cmake         |  3 +++
 kernel-shark/src/CMakeLists.txt         | 12 ++++++------
 kernel-shark/src/KsUtils.cpp            |  4 ++--
 kernel-shark/src/plugins/CMakeLists.txt |  3 +--
 5 files changed, 17 insertions(+), 12 deletions(-)
kernel-shark/CMakeLists.txt +5 -2
index 1aee858..64f7de8 100644
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
 # Set the name and version of the project
 project(kernel-shark)
 
+set(KS_APP_NAME "kernelshark")
 set(KS_VERSION_MAJOR 0)
 set(KS_VERSION_MINOR 9)
 set(KS_VERSION_PATCH 8)
@@ -39,6 +40,8 @@ if(NOT _INSTALL_PREFIX)
 	set(_INSTALL_PREFIX "/usr/local")
 endif()
 
+set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
+
 if (NOT _DEBUG)
 
 	set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -O2")
@@ -46,7 +49,7 @@ if (NOT _DEBUG)
 
 endif (NOT _DEBUG)
 
-SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/kshark/")
+SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/")
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
 include_directories(${KS_DIR}/src/
@@ -79,7 +82,7 @@ if (_DOXYGEN_DOC AND DOXYGEN_FOUND)
 endif ()
 
 configure_file( ${KS_DIR}/build/ks.desktop.cmake
-                ${KS_DIR}/kernelshark.desktop)
+                ${KS_DIR}/${KS_APP_NAME}.desktop)
 
 configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake
                 ${KS_DIR}/org.freedesktop.kshark-record.policy)
kernel-shark/build/deff.h.cmake +3 -0
index 1cf8a80..efee2a1 100644
@@ -14,6 +14,9 @@
 /** KernelShark installation prefix path. */
 #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@"
 
+/** KernelShark plugins installation prefix path. */
+#cmakedefine KS_PLUGIN_INSTALL_PREFIX "@KS_PLUGIN_INSTALL_PREFIX@"
+
 /** Location of the trace-cmd executable. */
 #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
 
kernel-shark/src/CMakeLists.txt +6 -6
index b7dbd7e..2f28cae 100644
@@ -69,19 +69,19 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     set_target_properties(kshark-gui PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
 
-    message(STATUS "kernelshark")
-    add_executable(kernelshark          kernelshark.cpp)
-    target_link_libraries(kernelshark   kshark-gui)
+    message(STATUS ${KS_APP_NAME})
+    add_executable(${KS_APP_NAME}          kernelshark.cpp)
+    target_link_libraries(${KS_APP_NAME}   kshark-gui)
 
     message(STATUS "kshark-record")
     add_executable(kshark-record        kshark-record.cpp)
     target_link_libraries(kshark-record kshark-gui)
 
-    install(TARGETS kernelshark kshark-record kshark kshark-plot kshark-gui
+    install(TARGETS ${KS_APP_NAME} kshark-record kshark kshark-plot kshark-gui
             RUNTIME DESTINATION ${_INSTALL_PREFIX}/bin/
-            LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/)
+            LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/)
 
-    install(FILES "${KS_DIR}/kernelshark.desktop"
+    install(FILES "${KS_DIR}/${KS_APP_NAME}.desktop"
             DESTINATION /usr/share/applications/)
 
     install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy"
kernel-shark/src/KsUtils.cpp +2 -2
index ee481bf..e2091be 100644
@@ -621,8 +621,8 @@ char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n)
 		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());
+		n = asprintf(&lib, "%s/plugin-%s.so",
+			     KS_PLUGIN_INSTALL_PREFIX, pluginStr.c_str());
 	}
 
 	return lib;
kernel-shark/src/plugins/CMakeLists.txt +1 -2
index 64cf98d..6c77179 100644
@@ -18,7 +18,6 @@ function(BUILD_PLUGIN)
 endfunction()
 
 set(PLUGIN_LIST "")
-
 BUILD_PLUGIN(NAME sched_events
              SOURCE sched_events.c SchedEvents.cpp)
 list(APPEND PLUGIN_LIST "sched_events default") # This plugin will be loaded by default
@@ -29,6 +28,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/plugins/)
+        LIBRARY DESTINATION ${KS_PLUGIN_INSTALL_PREFIX})
 
 set(PLUGINS ${PLUGIN_LIST} PARENT_SCOPE)
Signature · 1 line
2.20.1
#12 lore raw

PATCH v2 8/8 kernel-shark: Use XDG compliant path when saving cached data

In reply to Yordan Karadzhov

Use the QStandardPaths class provided by Qt in order to guarantee that the location of the cached data is XDG compliant.

---
 kernel-shark/src/KsMainWindow.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel-shark/src/KsMainWindow.cpp +4 -2
index 5f326f5..bb593bd 100644
@@ -409,8 +409,10 @@ QString KsMainWindow::_getCacheDir()
 		if (!QDir(dir).exists())
 			lamMakePath(true);
 	} else {
-		dir = QString(QDir::homePath()) +
-		      "/.cache/kernelshark";
+		auto appCachePath = QStandardPaths::GenericCacheLocation;
+		dir = QStandardPaths::writableLocation(appCachePath);
+		dir += "/kernelshark";
+
 		if (!QDir(dir).exists())
 			lamMakePath(false);
 	}
Signature · 1 line
2.20.1