From patchwork Fri Apr 19 13:50:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909641 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 176AA14DB for ; Fri, 19 Apr 2019 19:15:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AD2B28E03 for ; Fri, 19 Apr 2019 19:15:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F30E028E04; Fri, 19 Apr 2019 19:15:52 +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 6A86728E05 for ; Fri, 19 Apr 2019 19:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725961AbfDSTPw (ORCPT ); Fri, 19 Apr 2019 15:15:52 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41852 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728924AbfDSTPv (ORCPT ); Fri, 19 Apr 2019 15:15:51 -0400 Received: by mail-wr1-f67.google.com with SMTP id c12so1805686wrt.8 for ; Fri, 19 Apr 2019 12:15:50 -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=NhuQmTFWm66fHbbjbnxa6eNNlgwmjwpkuWGTkehdv4M=; b=C3FZb3oteqqGInsXQtomNqAO8FEHGW2SbJEim5eeeiBFw8XS3Av6UICSn0ucLdpVKV qQAisTTTHABKuYMCujs6NvtoaStoOMojJ9NY02omJ33zN2kWQzQqv1a2aX3XkH4Tw5Dw mvs5dUG+J5iV1KWKj685xPoGvFFxWeD1kXbQv/Q0JrR4AGIzmJzAvatHLqXifCuImsT9 Oq7abn8lw9whe+PhcOHK+ZyA3UVoIXiTiKUvGFGeu6ZbH9wSFR6k/ghAUELKlFg01f62 UYfjYKjKpMGjKgzKrSXjkazxCHHIKsJP4PVsTeFoN2kJr1/wpyXqumpZ+1IBCl2Gu8XB hQnQ== X-Gm-Message-State: APjAAAXJPLdqO4ePbbbpD3oQf2+7iGUMDBiaHzFuPN5iFgoFhKFcSjU5 QIcwFRAMivduRpcqypvmHHC1IIDd X-Google-Smtp-Source: APXvYqwHWk/QqT/Byx7t5j3MQtJ62nV/8JFWobyq5NSBQZsfA05JAkS/sRXfl7VV/AM76HwEaNEDIw== X-Received: by 2002:adf:e88b:: with SMTP id d11mr3121387wrm.327.1555681856469; Fri, 19 Apr 2019 06:50:56 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:50:55 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH v3 1/8] kernel-shark: Configuration information in ${HOME}/.cache/kernelshark Date: Fri, 19 Apr 2019 16:50:29 +0300 Message-Id: <20190419135036.19340-2-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 By default the "Last session" configuration file will be saved in ${HOME}/.cache/kernelshark. If ${HOME}/.cache/kernelshark doesn't exist, it will be created automatically. The user can select another directory to be used to store the cached data. This can be done by setting the environment variable KS_USER_CACHE_DIR. In this case if the path (the value of KS_USER_CACHE_DIR) doesn't exist the user will be asked before create it. Suggested-by: Steven Rostedt (VMware) Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsMainWindow.cpp | 68 +++++++++++++++++++++++++++---- kernel-shark/src/KsMainWindow.hpp | 4 ++ 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index 7afb721..c839aca 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -133,13 +133,15 @@ KsMainWindow::KsMainWindow(QWidget *parent) KsMainWindow::~KsMainWindow() { kshark_context *kshark_ctx(nullptr); - QString file = KS_CONF_DIR; + QString file = lastSessionFile(); - file += "/lastsession.json"; + if (!file.isEmpty()) { + QByteArray fileBA = file.toLocal8Bit(); - _updateSession(); - kshark_save_config_file(file.toLocal8Bit().data(), - _session.getConfDocPtr()); + _updateSession(); + kshark_save_config_file(fileBA.data(), + _session.getConfDocPtr()); + } _data.clear(); @@ -368,12 +370,60 @@ void KsMainWindow::_open() loadDataFile(fileName); } -void KsMainWindow::_restoreSession() +QString KsMainWindow::_getCacheDir() +{ + QString dir; + + auto lamMakePath = [&] (bool ask) { + if (ask) { + QMessageBox::StandardButton reply; + QString err("KernelShark cache directory not found!\n"); + QString question = + QString("Do you want to create %1").arg(dir); + + reply = QMessageBox::question(this, "KernelShark", + err + question, + QMessageBox::Yes | + QMessageBox::No); + + if (reply == QMessageBox::No) { + dir.clear(); + return; + } + } + + QDir().mkpath(dir); + }; + + dir = getenv("KS_USER_CACHE_DIR"); + if (!dir.isEmpty()) { + if (!QDir(dir).exists()) + lamMakePath(true); + } else { + dir = QString(QDir::homePath()) + + "/.cache/kernelshark"; + if (!QDir(dir).exists()) + lamMakePath(false); + } + + return dir; +} + +/** Get the description file of the last session. */ +QString KsMainWindow::lastSessionFile() { - QString file = KS_CONF_DIR; - file += "/lastsession.json"; + QString file; - loadSession(file); + file = _getCacheDir(); + if (!file.isEmpty()) + file += "/lastsession.json"; + + return file; +} + +void KsMainWindow::_restoreSession() +{ + loadSession(lastSessionFile()); _graph.updateGeom(); } diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp index 78cd442..ec6506e 100644 --- a/kernel-shark/src/KsMainWindow.hpp +++ b/kernel-shark/src/KsMainWindow.hpp @@ -37,6 +37,8 @@ public: void loadSession(const QString &fileName); + QString lastSessionFile(); + /** * @brief * @@ -230,6 +232,8 @@ private: void _filterSyncCBoxUpdate(kshark_context *kshark_ctx); + QString _getCacheDir(); + private slots: void _captureFinished(int, QProcess::ExitStatus); }; From patchwork Fri Apr 19 13:50:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909681 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 B4F0C1850 for ; Fri, 19 Apr 2019 19:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F1A28AF6 for ; Fri, 19 Apr 2019 19:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A747F28E1C; Fri, 19 Apr 2019 19:41:35 +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 53D1628E18 for ; Fri, 19 Apr 2019 19:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727737AbfDSTle (ORCPT ); Fri, 19 Apr 2019 15:41:34 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52961 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbfDSTle (ORCPT ); Fri, 19 Apr 2019 15:41:34 -0400 Received: by mail-wm1-f66.google.com with SMTP id a184so7190239wma.2 for ; Fri, 19 Apr 2019 12:41:33 -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=ZholOoeJP1gQpb7Y3E228BQvRpmVngdqPJVFbaYLOMc=; b=IvwkzY14RKN+wDtLmOKGUtHQi6eUGEGV9K2YRFNs6M+PFbM5MVKjKv1vfK8ubVP36H vEWCeMcZ8R9a0xmEg7GkWJwFAJBEC0wq/kalHA+5b2cN0oxv4T1fpiMpAEZJHiaVAuu0 YfxxPrL5z8irmzgisZP4fsWxZpyjHD7/F3WyeXotM/rUfsuMsY6puWQ9QXxHmm0yYMii TJhMazK2mZw9oZ59W4ntcfUwGygPBgkEgnBEVIsVY9yS68laLpVkCCdd2VFV/DCHSqrD T1D2P3a5ug5xJqPFnAhRFlSgDoc/e+pWWmfrJKMNqFrDV3U2B3o+Zqg1bCSd/mJmflCM +0OQ== X-Gm-Message-State: APjAAAXWD2z6MFfjj6pfZHQb00kLqDUxMUj1J0+u8pErflwO0pkgiC3V tCaU+yqHzij10kOO1Qc0k3/wrSLp X-Google-Smtp-Source: APXvYqxSSG/LB6NOMc/O/0mYcdRwGDrYCahYou0UfHUg+jE/yamVMQk6+f7EKsTcbRNTGkv/+aVaDg== X-Received: by 2002:a1c:a683:: with SMTP id p125mr2802471wme.151.1555681858050; Fri, 19 Apr 2019 06:50:58 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.50.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:50:57 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH v3 2/8] kernel-shark: Remove the definition of KS_CONF_DIR Date: Fri, 19 Apr 2019 16:50:30 +0300 Message-Id: <20190419135036.19340-3-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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_CONF_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/CMakeLists.txt | 5 ----- kernel-shark/build/deff.h.cmake | 3 --- 2 files changed, 8 deletions(-) diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt index 10cb696..1aee858 100644 --- a/kernel-shark/CMakeLists.txt +++ b/kernel-shark/CMakeLists.txt @@ -12,11 +12,6 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n") set(KS_DIR ${CMAKE_SOURCE_DIR}) -# Make a directory to hold configuration files. To change this do: -# cmake .. -DKS_CONF_DIR=/your/preferred/path -set(KS_CONF_DIR "${KS_DIR}/.ksconf" CACHE STRING "Directory for configuration files.") -file(MAKE_DIRECTORY ${KS_CONF_DIR}) - include(${KS_DIR}/build/FindTraceCmd.cmake) include(${KS_DIR}/build/FindJSONC.cmake) diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index 80d624c..8041cfc 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -14,9 +14,6 @@ /** KernelShark source code path. */ #cmakedefine KS_DIR "@KS_DIR@" -/** KernelShark configuration directory path. */ -#cmakedefine KS_CONF_DIR "@KS_CONF_DIR@" - /** Location of the trace-cmd executable. */ #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@" From patchwork Fri Apr 19 13:50:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909491 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 CD08913B5 for ; Fri, 19 Apr 2019 18:41:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2D3F28CDD for ; Fri, 19 Apr 2019 18:41:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B750328DCE; Fri, 19 Apr 2019 18:41:10 +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 44F7A28CDD for ; Fri, 19 Apr 2019 18:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727458AbfDSSlK (ORCPT ); Fri, 19 Apr 2019 14:41:10 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55351 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbfDSSlJ (ORCPT ); Fri, 19 Apr 2019 14:41:09 -0400 Received: by mail-wm1-f65.google.com with SMTP id o25so7056127wmf.5 for ; Fri, 19 Apr 2019 11:41:08 -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=lcmg/9QJVIq6qSZOb+glBNZ1KV4rVjONuDQaoDa12R0=; b=ka9aZ36nPaswyeVXZvO/a9hhRctxPY8gu78qEw4qhzk41Z6iAZD8/xrEBkP2q0Y4tw a+7cOkA9Na4Kt+355qawG+W5Y6AeuCEUU1SWxbJgSimzOVmayadCirfVFvKi+Mxj7EXA NQrIc7rnLH3UjvbaI8zeiKSjZR1RQ5p+vOsYd451XRhGi2jp8Y3ZdegyNevtq1gOH3iJ u6csc0BAw6SLFiYpvSZ2V74PSsb1TjeuYG/z7X/YzPB0Q3PtofXBWe30UlRlTXnzNFk7 vxEdKaX5wkBT9jRGwmh5xeMn1vRocSp884aixHr3JekUAW2HDeMK+2uUQmgttAhkU3QK YT4Q== X-Gm-Message-State: APjAAAWhMZ9T/hTAqTOxBTWGdkg5gcRtpvfFQ6Js7A2pFCBfwoZPnmi8 luFmzulnSjyu2WCJKr+RE5fyUWT+ X-Google-Smtp-Source: APXvYqw6V55lbsUQXpwsnz8giKiRKyA457yJm+PfXUhnTew6one/shDbLm0gGKn2mLgTMhW1THRPLg== X-Received: by 2002:a7b:c769:: with SMTP id x9mr2879369wmk.103.1555681859454; Fri, 19 Apr 2019 06:50:59 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.50.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:50:58 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH v3 3/8] kernel-shark: Add logic for the initial path of Open-File dialogs Date: Fri, 19 Apr 2019 16:50:31 +0300 Message-Id: <20190419135036.19340-4-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 the source code directory, all Open-File dialogs will start there. If the application has been started from its installation location, all Open-File dialogs will start at ${HOME}. Suggested-by: Steven Rostedt (VMware) Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsCaptureDialog.cpp | 6 +++--- kernel-shark/src/KsMainWindow.cpp | 12 ++++++------ kernel-shark/src/KsUtils.hpp | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index 1272c2e..57bf7c7 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -208,7 +208,7 @@ void KsCaptureControl::_importSettings() /* Get the configuration document. */ fileName = QFileDialog::getOpenFileName(this, "Import from Filter", - KS_DIR, + KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -259,7 +259,7 @@ void KsCaptureControl::_exportSettings() QString fileName = QFileDialog::getSaveFileName(this, "Export to File", - KS_DIR, + KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -314,7 +314,7 @@ void KsCaptureControl::_browse() QString fileName = QFileDialog::getSaveFileName(this, "Save File", - KS_DIR, + KsUtils::dialogDir(), "trace-cmd files (*.dat);;All files (*)"); if (!fileName.isEmpty()) diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp index c839aca..65ac71a 100644 --- a/kernel-shark/src/KsMainWindow.cpp +++ b/kernel-shark/src/KsMainWindow.cpp @@ -363,7 +363,7 @@ void KsMainWindow::_open() QString fileName = QFileDialog::getOpenFileName(this, "Open File", - KS_DIR, + KsUtils::dialogDir(), "trace-cmd files (*.dat);;All files (*)"); if (!fileName.isEmpty()) @@ -432,7 +432,7 @@ void KsMainWindow::_importSession() QString fileName = QFileDialog::getOpenFileName(this, "Import Session", - KS_DIR, + KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -463,7 +463,7 @@ void KsMainWindow::_exportSession() QString fileName = QFileDialog::getSaveFileName(this, "Export Filter", - KS_DIR, + KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -512,7 +512,7 @@ void KsMainWindow::_importFilter() if (!kshark_instance(&kshark_ctx)) return; - fileName = QFileDialog::getOpenFileName(this, "Import Filter", KS_DIR, + fileName = QFileDialog::getOpenFileName(this, "Import Filter", KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -540,7 +540,7 @@ void KsMainWindow::_exportFilter() if (!kshark_instance(&kshark_ctx)) return; - fileName = QFileDialog::getSaveFileName(this, "Export Filter", KS_DIR, + fileName = QFileDialog::getSaveFileName(this, "Export Filter", KsUtils::dialogDir(), "Kernel Shark Config files (*.json);;"); if (fileName.isEmpty()) @@ -861,7 +861,7 @@ void KsMainWindow::_pluginAdd() fileNames = QFileDialog::getOpenFileNames(this, "Add KernelShark plugins", - KS_DIR, + KsUtils::dialogDir(), "KernelShark Plugins (*.so);;"); if (fileNames.isEmpty()) diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index c8b5e88..77048ab 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -111,6 +111,21 @@ inline QString Ts2String(int64_t ts, int prec) bool matchCPUVisible(struct kshark_context *kshark_ctx, struct kshark_entry *e, int cpu); + +/** + * @brief Get the directory to be used when opening QFileDialog. If the + * application has been started from the source code directory, all + * Open File dialogs will start there. If the application has been + * started from its installation location, all Open File dialogs will + * start at ${HOME}. + */ +inline QString dialogDir() +{ + QString path = QCoreApplication::applicationFilePath(); + + return path.contains(KS_DIR) ? KS_DIR : QDir::homePath(); +} + }; // KsUtils /** Identifier of the Dual Marker active state. */ From patchwork Fri Apr 19 13:50:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909653 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 2DE0F14DB for ; Fri, 19 Apr 2019 19:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2146C28A2E for ; Fri, 19 Apr 2019 19:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154AA28A5F; Fri, 19 Apr 2019 19:19:49 +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 905EC28A2E for ; Fri, 19 Apr 2019 19:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727357AbfDSTTs (ORCPT ); Fri, 19 Apr 2019 15:19:48 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55068 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfDSTTs (ORCPT ); Fri, 19 Apr 2019 15:19:48 -0400 Received: by mail-wm1-f65.google.com with SMTP id c1so7142927wml.4 for ; Fri, 19 Apr 2019 12:19:46 -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=O0UuVyUaj6gRC5oVMlVkfjA3JGzFPAwr7A83t9IIslI=; b=OYdrnUFsLMLTw29zsGtbl0XGNTayvTWEjoCqL3YwIwlhFQ5BUQAoG1JoYtx4JsEIkS 3wkl/SttHThDOtLV8jPxoK5g5ng7nIH45oRrsHP1B6t4zNbQ8/FSB5xZN+zbxoRycV31 Ryy0BA+h8dtq4fo1eNkyLhNoqtqk1Cv3gQpKVfE4YFkZRwv+LeAGAX/t4BpHNmx0YqTb baYOxD9q65A1LtYi0A9ZByZXIuTFaUi+4+48Gdj2Ls5Xl193/tTngiNiwRO3/SdWkL8s fR/neICfuKqjiygPdk4FCKnAQW8w4w2Dv4CW32R5ebzCkDaoZm5T1rlau9YwFA6NqI1h SSOQ== X-Gm-Message-State: APjAAAU4dHHSGy8DpIk9QWYjv+4xsBYUFqEvvi+d0wR0mOQjxjCSD4lz 6IECkfHHn6DM4MJ1THvJetEQI2jK X-Google-Smtp-Source: APXvYqzsKmhQd4pOkE6TH3zt4PrEKH0XWWDiKNFh6I4AiEpITAwYt6Of9RvL62lSP3KtMvu+pXW1tw== X-Received: by 2002:a7b:ce84:: with SMTP id q4mr2900033wmj.41.1555681860670; Fri, 19 Apr 2019 06:51:00 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.51.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:51: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 v3 4/8] kernel-shark: Add logic for the plugins search path Date: Fri, 19 Apr 2019 16:50:32 +0300 Message-Id: <20190419135036.19340-5-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 the source code directory, all build-in plugins will be loaded from kernel-shark/lib/ If the application has been started from its installation location, all build-in plugins will be loaded from INSTALL_PREFIX/lib/kshark/plugins/ Signed-off-by: Yordan Karadzhov --- kernel-shark/build/deff.h.cmake | 3 +++ kernel-shark/src/KsUtils.cpp | 35 +++++++++++++++++-------- kernel-shark/src/KsUtils.hpp | 1 + kernel-shark/src/plugins/CMakeLists.txt | 2 +- 4 files changed, 29 insertions(+), 12 deletions(-) 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@" diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index 6af0c66..b05c0dc 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -423,13 +423,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; @@ -458,13 +457,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; @@ -487,6 +485,23 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx) lamUregUser); } +char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n) +{ + QString path = QCoreApplication::applicationFilePath(); + std::string pluginStr = plugin.toStdString(); + char *lib; + + if (path.contains(KS_DIR)) { + n = asprintf(&lib, "%s/lib/plugin-%s.so", + KS_DIR, 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. * @@ -508,8 +523,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; @@ -570,8 +584,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; @@ -579,7 +592,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 77048ab..019bde8 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -238,6 +238,7 @@ signals: private: void _parsePluginList(); + char *_pluginLibFromName(const QString &plugin, int &n); template void _forEachInList(const QStringList &pl, 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 Fri Apr 19 13:50:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909675 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 F0A3A1850 for ; Fri, 19 Apr 2019 19:34:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3DAF2896D for ; Fri, 19 Apr 2019 19:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7E3428E05; Fri, 19 Apr 2019 19:34: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 177A928DB2 for ; Fri, 19 Apr 2019 19:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbfDSTeg (ORCPT ); Fri, 19 Apr 2019 15:34:36 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33223 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfDSTeg (ORCPT ); Fri, 19 Apr 2019 15:34:36 -0400 Received: by mail-wm1-f66.google.com with SMTP id z6so9540142wmi.0 for ; Fri, 19 Apr 2019 12:34: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=AvGVFLM+dfFF/jKTzW+SOqyfsLgBn7rS8Uryt335C7s=; b=R7crRJSAS7gthi7r9HNRRzoQYTk+1Vzcju9pQYE/PIFW3DjtefHmHJEJy4fvbLeIGK 5hayETJ3ZpiZ0rcHyzUOSLuUKl7JhQlgqXDRIKwhbFSBYLk5w4zkmokBY0G0b5WGSON/ /ftJSG/B8vktRLeF/6xbaCZqLgDquh5v2MrhsiGOW1q4CRGTImXxaps5pfN2PE1cfh3c 3sJonQzhNFT/cxcuzbjBvNg7LlRle82V1rNV620T2dyzHlJTVTmObrLAmm9L18FGDubX QwRmC6jB9Zl/mN8iu+TZJcZ3UGgtUb2kTP4mhGoCXHg99JE4bm/jWK+TaI87qikzPyQB bvTQ== X-Gm-Message-State: APjAAAVxWLvp4/ymhS1q6lqwA9b3L1+CVK8FLtTfWzIyh4Q+qIUBql/t dxeZwL+cteCGMdAGMh+VZkt3JNzE X-Google-Smtp-Source: APXvYqz+2qs5rw8GzGuCOl3iV58o8+r4tFdttDlZ81+8/1aK/nogBazEjmGXHFypwHyFs4pT3+ljDA== X-Received: by 2002:a7b:c7d0:: with SMTP id z16mr2894458wmk.136.1555681861963; Fri, 19 Apr 2019 06:51:01 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:51:01 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH v3 5/8] kernel-shark: Rename KS_DIR to KS_SOURCE_DIR Date: Fri, 19 Apr 2019 16:50:33 +0300 Message-Id: <20190419135036.19340-6-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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_SOURCE_DIR is a more appropriate name since it defines the path to the KernelShark source code used to build the application. Signed-off-by: Yordan Karadzhov --- kernel-shark/CMakeLists.txt | 32 ++++++++++++++++---------------- kernel-shark/build/deff.h.cmake | 2 +- kernel-shark/src/CMakeLists.txt | 10 +++++----- kernel-shark/src/KsUtils.cpp | 4 ++-- kernel-shark/src/KsUtils.hpp | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt index 1aee858..825cabd 100644 --- a/kernel-shark/CMakeLists.txt +++ b/kernel-shark/CMakeLists.txt @@ -10,10 +10,10 @@ set(KS_VERSION_PATCH 8) set(KS_VERSION_STRING ${KS_VERSION_MAJOR}.${KS_VERSION_MINOR}.${KS_VERSION_PATCH}) message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n") -set(KS_DIR ${CMAKE_SOURCE_DIR}) +set(KS_SOURCE_DIR ${CMAKE_SOURCE_DIR}) -include(${KS_DIR}/build/FindTraceCmd.cmake) -include(${KS_DIR}/build/FindJSONC.cmake) +include(${KS_SOURCE_DIR}/build/FindTraceCmd.cmake) +include(${KS_SOURCE_DIR}/build/FindJSONC.cmake) find_package(Doxygen) @@ -29,8 +29,8 @@ if (Qt5Widgets_FOUND) endif (Qt5Widgets_FOUND) -set(LIBRARY_OUTPUT_PATH "${KS_DIR}/lib") -set(EXECUTABLE_OUTPUT_PATH "${KS_DIR}/bin") +set(LIBRARY_OUTPUT_PATH "${KS_SOURCE_DIR}/lib") +set(EXECUTABLE_OUTPUT_PATH "${KS_SOURCE_DIR}/bin") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -std=c++11 -pthread") @@ -49,8 +49,8 @@ endif (NOT _DEBUG) SET(CMAKE_INSTALL_RPATH "${_INSTALL_PREFIX}/lib/kshark/") SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -include_directories(${KS_DIR}/src/ - ${KS_DIR}/build/src/ +include_directories(${KS_SOURCE_DIR}/src/ + ${KS_SOURCE_DIR}/build/src/ ${JSONC_INCLUDE_DIR} ${TRACECMD_INCLUDE_DIR} ${TRACEEVENT_INCLUDE_DIR}) @@ -60,8 +60,8 @@ message(STATUS "C flags : " ${CMAKE_C_FLAGS}) message(STATUS "CXX flags : " ${CMAKE_CXX_FLAGS}) message(STATUS "Linker flags : " ${CMAKE_EXE_LINKER_FLAGS}) -add_subdirectory(${KS_DIR}/src) -add_subdirectory(${KS_DIR}/examples) +add_subdirectory(${KS_SOURCE_DIR}/src) +add_subdirectory(${KS_SOURCE_DIR}/examples) if (_DOXYGEN_DOC AND DOXYGEN_FOUND) @@ -72,16 +72,16 @@ if (_DOXYGEN_DOC AND DOXYGEN_FOUND) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES - "${KS_DIR}/doc/dox_build.log" - "${KS_DIR}/doc/html" - "${KS_DIR}/doc/latex") + "${KS_SOURCE_DIR}/doc/dox_build.log" + "${KS_SOURCE_DIR}/doc/html" + "${KS_SOURCE_DIR}/doc/latex") endif () -configure_file( ${KS_DIR}/build/ks.desktop.cmake - ${KS_DIR}/kernelshark.desktop) +configure_file(${KS_SOURCE_DIR}/build/ks.desktop.cmake + ${KS_SOURCE_DIR}/kernelshark.desktop) -configure_file( ${KS_DIR}/build/org.freedesktop.kshark-record.policy.cmake - ${KS_DIR}/org.freedesktop.kshark-record.policy) +configure_file(${KS_SOURCE_DIR}/build/org.freedesktop.kshark-record.policy.cmake + ${KS_SOURCE_DIR}/org.freedesktop.kshark-record.policy) message("") diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index ba211f4..47c9d9f 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -12,7 +12,7 @@ #cmakedefine KS_VERSION_STRING "@KS_VERSION_STRING@" /** KernelShark source code path. */ -#cmakedefine KS_DIR "@KS_DIR@" +#cmakedefine KS_SOURCE_DIR "@KS_SOURCE_DIR@" /** KernelShark installation prefix path. */ #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@" diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt index b7dbd7e..5f97916 100644 --- a/kernel-shark/src/CMakeLists.txt +++ b/kernel-shark/src/CMakeLists.txt @@ -81,13 +81,13 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND) RUNTIME DESTINATION ${_INSTALL_PREFIX}/bin/ LIBRARY DESTINATION ${_INSTALL_PREFIX}/lib/kshark/) - install(FILES "${KS_DIR}/kernelshark.desktop" + install(FILES "${KS_SOURCE_DIR}/kernelshark.desktop" DESTINATION /usr/share/applications/) - install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy" + install(FILES "${KS_SOURCE_DIR}/org.freedesktop.kshark-record.policy" DESTINATION /usr/share/polkit-1/actions/) - install(PROGRAMS "${KS_DIR}/bin/kshark-su-record" + install(PROGRAMS "${KS_SOURCE_DIR}/bin/kshark-su-record" DESTINATION ${_INSTALL_PREFIX}/bin/) endif (Qt5Widgets_FOUND AND Qt5Network_FOUND) @@ -96,5 +96,5 @@ add_subdirectory(plugins) find_program(DO_AS_ROOT pkexec) -configure_file( ${KS_DIR}/build/deff.h.cmake - ${KS_DIR}/src/KsCmakeDef.hpp) +configure_file( ${KS_SOURCE_DIR}/build/deff.h.cmake + ${KS_SOURCE_DIR}/src/KsCmakeDef.hpp) diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index b05c0dc..387a1e0 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -491,9 +491,9 @@ char *KsPluginManager::_pluginLibFromName(const QString &plugin, int &n) std::string pluginStr = plugin.toStdString(); char *lib; - if (path.contains(KS_DIR)) { + if (path.contains(KS_SOURCE_DIR)) { n = asprintf(&lib, "%s/lib/plugin-%s.so", - KS_DIR, pluginStr.c_str()); + KS_SOURCE_DIR, pluginStr.c_str()); } else { n = asprintf(&lib, "%s/lib/kshark/plugins/plugin-%s.so", _INSTALL_PREFIX, pluginStr.c_str()); diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index 019bde8..e776d62 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -123,7 +123,7 @@ inline QString dialogDir() { QString path = QCoreApplication::applicationFilePath(); - return path.contains(KS_DIR) ? KS_DIR : QDir::homePath(); + return path.contains(KS_SOURCE_DIR) ? KS_SOURCE_DIR : QDir::homePath(); } }; // KsUtils From patchwork Fri Apr 19 13:50:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909087 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 0D5AD14DB for ; Fri, 19 Apr 2019 18:17:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0494C28D3F for ; Fri, 19 Apr 2019 18:17:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDA3728D9A; Fri, 19 Apr 2019 18:17:20 +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 940B228D3F for ; Fri, 19 Apr 2019 18:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbfDSSRT (ORCPT ); Fri, 19 Apr 2019 14:17:19 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40688 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727287AbfDSSRT (ORCPT ); Fri, 19 Apr 2019 14:17:19 -0400 Received: by mail-wr1-f67.google.com with SMTP id h4so7814500wre.7 for ; Fri, 19 Apr 2019 11:17:18 -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=vohe4X2m1SR1JylOFC13tql3lHwVXjFouFgd4+HFAZM=; b=FW2LUpDVr9j6POmoytTHFRhorZCAz+O/7RTSLCJz9RnY251gt7CsdAv5le3TbkrnX1 50h+sgp59+0B6TrRffQumAULiO0KlC7bn+w5dHz1xpbbxrdlWu1HR4KBEMTteghAjcJM KWANWQB8ukj1BQ/10bqBpFGZZ3o/t8zXoi9UgycwycvMUAnMLExltUALjCKcY2itGnym tMGNUIT2SG1ruOX76ZKCxpY7ztgzHEi5XYZ6ZWmqGVJdErAxhOw2wXctTSJTfLkldBol YZAfNGuYct1+d8Qb6Wkyj7wfPdfuAN1TGoEiMNLI4D6gKpDRfzT1oHhYTA0I3EyS3Od2 /tNg== X-Gm-Message-State: APjAAAW1khzN6zrg4EdkjB/WB/4TLoL1FZhbjhswzdpQ525SgMSSV8U+ +mWiOgTFnK92Egkqh8R2zKzQ5KgZ X-Google-Smtp-Source: APXvYqzLt8FjCaWzocdWfe2ZoabZfC3JcgykmglNqRi3QcjOj2OL199vBoD0voELH3tMSyB7pcXXrw== X-Received: by 2002:a5d:4b01:: with SMTP id v1mr3201711wrq.48.1555681863138; Fri, 19 Apr 2019 06:51:03 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.51.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:51: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 v3 6/8] kernel-shark: Load Last Session from command line Date: Fri, 19 Apr 2019 16:50:34 +0300 Message-Id: <20190419135036.19340-7-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 ./kernelshark -l will load directly the Last Session Signed-off-by : Yordan Karadzhov --- kernel-shark/src/kernelshark.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel-shark/src/kernelshark.cpp b/kernel-shark/src/kernelshark.cpp index 2ec91de..1ec6678 100644 --- a/kernel-shark/src/kernelshark.cpp +++ b/kernel-shark/src/kernelshark.cpp @@ -28,6 +28,7 @@ void usage(const char *prog) printf(" -p register plugin, use plugin name, absolute or relative path\n"); printf(" -u unregister plugin, use plugin name or absolute path\n"); printf(" -s import a session\n"); + printf(" -l import the last session\n"); } int main(int argc, char **argv) @@ -40,7 +41,7 @@ int main(int argc, char **argv) int c; bool fromSession = false; - while ((c = getopt(argc, argv, "hvi:p:u:s:")) != -1) { + while ((c = getopt(argc, argv, "hvi:p:u:s:l")) != -1) { switch(c) { case 'h': usage(argv[0]); @@ -65,6 +66,12 @@ int main(int argc, char **argv) case 's': ks.loadSession(QString(optarg)); fromSession = true; + break; + + case 'l': + ks.loadSession(ks.lastSessionFile()); + fromSession = true; + break; default: break; From patchwork Fri Apr 19 13:50:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909047 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 D125C17EE for ; Fri, 19 Apr 2019 18:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1F2E28D98 for ; Fri, 19 Apr 2019 18:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B682828D9A; Fri, 19 Apr 2019 18:15:56 +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 52E9428D3F for ; Fri, 19 Apr 2019 18:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725280AbfDSSPm (ORCPT ); Fri, 19 Apr 2019 14:15:42 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45531 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbfDSSPj (ORCPT ); Fri, 19 Apr 2019 14:15:39 -0400 Received: by mail-wr1-f67.google.com with SMTP id s15so7774611wra.12 for ; Fri, 19 Apr 2019 11:15:38 -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=xwR7bQog9GKuWlI9nXN+mzLfy78RsHPv56l1jmn9Kbg=; b=KqlFTdwtI1LoNON3Jro/QP8pj3baGUYMCJeRq9HeIeTUunyVp8smWeEINhLhjqC+nU iLyxC/qNZidT/1gm1YwkBBsOg59jcsfq4jVy9MddSmC5bHAtdFsN8son5SDh4wkzbPRk 4Lk4vDoTvSsvW9UgBnSacZTdrCIvYs/omnetXcnhqetc3LS3NA4/BT4TIkfyp4Y1FUWF DF0K+WIz3+sI1QcFCgC2XjTo3Xfk9KWNoHbhbNsCitLoHfNwqkL9gHsF7tE1cHnlO8CZ RV5ywmWFbQresWMDxx1FyyG9Zvu9xFZPRJoh9G//S+348D+NSSclig4z7H23TENuR6K2 Mq7Q== X-Gm-Message-State: APjAAAUPTugLk3Ufp5ZHMF8DIrwM40WAc5vBmNAgMCcfJgwGShqPQdgn Nrk1AvGs7dEb2QINFC4+WAuXKd6J X-Google-Smtp-Source: APXvYqxvWiWzi6FCOXoZaaqKuw+z4h3Ng6I53UDD0XhN5usXzoe5DKlfvS8+mkrqi28y6c5Hfa6lkw== X-Received: by 2002:adf:f88c:: with SMTP id u12mr3245088wrp.235.1555681864429; Fri, 19 Apr 2019 06:51:04 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.51.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:51:04 -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 v3 7/8] kernel-shark: Use proper searching condition when the dataset is small Date: Fri, 19 Apr 2019 16:50:35 +0300 Message-Id: <20190419135036.19340-8-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 data-set is small we do not want to have the overhead added by the update of the progress bar. Because of this we bypass the state switching of the FSM. However, in this case the the search condition has to be updated by hand. Reported-by: Slavomir Kaslev Fixes: 1615b02b (kernel-shark-qt: Optimize the search in a case of a small data-set) Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsTraceViewer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel-shark/src/KsTraceViewer.cpp b/kernel-shark/src/KsTraceViewer.cpp index 4e2c93e..04a38b8 100644 --- a/kernel-shark/src/KsTraceViewer.cpp +++ b/kernel-shark/src/KsTraceViewer.cpp @@ -596,8 +596,11 @@ size_t KsTraceViewer::_searchItems() if (_proxyModel.rowCount({}) < KS_SEARCH_SHOW_PROGRESS_MIN) { /* * This is a small data-set. Do a single-threaded search - * without showing the progress. + * without showing the progress. We will bypass the state + * switching, hence the search condition has to be updated + * by hand. */ + _searchFSM.updateCondition(); _proxyModel.search(column, searchText, _searchFSM.condition(), &_matchList, nullptr, nullptr); } else { From patchwork Fri Apr 19 13:50:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10909677 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 6571813B5 for ; Fri, 19 Apr 2019 19:38:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5979428DB2 for ; Fri, 19 Apr 2019 19:38:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A97828E05; Fri, 19 Apr 2019 19:38:32 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI 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 872D828DB2 for ; Fri, 19 Apr 2019 19:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbfDSTiS (ORCPT ); Fri, 19 Apr 2019 15:38:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35150 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbfDSTiS (ORCPT ); Fri, 19 Apr 2019 15:38:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id o12so4704696wrn.2 for ; Fri, 19 Apr 2019 12:38:17 -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=NpbI2S9bGcE5lSFNoNpvOl10ZZyAD69vRiUg/1cQPf8=; b=uV3XiXpco25WJriMSCHJlxy7ElqcX2XWQcKdvspGMbsYhkRInhcv3abC10W4KXDeVb OF+OwodfbMWUtq21flb/xatNpz+9nLgO9KDMuwEQy0liHNoZXbV2M1iBN7QAIdWQ+Xgm 7IfVh3Vaj5mHYDKjuDM2chkeotW/q/1GwwTcQfKRuFkrkDZLTqwztWWhAIyX+mkg+CMp iy5Bx18BwEfQA1ImHST72bo4AW6yqsw57tYBVEx6s5V0Gozr46b3g8k+JnPuQHziSpAc FDnkO4Wgx4lzOHfsvSkQL87Yg48OutRfOHF88roV9k6XOOczshzaEqbLhPqUW6J0KgFN xmIw== X-Gm-Message-State: APjAAAVhwVqryo+Pne34qIq+W2ez/ueHpomVxRgzeZaXMB1QeBrOyTWU aQNEbAoEQI0CJns4jUclZa1kPD5F X-Google-Smtp-Source: APXvYqwgoP/5Fs3y/3X1NO609vMfuHpkuDai6s0b/3yoYZZ7AwZ2dkN0sQveL9Gsr1b9xzrk7Q5Ksg== X-Received: by 2002:a5d:52ce:: with SMTP id r14mr3262232wrv.224.1555681865688; Fri, 19 Apr 2019 06:51:05 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id g132sm4120496wme.3.2019.04.19.06.51.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 06:51: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 v3 8/8] kernel-shark: Handle the case when the marker points to a filtered entry Date: Fri, 19 Apr 2019 16:50:36 +0300 Message-Id: <20190419135036.19340-9-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190419135036.19340-1-ykaradzhov@vmware.com> References: <20190419135036.19340-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 Markers can point to entries that are filtered out. When switching the marker it may happen that new Active Marker points to an entry that is filtered. In this case no actions must be taken and a warning message for the user must be displayed. Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsTraceViewer.cpp | 27 +++++++++++++++++---------- kernel-shark/src/KsTraceViewer.hpp | 2 ++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/kernel-shark/src/KsTraceViewer.cpp b/kernel-shark/src/KsTraceViewer.cpp index 04a38b8..85da64f 100644 --- a/kernel-shark/src/KsTraceViewer.cpp +++ b/kernel-shark/src/KsTraceViewer.cpp @@ -61,7 +61,8 @@ KsTraceViewer::KsTraceViewer(QWidget *parent) _graphFollowsCheckBox(this), _graphFollows(true), _mState(nullptr), - _data(nullptr) + _data(nullptr), + _em(this) { this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); @@ -493,15 +494,21 @@ void KsTraceViewer::markSwitch() QModelIndex index = _proxyModel.mapFromSource(_model.index(row, 0)); - /* - * The row of the active marker will be colored according to - * the assigned property of the current state of the Dual - * marker. Auto-scrolling is temporarily disabled because we - * do not want to scroll to the position of the marker yet. - */ - _view.setAutoScroll(false); - _view.selectRow(index.row()); - _view.setAutoScroll(true); + if (index.isValid()) { + /* + * The row of the active marker will be colored according to + * the assigned property of the current state of the Dual + * marker. Auto-scrolling is temporarily disabled because we + * do not want to scroll to the position of the marker yet. + */ + _view.setAutoScroll(false); + _view.selectRow(index.row()); + _view.setAutoScroll(true); + } else { + _view.clearSelection(); + QString err("The marker's entry is filtered out."); + _em.showMessage(err); + } } else { _view.clearSelection(); } diff --git a/kernel-shark/src/KsTraceViewer.hpp b/kernel-shark/src/KsTraceViewer.hpp index cf529ba..15eee50 100644 --- a/kernel-shark/src/KsTraceViewer.hpp +++ b/kernel-shark/src/KsTraceViewer.hpp @@ -119,6 +119,8 @@ private: KsDataStore *_data; + QErrorMessage _em; + enum Condition { Containes = 0,