Skip to contentSkip to conversation

perf trace: Add a strtoul() method to 'struct syscall_arg_fmt'

tip: perf/core tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Oct 15, 2019 1 message not in the archive perf events

lore
Share & tools
lore

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw
In reply to a message not in the archive

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     3f41b77843b338e836f52cc2d486be689d6cb9c1
Gitweb:        https://git.kernel.org/tip/3f41b77843b338e836f52cc2d486be689d6cb9c1
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Wed, 09 Oct 2019 16:06:43 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Wed, 09 Oct 2019 16:06:43 -03:00

perf trace: Add a strtoul() method to 'struct syscall_arg_fmt'

This will go from a string to a number, so that filter expressions can be constructed with strings and then, before applying the tracepoint filters (or eBPF, in the future) we can map those strings to numbers.

The first one will be for 'msr' tracepoint arguments, but real quickly we will be able to reuse all strarrays for that.

---
 tools/perf/builtin-trace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +7 -1
index 2c19680..faa5bf4 100644
@@ -86,8 +86,12 @@
 # define F_LINUX_SPECIFIC_BASE	1024
 #endif
 
+/*
+ * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100
+ */
 struct syscall_arg_fmt {
 	size_t	   (*scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
+	bool	   (*strtoul)(char *bf, size_t size, struct syscall_arg *arg, u64 *val);
 	unsigned long (*mask_val)(struct syscall_arg *arg, unsigned long val);
 	void	   *parm;
 	const char *name;
@@ -1543,8 +1547,10 @@ syscall_arg_fmt__init_array(struct syscall_arg_fmt *arg, struct tep_format_field
                } else {
 			struct syscall_arg_fmt *fmt = syscall_arg_fmt__find_by_name(field->name);
 
-			if (fmt)
+			if (fmt) {
 				arg->scnprintf = fmt->scnprintf;
+				arg->strtoul   = fmt->strtoul;
+			}
 		}
 	}