diff mbox series

[4/4] libtracefs: Have synthetic events use types pid_t, gfp_t and bool

Message ID 20220131163642.2754485-5-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 9c16318b52e54aa38843d7b1b280e63022a18ba5
Headers show
Series libtracefs: synthetic event fixes | expand

Commit Message

Steven Rostedt Jan. 31, 2022, 4:36 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The synthetic events understand pid_t, gfp_t and bool, and it is better to
use them, as some kernels have bugs where a field with one of the above
types may not match the raw format they are.

That is, pid_t may not match s32, even though they are the same type!

Fixes: 7c9000c7495b9 ("libtracefs: Create a way to create a synthetic event")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-hist.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index ec63b88a0bca..e7dd279ae3f9 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -841,6 +841,15 @@  static char *add_synth_field(const struct tep_format_field *field,
 		return append_string(str, NULL, "];");
 	}
 
+	/* Synthetic events understand pid_t, gfp_t and bool */
+	if (strcmp(field->type, "pid_t") == 0 ||
+	    strcmp(field->type, "gfp_t") == 0 ||
+	    strcmp(field->type, "bool") == 0) {
+		str = strdup(field->type);
+		str = append_string(str, " ", name);
+		return append_string(str, NULL, ";");
+	}
+
 	sign = field->flags & TEP_FIELD_IS_SIGNED;
 
 	switch (field->size) {