From patchwork Thu May 2 12:40:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92DF51398 for ; Thu, 2 May 2019 12:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76B3528FE3 for ; Thu, 2 May 2019 12:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681EF28FE6; Thu, 2 May 2019 12:44:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80BA28FD9 for ; Thu, 2 May 2019 12:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbfEBMo0 (ORCPT ); Thu, 2 May 2019 08:44:26 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34792 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbfEBMo0 (ORCPT ); Thu, 2 May 2019 08:44:26 -0400 Received: by mail-wr1-f68.google.com with SMTP id e9so3175263wrc.1 for ; Thu, 02 May 2019 05:40:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yJ3LU9b3ycGuq/+Hd+KuAKwFjTZs+PcwurjzAx/a/RI=; b=f5MpclIgxLehc6Fjk+i2kSyMUw44tsqgNYrjWk3XL6hrLZqwtc4J6y0rj40jrdaHgo bGGjT/gfdzioP3/TbqSdzgq2PMqkyrpkaKLlc1L/1tw9HP9FJ3OOes/3CelplcMMscVI T/0NNbvn+oODOi4Bylv2FA6dIJEJKF+aZYQCH6r+MQsScwY/6P3917lrrvP7T6hn9Jlx nWckCFEXTNEU/tA1IoIQOIE6fzosLQqtXzmp875IUAbjHX2yaKW7SXBXDKeiKKL38q1c oBVNAyUGiTYgQE8eshiMBYHXt7FhkyCo0QrwlkDQPplckbwZQQKlgvDZa/x74hbaHV9C ESnw== X-Gm-Message-State: APjAAAWzEEW+PDLrAMtWBj9ewk81hOYoa/Mu9sM3N/TIQBF5xETGkO8T I0Syddn/eB0ACPfUFn0wvOg= X-Google-Smtp-Source: APXvYqzfcnWAdaqazgqUaInHdyJK36XvbPFtejOi7DiSZVwVb93yBuRZgoZZ/+M8BD6wBpjW/VehHw== X-Received: by 2002:a5d:55cc:: with SMTP id i12mr2634005wrw.179.1556800832057; Thu, 02 May 2019 05:40:32 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:31 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH v2 1/8] kernel-shark: Add INSTALL PREFIX to the Cmake-generated header file. Date: Thu, 2 May 2019 15:40:02 +0300 Message-Id: <20190502124009.32208-2-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To be used to check if the aplication runs from its installation location. Reviewed-by: Slavomir Kaslev Signed-off-by: Yordan Karadzhov --- kernel-shark/build/deff.h.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index 8041cfc..ba211f4 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -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@" From patchwork Thu May 2 12:40:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C94921398 for ; Thu, 2 May 2019 12:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6E8328FDA for ; Thu, 2 May 2019 12:40:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAFD728FDD; Thu, 2 May 2019 12:40:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B228728FDE for ; Thu, 2 May 2019 12:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbfEBMkg (ORCPT ); Thu, 2 May 2019 08:40:36 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33465 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbfEBMkg (ORCPT ); Thu, 2 May 2019 08:40:36 -0400 Received: by mail-wr1-f67.google.com with SMTP id e28so3189048wra.0 for ; Thu, 02 May 2019 05:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/1kmzUWBiZYQO3XqM7s+21dJRQ1VpCT3JOC8swqDTnY=; b=ib188twkeSauQZenppj7eZUahcIbrUsMGIw+qih/Mp+BI4ugmBQswzdCagoEKwDpAl 0Y2RfG26QkXm1wHzsdR3V2Lv1NP8BR/oovJkVLbD78DKiMFuUS3MFmFfxtXy/40ZShTE 6RnICgLtCHkP2lbyzmAdC8H/UFQAphZXmg9tMT5ItIl+2igaq37RHz9i/FlWiMDDyE1R nn1D1H6TpuyJleFt1vrQM+55GkXUUsVbTTvqtWndclCikVRUufcjf6lGPGE43shxNYGb CBIPb10ApckR0Z3oR3a1FZWhAWbSX2Ni7nb0bNkO+hOSXD5/9OtZuQ+oyzdvqM65/Ez8 XIuA== X-Gm-Message-State: APjAAAUjSIryYONnypVTMhJpZNy714bM0PmA4O6YZSRSCgrlj15s2F6Y nXttEfFvkwKMcciog/IBY6+Ezt5x X-Google-Smtp-Source: APXvYqy/DztM+Nuj1uOs32zFTiJkraOzvRm8T7P0Vunbii/BV6rRWSdp3L7Ek7xLokvMLedSK5HUjg== X-Received: by 2002:adf:bac9:: with SMTP id w9mr2648756wrg.256.1556800833725; Thu, 02 May 2019 05:40:33 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:33 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH v2 2/8] kernel-shark: Add logic for the initial path of Open-File dialogs Date: Thu, 2 May 2019 15:40:03 +0300 Message-Id: <20190502124009.32208-3-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Suggested-by: Steven Rostedt (VMware) Reviewed-by: Slavomir Kaslev Signed-off-by: Yordan Karadzhov --- 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(-) diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index 1272c2e..2976a3b 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -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 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); diff --git a/kernel-shark/src/KsCaptureDialog.hpp b/kernel-shark/src/KsCaptureDialog.hpp index d65f475..2265704 100644 --- a/kernel-shark/src/KsCaptureDialog.hpp +++ b/kernel-shark/src/KsCaptureDialog.hpp @@ -61,6 +61,8 @@ private: QPushButton _outputBrowseButton; + QString _lastFilePath; + QStringList _getPlugins(); void _importSettings(); diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index c839aca..748bacd 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -360,11 +360,11 @@ void KsMainWindow::_createMenus() void KsMainWindow::_open() { - QString fileName = - QFileDialog::getOpenFileName(this, - "Open File", - KS_DIR, - "trace-cmd files (*.dat);;All files (*)"); + QString fileName; + + fileName = KsUtils::getFile(this, "Open File", + "trace-cmd files (*.dat);;All files (*)", + _lastDataFilePath); if (!fileName.isEmpty()) loadDataFile(fileName); @@ -429,11 +429,11 @@ void KsMainWindow::_restoreSession() void KsMainWindow::_importSession() { - QString fileName = - QFileDialog::getOpenFileName(this, - "Import Session", - KS_DIR, - "Kernel Shark Config files (*.json);;"); + QString fileName; + + fileName = KsUtils::getFile(this, "Import Session", + "Kernel Shark Config files (*.json);;", + _lastConfFilePath); if (fileName.isEmpty()) return; @@ -460,23 +460,15 @@ void KsMainWindow::_updateSession() void KsMainWindow::_exportSession() { - QString fileName = - QFileDialog::getSaveFileName(this, - "Export Filter", - KS_DIR, - "Kernel Shark Config files (*.json);;"); + QString fileName; + fileName = KsUtils::getSaveFile(this, "Export Filter", + "Kernel Shark Config files (*.json);;", + ".json", + _lastConfFilePath); if (fileName.isEmpty()) return; - if (!fileName.endsWith(".json")) { - fileName += ".json"; - if (QFileInfo(fileName).exists()) { - if (!KsWidgetsLib::fileExistsDialog(fileName)) - return; - } - } - _updateSession(); _session.exportToFile(fileName); } @@ -512,8 +504,9 @@ void KsMainWindow::_importFilter() if (!kshark_instance(&kshark_ctx)) return; - fileName = QFileDialog::getOpenFileName(this, "Import Filter", KS_DIR, - "Kernel Shark Config files (*.json);;"); + fileName = KsUtils::getFile(this, "Import Filter", + "Kernel Shark Config files (*.json);;", + _lastConfFilePath); if (fileName.isEmpty()) return; @@ -540,20 +533,14 @@ void KsMainWindow::_exportFilter() if (!kshark_instance(&kshark_ctx)) return; - fileName = QFileDialog::getSaveFileName(this, "Export Filter", KS_DIR, - "Kernel Shark Config files (*.json);;"); + fileName = KsUtils::getSaveFile(this, "Export Filter", + "Kernel Shark Config files (*.json);;", + ".json", + _lastConfFilePath); if (fileName.isEmpty()) return; - if (!fileName.endsWith(".json")) { - fileName += ".json"; - if (QFileInfo(fileName).exists()) { - if (!KsWidgetsLib::fileExistsDialog(fileName)) - return; - } - } - kshark_export_all_event_filters(kshark_ctx, &conf); kshark_save_config_file(fileName.toStdString().c_str(), conf); kshark_free_config_doc(conf); @@ -859,15 +846,12 @@ void KsMainWindow::_pluginAdd() { QStringList fileNames; - fileNames = - QFileDialog::getOpenFileNames(this, "Add KernelShark plugins", - KS_DIR, - "KernelShark Plugins (*.so);;"); - - if (fileNames.isEmpty()) - return; + fileNames = KsUtils::getFiles(this, "Add KernelShark plugins", + "KernelShark Plugins (*.so);;", + _lastPluginFilePath); - _plugins.addPlugins(fileNames); + if (!fileNames.isEmpty()) + _plugins.addPlugins(fileNames); } void KsMainWindow::_record() diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp index ec6506e..2bf3285 100644 --- a/kernel-shark/src/KsMainWindow.hpp +++ b/kernel-shark/src/KsMainWindow.hpp @@ -151,7 +151,9 @@ private: QAction _contentsAction; - QShortcut _deselectShortcut; + QShortcut _deselectShortcut; + + QString _lastDataFilePath, _lastConfFilePath, _lastPluginFilePath; void _open(); diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index 6af0c66..8c42206 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -11,6 +11,7 @@ // KernelShark #include "KsUtils.hpp" +#include "KsWidgetsLib.hpp" namespace KsUtils { @@ -136,6 +137,126 @@ bool matchCPUVisible(struct kshark_context *kshark_ctx, return (e->cpu == cpu && (e->visible & KS_GRAPH_VIEW_FILTER_MASK)); } +/** + * @brief Check if the application runs from its installation location. + */ +bool isInstalled() +{ + QString appPath = QCoreApplication::applicationFilePath(); + QString installPath(_INSTALL_PREFIX); + + installPath += "/bin/kernelshark"; + installPath = QDir::cleanPath(installPath); + + return appPath == installPath; +} + +static QString getFileDialog(QWidget *parent, + const QString &windowName, + const QString &filter, + QString &lastFilePath, + bool forSave) +{ + QString fileName; + + if (lastFilePath.isEmpty()) { + lastFilePath = isInstalled() ? QDir::homePath() : + QDir::currentPath(); + } + + if (forSave) { + fileName = QFileDialog::getSaveFileName(parent, + windowName, + lastFilePath, + filter); + } else { + fileName = QFileDialog::getOpenFileName(parent, + windowName, + lastFilePath, + filter); + } + + if (!fileName.isEmpty()) + lastFilePath = QFileInfo(fileName).path(); + + return fileName; +} + +static QStringList getFilesDialog(QWidget *parent, + const QString &windowName, + const QString &filter, + QString &lastFilePath) +{ + QStringList fileNames; + + if (lastFilePath.isEmpty()) { + lastFilePath = isInstalled() ? QDir::homePath() : + QDir::currentPath(); + } + + fileNames = QFileDialog::getOpenFileNames(parent, + windowName, + lastFilePath, + filter); + + if (!fileNames.isEmpty()) + lastFilePath = QFileInfo(fileNames[0]).path(); + + return fileNames; +} + +/** + * @brief Open a standard Qt getFileName dialog and return the name of the + * selected file. Only one file can be selected. + */ +QString getFile(QWidget *parent, + const QString &windowName, + const QString &filter, + QString &lastFilePath) +{ + return getFileDialog(parent, windowName, filter, lastFilePath, false); +} + +/** + * @brief Open a standard Qt getFileName dialog and return the names of the + * selected files. Multiple files can be selected. + */ +QStringList getFiles(QWidget *parent, + const QString &windowName, + const QString &filter, + QString &lastFilePath) +{ + return getFilesDialog(parent, windowName, filter, lastFilePath); +} + +/** + * @brief Open a standard Qt getFileName dialog and return the name of the + * selected file. Only one file can be selected. + */ +QString getSaveFile(QWidget *parent, + const QString &windowName, + const QString &filter, + const QString &extension, + QString &lastFilePath) +{ + QString fileName = getFileDialog(parent, + windowName, + filter, + lastFilePath, + true); + + if (!fileName.isEmpty() && !fileName.endsWith(extension)) { + fileName += extension; + + if (QFileInfo(fileName).exists()) { + if (!KsWidgetsLib::fileExistsDialog(fileName)) + fileName.clear(); + } + } + + return fileName; +} + }; // KsUtils /** A stream operator for converting QColor into KsPlot::Color. */ diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index c8b5e88..7b80b21 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -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. */ From patchwork Thu May 2 12:40:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13FBB1515 for ; Thu, 2 May 2019 12:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027F728FDE for ; Thu, 2 May 2019 12:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA64828FE3; Thu, 2 May 2019 12:48:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7274528FDE for ; Thu, 2 May 2019 12:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726386AbfEBMsy (ORCPT ); Thu, 2 May 2019 08:48:54 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36494 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbfEBMsy (ORCPT ); Thu, 2 May 2019 08:48:54 -0400 Received: by mail-wm1-f67.google.com with SMTP id p16so2461569wma.1 for ; Thu, 02 May 2019 05:48:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iTaQEMdDKyzVeiyiwZKYOkIlTY4c7OgcVgSgP0/QoTY=; b=OPV5daViIVZnPXWtol2Qew5u2EY2KU5TSem9A+nKln1DQUXFtAB0Gaajo6QdV9ZqpX HU8D2FDGTwa7nF6pJMjmGyFiYItj48F7VLjfEmjGXdy8iiTixpTEBIpY9nIASwK+yIz1 0SaxnFLRNryOrLfXKO9ScoWXqxP/1+Z30FFsg1oJS1pBKlpsLuJeHrQseNAUO3uhu+ca p6HrKZsjcv3RAMewcZ1jHAWfLQAhnDMhbaTrshwpgyglY2j/Ua+6SeSHQZc3FY8eOyFZ EBMDKxl6HQy8qYCy2xzSKRRQE5lNEFcbHSlVfTYUQ7QiO4s10zctmAf8GYMgtRTinfan 8hGA== X-Gm-Message-State: APjAAAUntq5iXdoJ/UI2XtYMl19/S51yBB/3p6vmMgsh8fClyu80ioXw FJXhLdb1DMaRvNm/fLWZheSHdlWc X-Google-Smtp-Source: APXvYqx6Y5f+qkY+M5gS9+HSFRRwkk+Q7GW+aYbXeioGlyYpzzFCLgLIg8a4TVp4JC+x+ILxo98z3w== X-Received: by 2002:a7b:cb04:: with SMTP id u4mr2238197wmj.0.1556800835096; Thu, 02 May 2019 05:40:35 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:34 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH v2 3/8] kernel-shark: Add logic for the plugins search path Date: Thu, 2 May 2019 15:40:04 +0300 Message-Id: <20190502124009.32208-4-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/ Suggested-by: Steven Rostedt (VMware) Reviewed-by: Slavomir Kaslev Signed-off-by: Yordan Karadzhov --- 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(-) diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index 8c42206..f62e53a 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -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. diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index 7b80b21..1c87271 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -241,6 +241,8 @@ signals: private: void _parsePluginList(); + char *_pluginLibFromName(const QString &plugin, int &n); + template void _forEachInList(const QStringList &pl, const QVector ®, diff --git a/kernel-shark/src/plugins/CMakeLists.txt b/kernel-shark/src/plugins/CMakeLists.txt index 6098275..64cf98d 100644 --- a/kernel-shark/src/plugins/CMakeLists.txt +++ b/kernel-shark/src/plugins/CMakeLists.txt @@ -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) From patchwork Thu May 2 12:40:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8BCE1395 for ; Thu, 2 May 2019 12:52:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D86092022C for ; Thu, 2 May 2019 12:52:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D626A205C0; Thu, 2 May 2019 12:52:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 465D520008 for ; Thu, 2 May 2019 12:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbfEBMwH (ORCPT ); Thu, 2 May 2019 08:52:07 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54911 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbfEBMwH (ORCPT ); Thu, 2 May 2019 08:52:07 -0400 Received: by mail-wm1-f65.google.com with SMTP id b10so2661537wmj.4 for ; Thu, 02 May 2019 05:52:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nTy5Y2kSz9IHvXQ4mq/bAJQGbvvBqCYGHhj4u5aHRTw=; b=UbAoupc2iAinCXBNCqRuEg0UbSLVAXx4XSsGkH8wvtNPcLMxZAYV2Qqvzp2vtuL3w+ 3d2513Z8PVXjAFpUFM+pUgJrwUrAB1C3h6B+asrPeIwmaaeoMnnCRa3J9oVcQ8CKKLWS nl7uYzyqvWacnvOSWZYAAWr7kAI/mgV3NXgFrVzPhCm1PUHVlG5EGSBeGlujwpknR6AA K+hd2Ss4TWynlTTdc6XU2tRivXo+INyEm1LzIFx7r+GLGo0sIm/o30LIHZngOVFe9T0O mJ2PpJfzkKGUy4kQd6w/6H2b4Jm1w+HC29ien1VGQ0/raJtRnNiwAXXQkf3iPwvou9K7 tF6Q== X-Gm-Message-State: APjAAAVI6w0QAIcIyws5T/E2F0K+dT/7N+kNjOpzp6A1iIzqHhf+lV1L J0OpuXNqXWR0fl3T49UUxXaQfTHM X-Google-Smtp-Source: APXvYqx66FjqiPjhkPjumxtCEot1sjGZSZC2G8d2P+drREgbvZeBBdB9XKJPgILwZTVkqbUEWBwQlw== X-Received: by 2002:a1c:7008:: with SMTP id l8mr2150835wmc.49.1556800836408; Thu, 02 May 2019 05:40:36 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:36 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH v2 4/8] kernel-shark: Remove the definition of KS_DIR Date: Thu, 2 May 2019 15:40:05 +0300 Message-Id: <20190502124009.32208-5-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP KS_DIR is no longer used, so we do not need to define it in the Cmake-generated header file. Reviewed-by: Slavomir Kaslev Signed-off-by: Yordan Karadzhov --- kernel-shark/build/deff.h.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index ba211f4..1cf8a80 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -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@" From patchwork Thu May 2 12:40:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E35B392A for ; Thu, 2 May 2019 12:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D266428FDE for ; Thu, 2 May 2019 12:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44FD28FE3; Thu, 2 May 2019 12:47:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AF9D28FDE for ; Thu, 2 May 2019 12:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbfEBMrH (ORCPT ); Thu, 2 May 2019 08:47:07 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37984 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbfEBMrH (ORCPT ); Thu, 2 May 2019 08:47:07 -0400 Received: by mail-wr1-f67.google.com with SMTP id k16so3179193wrn.5 for ; Thu, 02 May 2019 05:47:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i3nTPtDvPWQAiGaNNaCPJbhHy8PTpiKkzlb8KCTSZl8=; b=QV3NItv7+MlwxZVzvoS32xrwo7IU5g7QFkCW2e/rlDfvR9NthNzXRTYTNk9WwnDoMr BBKhpfchYcGAI0aNHoiRJ9BVETF4WWnKztNQoEG5bzFeQYpxxK7mdWFAmlA6h9iSz1EJ q49Cxzb4HRtD9Tw4y1hR79CGvO8MNluqso+Yfydz/nypfvbBdmbz+sxwOShObydOUhi+ SYWitq5tY39A5QMjsdfqMZhWDVH5omlGsfgWCPu+egRaS4Uc87uwuw3PofwIdBreLiro vU0ljwaStwdVetbTh3fM9vBdiEZoWfsZ/1pYAWc0yJEAtARruHVfIn+7nQOfkckMkPSz kh5Q== X-Gm-Message-State: APjAAAVMzHxGOrgyXltgYCwNI9XyFMo1nZx9wtWkZNKl/IyoXlTWsH8J hOgTPwI6w69JLY2qd8ajlws= X-Google-Smtp-Source: APXvYqzbWPLDksOaO14n1oOwWPehVeMW4EL5eZa5/tw6RPZaYhED4XjUYXjeHYCNfIZAKYVD5GxLDQ== X-Received: by 2002:a5d:4492:: with SMTP id j18mr2515015wrq.212.1556800837820; Thu, 02 May 2019 05:40:37 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:37 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH v2 5/8] kernel-shark: Remember the paths used by the Open-File dialogs Date: Thu, 2 May 2019 15:40:06 +0300 Message-Id: <20190502124009.32208-6-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The application will remember the used file paths across different executions. Suggested-by: Slavomir Kaslev Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsMainWindow.cpp | 11 ++++++++++- kernel-shark/src/KsMainWindow.hpp | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index 748bacd..5f326f5 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -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)) diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp index 2bf3285..962de2d 100644 --- a/kernel-shark/src/KsMainWindow.hpp +++ b/kernel-shark/src/KsMainWindow.hpp @@ -155,6 +155,8 @@ private: QString _lastDataFilePath, _lastConfFilePath, _lastPluginFilePath; + QSettings _settings; + void _open(); void _restoreSession(); From patchwork Thu May 2 12:40:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEC1A92A for ; Thu, 2 May 2019 12:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADF3F28FD9 for ; Thu, 2 May 2019 12:40:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1DD428FDD; Thu, 2 May 2019 12:40:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4553928FD9 for ; Thu, 2 May 2019 12:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbfEBMkl (ORCPT ); Thu, 2 May 2019 08:40:41 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41588 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfEBMkk (ORCPT ); Thu, 2 May 2019 08:40:40 -0400 Received: by mail-wr1-f66.google.com with SMTP id c12so3136676wrt.8 for ; Thu, 02 May 2019 05:40:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TyZuzO2XXCXgNlhtnNYpL+H13gJK/Nod1539clmwlY0=; b=hhgm+dz1KhoCI9WX7PlGkBykvDlboENSi2HTSULktP0aZjc+uQJ7Q4r0Cf92KZG02L DCYNn0t94xCRqTl/tyQPgRKcwcMzPMtqUCdYY0OJu0CCGqmkyQ/XDEbJjmaTHev9VscH pZJxBtyDKdMy4pR84uTozC6gBIt6ZSOPubSTyS/tqPE6ZQT5Zwvx7JASB8rYpSmwbtHR Qf/RraLM9dLndZkw4eHrvBAaSAJh65ShI991vFc/EY1FU4wixV3iPIJGjZduwYnuoeYQ ntj3/pWwiEDg8Dr/P9baJDtGXME27kxpIYvA+lepaijfZ4oSiiRiBBbiftMEbD5CE8hX NX9A== X-Gm-Message-State: APjAAAW4sRDJWGcyxVuDnoqjjcvElGfFl3fQOK3lhXg3IBlzXCi3tn53 yfUkEZRO9ns1CQ+Nap+ceFo= X-Google-Smtp-Source: APXvYqxsi+ite1UiIMBMQAhYnTzfHgp64Dq7RLAZzcfj7yI2KX7Cp/eFL/HrCYSB0ZWFmi5IE/KkIQ== X-Received: by 2002:adf:ce0b:: with SMTP id p11mr2496331wrn.196.1556800839167; Thu, 02 May 2019 05:40:39 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:38 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov Subject: [PATCH v2 6/8] kernel-shark: Add logic for selecting the trace-cmd executable used Date: Thu, 2 May 2019 15:40:07 +0300 Message-Id: <20190502124009.32208-7-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Yordan Karadzhov --- 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 --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, From patchwork Thu May 2 12:40:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A60592A for ; Thu, 2 May 2019 12:40:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE09728FDA for ; Thu, 2 May 2019 12:40:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E29CA28FDD; Thu, 2 May 2019 12:40:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6787828FD9 for ; Thu, 2 May 2019 12:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbfEBMkn (ORCPT ); Thu, 2 May 2019 08:40:43 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36150 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfEBMkn (ORCPT ); Thu, 2 May 2019 08:40:43 -0400 Received: by mail-wr1-f67.google.com with SMTP id o4so3167409wra.3 for ; Thu, 02 May 2019 05:40:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B2b1nhQASwdzA0A1+OW/NvGNY0+pW67mx28Mgy0aZUU=; b=CHzmbqGPPHlBMDboa8J8tF44HAYTj9FfIxk1RLS8rD+oL+t/lpARVYH/ejbLyVDc8e xO8IjrAxjXKQKLSshLehKhfGPVR4wNt6YUK4Bk0ysWSlzi0SmxRhtTi/X9lKi/TimIoy vGDPUsmfX35L0WA71ygvavKDon0ESamP+AU85tiDu6aGzOT9CA9IU8CrGjFsmxZ+1TC6 IsJKbVt2pXJmt5r647SgvJrwgmBKEi9h6UmnX3KG+7jVpnylJUKKGo14F2ZmVIE8x6Yt 2eQrhf2EvdH2TOfo0ZGv3W0QQkMqKT+RKKc9nESfV9nbYdWwd0b444rf5zedbVXjY4Ty +kLw== X-Gm-Message-State: APjAAAU70pSXxEyXNOipxrPdvc9D20rVti/Q6UV7Rfmo+6+dt/su7t2l 1VWpIfPnnLjLXuch3KfUI0k= X-Google-Smtp-Source: APXvYqyx86CIj6lMrLqD8a6Vb7odqCYgoeddB2cq6UtnXCTNHUq3T9IOdv+fOyQLSoiFPtvv2AyzFw== X-Received: by 2002:a5d:6386:: with SMTP id p6mr2686052wru.59.1556800840721; Thu, 02 May 2019 05:40:40 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:40 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov Subject: [PATCH v2 7/8] kernel-shark: Remove hard-coded install paths for libraries and plugins Date: Thu, 2 May 2019 15:40:08 +0300 Message-Id: <20190502124009.32208-8-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The definition of KS_APP_NAME is used to derive standard installation paths for the KernelShark libraries and plugins. Suggested-by: Troy Engel Signed-off-by: Yordan Karadzhov --- 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(-) diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt index 1aee858..64f7de8 100644 --- a/kernel-shark/CMakeLists.txt +++ b/kernel-shark/CMakeLists.txt @@ -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) diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index 1cf8a80..efee2a1 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -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@" diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt index b7dbd7e..2f28cae 100644 --- a/kernel-shark/src/CMakeLists.txt +++ b/kernel-shark/src/CMakeLists.txt @@ -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" diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index ee481bf..e2091be 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -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; diff --git a/kernel-shark/src/plugins/CMakeLists.txt b/kernel-shark/src/plugins/CMakeLists.txt index 64cf98d..6c77179 100644 --- a/kernel-shark/src/plugins/CMakeLists.txt +++ b/kernel-shark/src/plugins/CMakeLists.txt @@ -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) From patchwork Thu May 2 12:40:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10926731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E1AD17DF for ; Thu, 2 May 2019 12:40:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C39A28FD9 for ; Thu, 2 May 2019 12:40:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4086128FDD; Thu, 2 May 2019 12:40:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8B7428FD9 for ; Thu, 2 May 2019 12:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbfEBMkn (ORCPT ); Thu, 2 May 2019 08:40:43 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42000 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbfEBMkn (ORCPT ); Thu, 2 May 2019 08:40:43 -0400 Received: by mail-wr1-f65.google.com with SMTP id l2so3129982wrb.9 for ; Thu, 02 May 2019 05:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N7ItfzZKOt1nrRaCHb3cf3KeNap2LA1hzeISdKQJswc=; b=JpFWH6xGImItAlBYcAo1fkFWdCvGPruvzkV9EFfWCOheHI2wD7gFbPtqSNzhWoF4vV oa8MpV94QCf2VpLjVvQAOgh9lig5bAjKS7/5FL4UEBfoNDbJTpBue/rHEAjBiUBRPdBM FSNklo6Dw7l/dX7dzs5GQXlrlTzqHTX0bwyln0hDR3+kuv40ACGypqCZfONb7kOP1bH2 HO4t7/pe8rjUuWWb4i/DtS15dD2eQ/hqotOZdM58vHy91o64aKLodsDNy85YkO0rMEJ1 u+JY/VwGutZjH51YbvtchNN6DQ5WBVMps/dtiI5dMj+7GM6OCEkxH9KIRkrhmEVqZBG/ svLw== X-Gm-Message-State: APjAAAV9LMEgBNodODnI8W4SDipleynvxmIg76jHrSDNAxm1g7stMLb4 fKsEvE1HzrNXvC90sMMTmmU= X-Google-Smtp-Source: APXvYqxICNcv5KKQp1NqeqjJwuOsChTgWQP8mJmLCzKHih3ZURPgOKH3owhk8KremBH05x9PRWFHEw== X-Received: by 2002:adf:db05:: with SMTP id s5mr2623511wri.247.1556800842252; Thu, 02 May 2019 05:40:42 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id d11sm7511008wmb.39.2019.05.02.05.40.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 05:40:41 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, troyengel@gmail.com, Yordan Karadzhov Subject: [PATCH v2 8/8] kernel-shark: Use XDG compliant path when saving cached data Date: Thu, 2 May 2019 15:40:09 +0300 Message-Id: <20190502124009.32208-9-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502124009.32208-1-ykaradzhov@vmware.com> References: <20190502124009.32208-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the QStandardPaths class provided by Qt in order to guarantee that the location of the cached data is XDG compliant. Suggested-by: Troy Engel Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsMainWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index 5f326f5..bb593bd 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -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); }