From patchwork Tue Apr 23 13:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10912959 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 6D03A112C for ; Tue, 23 Apr 2019 13:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DDB5286F2 for ; Tue, 23 Apr 2019 13:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5230D28715; Tue, 23 Apr 2019 13:28:04 +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 3B8FC286F2 for ; Tue, 23 Apr 2019 13:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbfDWN2D (ORCPT ); Tue, 23 Apr 2019 09:28:03 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39440 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbfDWN2C (ORCPT ); Tue, 23 Apr 2019 09:28:02 -0400 Received: by mail-wr1-f66.google.com with SMTP id a9so2645489wrp.6 for ; Tue, 23 Apr 2019 06:28:01 -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=TuYWMMZRCJKH6101TCTD2mVPAAihpRZlVB18ai0tumE=; b=ZQeojPhPGNSgJyAxOGQy/Sr12EFAYxDi17y8rmrShDlgoOc6+U5ALQ3bNkYLFWCGLt O8kVxRsmCNUBgibkULhzPGhmsYkG83Sp2l/N84iQsjDjma6t+eAZvJ38LCsFUrUfHz8B 5AZ+tmBhEgtV+GGrcxcBNRPv9r18UDhAAYCsWSNb2hMsNE1gcw0v+4XZ0kEpsIjY+wT0 hj12b99pYPfOpZFpmS9ji/CQx5ryYA7pHccMiNDMvvg2SfMOZCepQ2fOJpaXzQk6aSIi dwmQnD56T/RzZ0vM5lM/HBV4g+KWF1QlTgmY2lJct6Fj6fHvYibNVoSzJJdC7m1gnOxY 5ljg== X-Gm-Message-State: APjAAAX0xHKXnALDK2ujWdYH9xubf7rl1G+/qCKO2w3FWc1nLACueZLb 97vdAcXEEx4EB55jVoL/KxORnXwA X-Google-Smtp-Source: APXvYqydq6RQZdqj1BNbGrEhU1g0D58vvp+2SfrQbYjM3SQxy3bjG1CdxHrvNpUXOLG//lYvIo7YOQ== X-Received: by 2002:adf:dcc3:: with SMTP id x3mr9314848wrm.263.1556026081193; Tue, 23 Apr 2019 06:28:01 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w11sm31222231wre.15.2019.04.23.06.28.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 06:28:00 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 1/5] kernel-shark: Add INSTALL PREFIX to the Cmake-generated header file. Date: Tue, 23 Apr 2019 16:27:37 +0300 Message-Id: <20190423132741.17864-2-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423132741.17864-1-ykaradzhov@vmware.com> References: <20190423132741.17864-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. 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 Tue Apr 23 13:27:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10912961 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 264B6112C for ; Tue, 23 Apr 2019 13:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C77286F2 for ; Tue, 23 Apr 2019 13:28:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A0E628715; Tue, 23 Apr 2019 13:28:06 +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 17DFB286F2 for ; Tue, 23 Apr 2019 13:28:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbfDWN2E (ORCPT ); Tue, 23 Apr 2019 09:28:04 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33992 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbfDWN2E (ORCPT ); Tue, 23 Apr 2019 09:28:04 -0400 Received: by mail-wr1-f66.google.com with SMTP id c6so14534807wrm.1 for ; Tue, 23 Apr 2019 06:28:03 -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=ehWXD5xz2Th45I7P9D3ZpvQ5qdm3wj/0biwIanxs6Qg=; b=tjz7Wlt40sIAJO9MzB9lbJE0ACIvmoMKdK46+s1Ms46ixlrlzbiTuahJvpcoGbd+lY DHLqzI9H4g8Q2qkvOt0MlGJwXgjov7SwNEaVM65Bj+ZNsqZurTyRTrUBgRv9zpD5j0JX TF+QxMJ60SnyQzPeRXkymgQrt//Y21rSHk0RxwqZYKaQ+15NQvlRLlbaoTq1h4ClwtKs lb9w3BdV81lfgGkfgm58ff5AC5S4a/LYzgRRmDdd1Irp3VCg+aWIPJ69+ives9U3y3ws dZLC9l7/jhaL5ep5obyQspQGrMBlL+qT2LUUTnfn56XcGhgoBd8zLyP0rZIR9iYyHypo E8Mw== X-Gm-Message-State: APjAAAXiAXVMZChTA5YJ5SAa6TGDq9MWPwSkPwEHB7lH/94HtFAfrsLM oMYYueG5ikgPaLrRvJ3IFRk= X-Google-Smtp-Source: APXvYqy9cC4e8rhdE38g22YOfAZ1bduHfY13bBBmwuQPfOlOiIJGjSfNznTjRgYEDc43VIR5qmfWhg== X-Received: by 2002:adf:8051:: with SMTP id 75mr18118148wrk.2.1556026082745; Tue, 23 Apr 2019 06:28:02 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w11sm31222231wre.15.2019.04.23.06.28.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 06:28:02 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 2/5] kernel-shark: Add logic for the initial path of Open-File dialogs Date: Tue, 23 Apr 2019 16:27:38 +0300 Message-Id: <20190423132741.17864-3-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423132741.17864-1-ykaradzhov@vmware.com> References: <20190423132741.17864-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) 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 Tue Apr 23 13:27:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10912963 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 680401390 for ; Tue, 23 Apr 2019 13:28:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 553B8286F2 for ; Tue, 23 Apr 2019 13:28:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48AC828715; Tue, 23 Apr 2019 13:28: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 C3A56286F2 for ; Tue, 23 Apr 2019 13:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbfDWN2G (ORCPT ); Tue, 23 Apr 2019 09:28:06 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39429 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbfDWN2G (ORCPT ); Tue, 23 Apr 2019 09:28:06 -0400 Received: by mail-wm1-f68.google.com with SMTP id n25so48691wmk.4 for ; Tue, 23 Apr 2019 06:28:04 -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=MQ5bu7Q2HlDV1Agt/54R/VPmV4hl5vSOySDWLM7upn8=; b=cNqGyH0TArqG5RET/AFBx+cJScFJS6b9mxovX/cYHX4MAT8uZkTSj/pqHWa5pz+5oB wotUeR1xwxIRyt7TpdOyk17mY/fdM95gBV9x8QLr38HW64ChPLk0GOCWCE2+WgZupFcY bEOeGGbv9pQ2zcZDVcZAET+XgstzqKo0AJqfpDe0ez/5WB7qXfcR339NuuiLXOkf5k9h 8tmY1EPh/3FIxBupNdtiDM1BSXoSD3irk6aotVKxpkKBBtDUdmD9rOwG2ujUPEVkSwVJ UEts7BmVfAxjvteMwNFp3D85RKJ5X9PTt0BQv4COEvW6TQHlXgq3k8s4LiBcMGh6QWzH b4MQ== X-Gm-Message-State: APjAAAWI26l3h1HhaQXMBOOdMSgafw6nVVLApYcY2YsOQ/MQlAcnvusL oGu97dqF041f+I+XnaruL6o= X-Google-Smtp-Source: APXvYqw9YwJ08jGF5pxA9s86Bz8iw/5T4DcwE3+z9+jsxH8hl5blhk7t37kUtri+g6SaExhynwtTlQ== X-Received: by 2002:a1c:6889:: with SMTP id d131mr2347449wmc.114.1556026084156; Tue, 23 Apr 2019 06:28:04 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w11sm31222231wre.15.2019.04.23.06.28.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 06:28:03 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 3/5] kernel-shark: Add logic for the plugins search path Date: Tue, 23 Apr 2019 16:27:39 +0300 Message-Id: <20190423132741.17864-4-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423132741.17864-1-ykaradzhov@vmware.com> References: <20190423132741.17864-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) 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 Tue Apr 23 13:27:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10912965 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 6F1791390 for ; Tue, 23 Apr 2019 13:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 612E2286F2 for ; Tue, 23 Apr 2019 13:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 522F428715; Tue, 23 Apr 2019 13:28:08 +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 F036D286F2 for ; Tue, 23 Apr 2019 13:28:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfDWN2H (ORCPT ); Tue, 23 Apr 2019 09:28:07 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33998 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbfDWN2H (ORCPT ); Tue, 23 Apr 2019 09:28:07 -0400 Received: by mail-wr1-f68.google.com with SMTP id c6so14535022wrm.1 for ; Tue, 23 Apr 2019 06:28: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=wszLKCv0U3ICfQrxFCpczCj5V/Wa3796D+NUgPIEPNI=; b=kFExoqHiOakwpyziOO4+FyGQxXIybsZ37s4JyEmylIXul4Kh68c3XknHHPlYbKu0lx PFAkL5DsuciKo/Rtf3LiLCYmJDJ249N/lr99Xq+MW6J5kP0zNNhlSth5xH7wtAcUEUA7 pvnP55bOFrHljXX0iIM851aeUWTNUStM0Is+cZMU7lapZIvpfRKJ7+jftCQs0ADFbMmx fvIhVgbriyAmZGc2SQG2NTOWfOzYs0vEOLbcidxLbVCm/dxm3u2wn6dt1TVS3EsOfhSG /uIEPJiqrnSGcVcfou8xFWt6C9waj1VsHJv9oX3LGx5lE0a9STIk2BHRLll5NEz3EAZL cjcQ== X-Gm-Message-State: APjAAAWxv3x7bCEG3um6jbD7bH/AgUMBBWfnwH9rbkdYk3hw1dNhjkQf uFNWRMkfxAW58+195bKVzA4= X-Google-Smtp-Source: APXvYqzDm79IyIj6VH1ACVzGGWBFfU2+FiQrIku1IwU9SB7a2VDHHvGnj6oMPjR7xpeY6R1X9Mw9zQ== X-Received: by 2002:a5d:4e82:: with SMTP id e2mr18009090wru.164.1556026085593; Tue, 23 Apr 2019 06:28:05 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w11sm31222231wre.15.2019.04.23.06.28.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 06:28:05 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 4/5] kernel-shark: Remove the definition of KS_DIR Date: Tue, 23 Apr 2019 16:27:40 +0300 Message-Id: <20190423132741.17864-5-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423132741.17864-1-ykaradzhov@vmware.com> References: <20190423132741.17864-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. 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 Tue Apr 23 13:27:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10912967 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 A5CBB112C for ; Tue, 23 Apr 2019 13:28:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 966F8286F2 for ; Tue, 23 Apr 2019 13:28:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A83C28715; Tue, 23 Apr 2019 13:28: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 32E49286F2 for ; Tue, 23 Apr 2019 13:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbfDWN2J (ORCPT ); Tue, 23 Apr 2019 09:28:09 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44384 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbfDWN2I (ORCPT ); Tue, 23 Apr 2019 09:28:08 -0400 Received: by mail-wr1-f66.google.com with SMTP id c5so11355379wrs.11 for ; Tue, 23 Apr 2019 06:28:07 -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=Bd8/O3nFKfDnlyx4P3RcT9dgrqw31uFQ79XNZXVW2Ko=; b=Phxw44u2zcn38pPSgzY5BxNbLsa7Pzv60UjqsgL6F+nzAIUMGey/mXgBpeZ1HuOjRx docBX2mFDYZUeIWSY+R65xCBAcyoUPisRvHkoP28ibUG+ssk7Hm2BrBxOdBX0Hd1D4A7 Z5apGS4RAqgMZYsMoHRIoHIeNcKPWseauv+F3ozFWPl5bPgs1PTINqsVyZqArKwvaz6w zEGagqO4b4fmnr9so/0XB7wm5i8rerWFO/yWam8XZADlVB8jbT3Na0Z10krI2Phg/YpJ OOVLhjnM+VQb2UcYp1paE3k3mvkPlLe3Bnh7DWeRlvBE558vE3ObCBqNPDtAkoh9ZaNN G4pA== X-Gm-Message-State: APjAAAVlPVXCW9DERIwDlNZUWMUqXQMqT3eO0WXQbQ6LM8aO7Yu8mQ+x rYbgXNFQ9+fGmIddhmFW/bYkZUkg X-Google-Smtp-Source: APXvYqwSBD+5MuEQQp1PVa9pbVhj0CbxkZcdtt3C9c+k7b8qnhCBEnJeMMYIoY8PfUzBFIX4U2z5zw== X-Received: by 2002:adf:fe02:: with SMTP id n2mr17043237wrr.3.1556026086996; Tue, 23 Apr 2019 06:28:06 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w11sm31222231wre.15.2019.04.23.06.28.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 06:28:06 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov , Slavomir Kaslev Subject: [PATCH 5/5] kernel-shark: Remember the paths used by the Open-File dialogs. Date: Tue, 23 Apr 2019 16:27:41 +0300 Message-Id: <20190423132741.17864-6-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423132741.17864-1-ykaradzhov@vmware.com> References: <20190423132741.17864-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 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();