diff mbox series

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

Message ID 20190502124009.32208-7-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Modifications needed for KS 1.0 | expand

Commit Message

Yordan Karadzhov May 2, 2019, 12:40 p.m. UTC
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.

Suggested-by: Troy Engel <troyengel@gmail.com>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 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(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index 2976a3b..b107595 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -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);
 
diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp
index f62e53a..ee481bf 100644
--- a/kernel-shark/src/KsUtils.cpp
+++ b/kernel-shark/src/KsUtils.cpp
@@ -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;
diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp
index 1c87271..b4663da 100644
--- a/kernel-shark/src/KsUtils.hpp
+++ b/kernel-shark/src/KsUtils.hpp
@@ -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,