diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-10-09 16:11:36 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-10-09 16:11:36 -0300 |
commit | d0a3a1041005d9273d18669819e2a6dfed922a4d (patch) | |
tree | f13ce797e722d6d113f85c1bfe53aa7e309f936b /tools/perf/trace | |
parent | 3f41b77843b338e836f52cc2d486be689d6cb9c1 (diff) | |
download | linux-d0a3a1041005d9273d18669819e2a6dfed922a4d.tar.gz linux-d0a3a1041005d9273d18669819e2a6dfed922a4d.tar.bz2 linux-d0a3a1041005d9273d18669819e2a6dfed922a4d.zip |
perf trace: Introduce a strtoul() method for 'struct strarrays'
And also for 'struct strarray', since its needed to implement
strarrays__strtoul(). This just traverses the entries and when finding a
match, returns (offset + index), i.e. the value associated with the
searched string.
E.g. "EFER" (MSR_EFER) returns:
# grep -w EFER -B2 /tmp/build/perf/trace/beauty/generated/x86_arch_MSRs_array.c
#define x86_64_specific_MSRs_offset 0xc0000080
static const char *x86_64_specific_MSRs[] = {
[0xc0000080 - x86_64_specific_MSRs_offset] = "EFER",
#
0xc0000080
This will be auto-attached to 'struct syscall_arg_fmt' entries
associated with strarrays as soon as we add a ->strarray and ->strarrays
to 'struct syscall_arg_fmt'.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-r2hpaahf8lishyb1owko9vs1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/trace')
-rw-r--r-- | tools/perf/trace/beauty/beauty.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index aa3fac8bd1be..919ac4548bd8 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -5,6 +5,7 @@ #include <linux/kernel.h> #include <linux/types.h> #include <sys/types.h> +#include <stdbool.h> struct strarray { u64 offset; @@ -29,6 +30,8 @@ struct strarray { size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, bool show_prefix, int val); size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, bool show_prefix, unsigned long flags); +bool strarray__strtoul(struct strarray *sa, char *bf, size_t size, u64 *ret); + struct trace; struct thread; @@ -51,6 +54,8 @@ struct strarrays { size_t strarrays__scnprintf(struct strarrays *sas, char *bf, size_t size, const char *intfmt, bool show_prefix, int val); +bool strarrays__strtoul(struct strarrays *sas, char *bf, size_t size, u64 *ret); + size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); extern struct strarray strarray__socket_families; |