From patchwork Wed Nov 28 15:16:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10760055 Return-Path: Received: from mail-eopbgr710043.outbound.protection.outlook.com ([40.107.71.43]:7840 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728732AbeK2CST (ORCPT ); Wed, 28 Nov 2018 21:18:19 -0500 From: Yordan Karadzhov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH 08/17] kernel-shark-qt: Add a method for easy retrieve of all Ids of a filter Date: Wed, 28 Nov 2018 15:16:16 +0000 Message-ID: <20181128151530.21965-9-ykaradzhov@vmware.com> References: <20181128151530.21965-1-ykaradzhov@vmware.com> In-Reply-To: <20181128151530.21965-1-ykaradzhov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 1649 This patch adds to KsUtils a method which can be used to retrieve a vector of sorted Id values associated with a given filter. The method will be used by the Quick Context Menu widget. Signed-off-by: Yordan Karadzhov --- kernel-shark-qt/src/KsUtils.cpp | 21 +++++++++++++++++++++ kernel-shark-qt/src/KsUtils.hpp | 2 ++ 2 files changed, 23 insertions(+) diff --git a/kernel-shark-qt/src/KsUtils.cpp b/kernel-shark-qt/src/KsUtils.cpp index 25e7fdb..c0e0f7d 100644 --- a/kernel-shark-qt/src/KsUtils.cpp +++ b/kernel-shark-qt/src/KsUtils.cpp @@ -36,6 +36,27 @@ QVector getPidList() return pids; } +/** @brief Get a sorted vector of Id values of a filter. */ +QVector getFilterIds(tracecmd_filter_id *filter) +{ + kshark_context *kshark_ctx(nullptr); + int *cpuFilter, n; + QVector v; + + if (!kshark_instance(&kshark_ctx)) + return v; + + cpuFilter = tracecmd_filter_ids(filter); + n = filter->count; + for (int i = 0; i < n; ++i) + v.append(cpuFilter[i]); + + qSort(v); + + free(cpuFilter); + return v; +} + /** * Set the bit of the filter mask of the kshark session context responsible * for the visibility of the events in the Table View. diff --git a/kernel-shark-qt/src/KsUtils.hpp b/kernel-shark-qt/src/KsUtils.hpp index b14cd6a..888ed56 100644 --- a/kernel-shark-qt/src/KsUtils.hpp +++ b/kernel-shark-qt/src/KsUtils.hpp @@ -84,6 +84,8 @@ namespace KsUtils { QVector getPidList(); +QVector getFilterIds(tracecmd_filter_id *filter); + /** @brief Geat the list of plugins. */ inline QStringList getPluginList() {return plugins.split(";");}