diff mbox series

[v3,3/5] trace-cmd: Add new libtraceevent flag to suppress parsing warnings

Message ID 20200226163159.20232-4-tz.stoyanov@gmail.com (mailing list archive)
State New
Headers show
Series trace-cmd: SQL-like syntax for ftrace histograms configuration | expand

Commit Message

Tzvetomir Stoyanov (VMware) Feb. 26, 2020, 4:31 p.m. UTC
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 mbox series

Patch

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;