diff mbox series

libtraceevent: Have sizeof() parsing handle u8/s8 through u64/s64

Message ID 20241011154801.6e237662@gandalf.local.home (mailing list archive)
State Accepted
Commit f2224d5b26a1fafd033506052c1f368e59563e85
Headers show
Series libtraceevent: Have sizeof() parsing handle u8/s8 through u64/s64 | expand

Commit Message

Steven Rostedt Oct. 11, 2024, 7:48 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The sizeof() may be used for common types like:

 __u8, __s8, u8, s8,
 __u16, __s16, u16, s16,
 __u32, __s32, u32, s32,
 __u64, __s64, u64, s64

Handle them.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/event-parse.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Sean Anderson Oct. 17, 2024, 3:27 p.m. UTC | #1
On 10/11/24 15:48, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> The sizeof() may be used for common types like:
> 
>  __u8, __s8, u8, s8,
>  __u16, __s16, u16, s16,
>  __u32, __s32, u32, s32,
>  __u64, __s64, u64, s64
> 
> Handle them.
> 
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  src/event-parse.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/event-parse.c b/src/event-parse.c
> index ddeb3b9909c0..73563c8e9dea 100644
> --- a/src/event-parse.c
> +++ b/src/event-parse.c
> @@ -3571,6 +3571,23 @@ process_sizeof(struct tep_event *event, struct tep_print_arg *arg, char **tok)
>  			/* The token is the next token */
>  			token_has_paren = true;
>  		}
> +
> +	} else if (strcmp(token, "__u64") == 0 || strcmp(token, "u64") == 0 ||
> +		   strcmp(token, "__s64") == 0 || strcmp(token, "s64") == 0) {
> +		arg->atom.atom = strdup("8");
> +
> +	} else if (strcmp(token, "__u32") == 0 || strcmp(token, "u32") == 0 ||
> +		   strcmp(token, "__s32") == 0 || strcmp(token, "s32") == 0) {
> +		arg->atom.atom = strdup("4");
> +
> +	} else if (strcmp(token, "__u16") == 0 || strcmp(token, "u16") == 0 ||
> +		   strcmp(token, "__s16") == 0 || strcmp(token, "s16") == 0) {
> +		arg->atom.atom = strdup("2");
> +
> +	} else if (strcmp(token, "__u8") == 0 || strcmp(token, "u8") == 0 ||
> +		   strcmp(token, "__8") == 0 || strcmp(token, "s8") == 0) {
> +		arg->atom.atom = strdup("1");
> +
>  	} else if (strcmp(token, "REC") == 0) {
>  
>  		free_token(token);

Reviewed-by: Sean Anderson <sean.anderson@linux.dev>
Tested-by: Sean Anderson <sean.anderson@linux.dev>
diff mbox series

Patch

diff --git a/src/event-parse.c b/src/event-parse.c
index ddeb3b9909c0..73563c8e9dea 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -3571,6 +3571,23 @@  process_sizeof(struct tep_event *event, struct tep_print_arg *arg, char **tok)
 			/* The token is the next token */
 			token_has_paren = true;
 		}
+
+	} else if (strcmp(token, "__u64") == 0 || strcmp(token, "u64") == 0 ||
+		   strcmp(token, "__s64") == 0 || strcmp(token, "s64") == 0) {
+		arg->atom.atom = strdup("8");
+
+	} else if (strcmp(token, "__u32") == 0 || strcmp(token, "u32") == 0 ||
+		   strcmp(token, "__s32") == 0 || strcmp(token, "s32") == 0) {
+		arg->atom.atom = strdup("4");
+
+	} else if (strcmp(token, "__u16") == 0 || strcmp(token, "u16") == 0 ||
+		   strcmp(token, "__s16") == 0 || strcmp(token, "s16") == 0) {
+		arg->atom.atom = strdup("2");
+
+	} else if (strcmp(token, "__u8") == 0 || strcmp(token, "u8") == 0 ||
+		   strcmp(token, "__8") == 0 || strcmp(token, "s8") == 0) {
+		arg->atom.atom = strdup("1");
+
 	} else if (strcmp(token, "REC") == 0) {
 
 		free_token(token);