From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 1/5] kernel-shark: Add method for checking if a given ID filter is set
Date: Thu, 19 Mar 2020 16:10:27 +0200 [thread overview]
Message-ID: <20200319141031.3774-2-y.karadz@gmail.com> (raw)
In-Reply-To: <20200319141031.3774-1-y.karadz@gmail.com>
The method is already defined and used as a static function in
libkshark.c and libkshark-configio.c (basically having two identical
copies). Now we are making this method part of the API. We will later
use this method in the GUI (following patch).
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
kernel-shark/src/libkshark-configio.c | 17 ++++++-----------
kernel-shark/src/libkshark.c | 21 ++++++++++++++-------
kernel-shark/src/libkshark.h | 2 ++
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/kernel-shark/src/libkshark-configio.c b/kernel-shark/src/libkshark-configio.c
index 5d7323f..f01a39b 100644
--- a/kernel-shark/src/libkshark-configio.c
+++ b/kernel-shark/src/libkshark-configio.c
@@ -1306,11 +1306,6 @@ bool kshark_import_user_mask(struct kshark_context *kshark_ctx,
}
}
-static bool filter_is_set(struct tracecmd_filter_id *filter)
-{
- return filter && filter->count;
-}
-
/**
* @brief Record the current configuration of "show task" and "hide task"
* filters into a Json document.
@@ -1335,13 +1330,13 @@ bool kshark_export_all_event_filters(struct kshark_context *kshark_ctx,
return false;
/* Save a filter only if it contains Id values. */
- if (filter_is_set(kshark_ctx->show_event_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->show_event_filter))
ret &= kshark_export_event_filter(kshark_ctx->pevent,
kshark_ctx->show_event_filter,
KS_SHOW_EVENT_FILTER_NAME,
*conf);
- if (filter_is_set(kshark_ctx->hide_event_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->hide_event_filter))
ret &= kshark_export_event_filter(kshark_ctx->pevent,
kshark_ctx->hide_event_filter,
KS_HIDE_EVENT_FILTER_NAME,
@@ -1374,12 +1369,12 @@ bool kshark_export_all_task_filters(struct kshark_context *kshark_ctx,
return false;
/* Save a filter only if it contains Id values. */
- if (filter_is_set(kshark_ctx->show_task_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->show_task_filter))
ret &= kshark_export_filter_array(kshark_ctx->show_task_filter,
KS_SHOW_TASK_FILTER_NAME,
*conf);
- if (filter_is_set(kshark_ctx->hide_task_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->hide_task_filter))
ret &= kshark_export_filter_array(kshark_ctx->hide_task_filter,
KS_HIDE_TASK_FILTER_NAME,
*conf);
@@ -1412,12 +1407,12 @@ bool kshark_export_all_cpu_filters(struct kshark_context *kshark_ctx,
return false;
/* Save a filter only if it contains Id values. */
- if (filter_is_set(kshark_ctx->show_task_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->show_task_filter))
ret &= kshark_export_filter_array(kshark_ctx->show_cpu_filter,
KS_SHOW_CPU_FILTER_NAME,
*conf);
- if (filter_is_set(kshark_ctx->hide_task_filter))
+ if (kshark_this_filter_is_set(kshark_ctx->hide_task_filter))
ret &= kshark_export_filter_array(kshark_ctx->hide_cpu_filter,
KS_HIDE_CPU_FILTER_NAME,
*conf);
diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index a361578..0905359 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -445,7 +445,14 @@ void kshark_filter_clear(struct kshark_context *kshark_ctx, int filter_id)
tracecmd_filter_id_clear(filter);
}
-static bool filter_is_set(struct tracecmd_filter_id *filter)
+/**
+ * @brief Check if a given Id filter is set.
+ *
+ * @param filter: Input location for the Id filster.
+ *
+ * @returns True if the Id filter is set, otherwise False.
+ */
+bool kshark_this_filter_is_set(struct tracecmd_filter_id *filter)
{
return filter && filter->count;
}
@@ -459,12 +466,12 @@ static bool filter_is_set(struct tracecmd_filter_id *filter)
*/
bool kshark_filter_is_set(struct kshark_context *kshark_ctx)
{
- return filter_is_set(kshark_ctx->show_task_filter) ||
- filter_is_set(kshark_ctx->hide_task_filter) ||
- filter_is_set(kshark_ctx->show_cpu_filter) ||
- filter_is_set(kshark_ctx->hide_cpu_filter) ||
- filter_is_set(kshark_ctx->show_event_filter) ||
- filter_is_set(kshark_ctx->hide_event_filter);
+ return kshark_this_filter_is_set(kshark_ctx->show_task_filter) ||
+- kshark_this_filter_is_set(kshark_ctx->hide_task_filter) ||
+- kshark_this_filter_is_set(kshark_ctx->show_cpu_filter) ||
+- kshark_this_filter_is_set(kshark_ctx->hide_cpu_filter) ||
+- kshark_this_filter_is_set(kshark_ctx->show_event_filter) ||
+- kshark_this_filter_is_set(kshark_ctx->hide_event_filter);
}
static inline void unset_event_filter_flag(struct kshark_context *kshark_ctx,
diff --git a/kernel-shark/src/libkshark.h b/kernel-shark/src/libkshark.h
index e795ed4..0d6c50d 100644
--- a/kernel-shark/src/libkshark.h
+++ b/kernel-shark/src/libkshark.h
@@ -261,6 +261,8 @@ void kshark_filter_add_id(struct kshark_context *kshark_ctx,
void kshark_filter_clear(struct kshark_context *kshark_ctx, int filter_id);
+bool kshark_this_filter_is_set(struct tracecmd_filter_id *filter);
+
bool kshark_filter_is_set(struct kshark_context *kshark_ctx);
void kshark_filter_entries(struct kshark_context *kshark_ctx,
--
2.20.1
next prev parent reply other threads:[~2020-03-19 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 14:10 [PATCH 0/5] kernel-shark: Optimize the logic of the filtering menus Yordan Karadzhov (VMware)
2020-03-19 14:10 ` Yordan Karadzhov (VMware) [this message]
2020-03-19 14:10 ` [PATCH 2/5] kernel-shark: Fix bug in bool kshark_export_all_cpu_filters() Yordan Karadzhov (VMware)
2020-03-19 14:10 ` [PATCH 3/5] kernel-shark: Add two helper methods to KsUtils Yordan Karadzhov (VMware)
2020-03-19 14:10 ` [PATCH 4/5] kernel-shark: Remove unused methods from KsMainWindow class Yordan Karadzhov (VMware)
2020-03-19 14:10 ` [PATCH 5/5] kernel-shark: Optimize the logic of the filtering menus Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200319141031.3774-2-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).