linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	Gabriel Krisman Bertazi <krisman@suse.de>
Subject: [PATCH trace-cmd v2 1/3] trace-cmd report: Ensure filter is applied to single input file
Date: Thu, 30 Mar 2023 15:52:09 -0300	[thread overview]
Message-ID: <20230330185211.5604-2-krisman@suse.de> (raw)
In-Reply-To: <20230330185211.5604-1-krisman@suse.de>

Since 955d05fc7aee ("trace-cmd report: Make filter arguments match their
files"), the -F filtering is silently ignored when a trace file is
provided with -i and the filter comes after -i .  The reason is that the
filter is now associated with input_files and not saved to the global
list only in this case, but process_filters still only checks the global
list when handles->input_file is not set.

Avoid this by checking last_input_file first, which always contains a
pointer to the correct filter in this case.

This was only lightly tested, using a single trace file.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217038
Fixes: 955d05fc7aee ("trace-cmd report: Make filter arguments match their files")
Signed-off-by: Gabriel krisman Bertazi <krisman@suse.de>

---
Since v1:
  - use rev. xmas tree for variable declaration (steve)
---
 tracecmd/trace-read.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 52ba818..6a872d7 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -564,14 +564,15 @@ static void make_pid_filter(struct tracecmd_input *handle,
 
 static void process_filters(struct handle_list *handles)
 {
+	struct input_files *input_file = handles->input_file ?: last_input_file;
 	struct tracecmd_filter *trace_filter;
 	struct filter_str *filter;
 	int filters = 0;
 
-	make_pid_filter(handles->handle, handles->input_file);
+	make_pid_filter(handles->handle, input_file);
 
-	if (handles->input_file)
-		filter = handles->input_file->filter_str;
+	if (input_file)
+		filter = input_file->filter_str;
 	else
 		filter = filter_strings;
 
-- 
2.40.0


  reply	other threads:[~2023-03-30 18:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 18:52 [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-03-30 18:52 ` Gabriel Krisman Bertazi [this message]
2023-03-30 18:52 ` [PATCH trace-cmd v2 2/3] trace-cmd-report: Support global filters Gabriel Krisman Bertazi
2023-03-30 18:52 ` [PATCH trace-cmd v2 3/3] documentation: trace-cmd-report: Document filter scope Gabriel Krisman Bertazi
2023-05-06 22:35 ` [PATCH trace-cmd v2 0/3] trace-cmd filtering Gabriel Krisman Bertazi
2023-05-07  1:51   ` Steven Rostedt
2023-05-30  8:20 ` Steven Rostedt

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=20230330185211.5604-2-krisman@suse.de \
    --to=krisman@suse.de \
    --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).