linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v3 3/5] trace-cmd: Add new libtraceevent flag to suppress parsing warnings
Date: Wed, 26 Feb 2020 18:31:57 +0200	[thread overview]
Message-ID: <20200226163159.20232-4-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20200226163159.20232-1-tz.stoyanov@gmail.com>

When the event's format strings are parsed by tep_parse_format()
API and there is a parsing error, a warning is printed. There are
use cases when these errors are not important and should be suppressed.
A new flag is added to
 enum tep_flag {
   ...
   TEP_NO_PARSING_WARNINGS
   ...
 }
for such use cases. It can be set / cleared / checked using
the existing libtraceevent APIs:
 void tep_set_flag(struct tep_handle *tep, int flag);
 void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag);
 bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag);

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 include/traceevent/event-parse.h | 2 ++
 lib/traceevent/event-parse.c     | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index 52bafa54..49e3d287 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -321,6 +321,8 @@ enum tep_flag {
 	TEP_NSEC_OUTPUT		= 1,	/* output in NSECS */
 	TEP_DISABLE_SYS_PLUGINS	= 1 << 1,
 	TEP_DISABLE_PLUGINS	= 1 << 2,
+	TEP_NO_PARSING_WARNINGS	= 1 << 3, /* Disable warnings while parsing
+					     event's format strings */
 };
 
 #define TEP_ERRORS 							      \
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index 064c100d..61cd7ea1 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -6222,6 +6222,7 @@ enum tep_errno __tep_parse_format(struct tep_event **eventp,
 				  struct tep_handle *tep, const char *buf,
 				  unsigned long size, const char *sys)
 {
+	int show_warning_state = show_warning;
 	struct tep_event *event;
 	int ret;
 
@@ -6274,11 +6275,12 @@ enum tep_errno __tep_parse_format(struct tep_event **eventp,
 	 * If the event has an override, don't print warnings if the event
 	 * print format fails to parse.
 	 */
-	if (tep && find_event_handle(tep, event))
+	if (tep && (tep_test_flag(tep, TEP_NO_PARSING_WARNINGS) ||
+		    find_event_handle(tep, event)))
 		show_warning = 0;
 
 	ret = event_read_print(event);
-	show_warning = 1;
+	show_warning = show_warning_state;
 
 	if (ret < 0) {
 		ret = TEP_ERRNO__READ_PRINT_FAILED;
-- 
2.24.1


  parent reply	other threads:[~2020-02-26 16:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 16:31 [PATCH v3 0/5] trace-cmd: SQL-like syntax for ftrace histograms configuration Tzvetomir Stoyanov (VMware)
2020-02-26 16:31 ` [PATCH v3 1/5] trace-cmd: Add new libtracefs API tracefs_instance_file_append() Tzvetomir Stoyanov (VMware)
2020-02-26 16:31 ` [PATCH v3 2/5] trace-cmd: Unit test for tracefs_instance_file_append() API Tzvetomir Stoyanov (VMware)
2020-02-26 16:31 ` Tzvetomir Stoyanov (VMware) [this message]
2020-02-26 16:31 ` [PATCH v3 4/5] trace-cmd: Suppress parsing warnings in tracefs_local_events() API Tzvetomir Stoyanov (VMware)
2020-02-26 16:31 ` [PATCH v3 5/5] trace-cmd: Add "--sql" option to trace-cmd start and record sub commands Tzvetomir Stoyanov (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=20200226163159.20232-4-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@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).