diff mbox series

[08/17] kernel-shark-qt: Add a method for easy retrieve of all Ids of a filter

Message ID 20181128151530.21965-9-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit 9e752649d42a9ff70f7f515d3b8df1ac297a3535
Headers show
Series More modifications and bug fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Nov. 28, 2018, 3:16 p.m. UTC
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 <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsUtils.cpp | 21 +++++++++++++++++++++
 kernel-shark-qt/src/KsUtils.hpp |  2 ++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

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<int> getPidList()
 	return pids;
 }
 
+/** @brief Get a sorted vector of Id values of a filter. */
+QVector<int> getFilterIds(tracecmd_filter_id *filter)
+{
+	kshark_context *kshark_ctx(nullptr);
+	int *cpuFilter, n;
+	QVector<int> 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<int> getPidList();
 
+QVector<int> getFilterIds(tracecmd_filter_id *filter);
+
 /** @brief Geat the list of plugins. */
 inline QStringList getPluginList() {return plugins.split(";");}