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,