diff options
author | He Kuang <hekuang@huawei.com> | 2017-02-07 02:34:11 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-02-08 06:55:01 -0500 |
commit | 3bb53c9f124bd9297f18d58a395cff59dfaf8541 (patch) | |
tree | 3390651ac0724f1035cfe9b2fed8408fc7dd122b | |
parent | e06094ab6755efbba4944803ee08e67fc8c0ae6c (diff) |
perf tools arm64: Add support for generating bpf prologue
Since HAVE_KPROBES can be enabled in arm64, this patch introduces
regs_query_register_offset() to convert register name to offset for
arm64, so the BPF prologue feature is ready to use.
Signed-off-by: He Kuang <hekuang@huawei.com>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Bintian Wang <bintian.wang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20170207073412.26983-1-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/arch/arm64/Makefile | 1 | ||||
-rw-r--r-- | tools/perf/arch/arm64/util/dwarf-regs.c | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile index 18b13518d8d8..eebe1ec9d2ee 100644 --- a/tools/perf/arch/arm64/Makefile +++ b/tools/perf/arch/arm64/Makefile | |||
@@ -2,3 +2,4 @@ ifndef NO_DWARF | |||
2 | PERF_HAVE_DWARF_REGS := 1 | 2 | PERF_HAVE_DWARF_REGS := 1 |
3 | endif | 3 | endif |
4 | PERF_HAVE_JITDUMP := 1 | 4 | PERF_HAVE_JITDUMP := 1 |
5 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 | ||
diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index d49efeb8172e..068b6189157b 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c | |||
@@ -10,17 +10,20 @@ | |||
10 | 10 | ||
11 | #include <stddef.h> | 11 | #include <stddef.h> |
12 | #include <dwarf-regs.h> | 12 | #include <dwarf-regs.h> |
13 | #include <linux/ptrace.h> /* for struct user_pt_regs */ | ||
14 | #include "util.h" | ||
13 | 15 | ||
14 | struct pt_regs_dwarfnum { | 16 | struct pt_regs_dwarfnum { |
15 | const char *name; | 17 | const char *name; |
16 | unsigned int dwarfnum; | 18 | unsigned int dwarfnum; |
17 | }; | 19 | }; |
18 | 20 | ||
19 | #define STR(s) #s | ||
20 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} | 21 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} |
21 | #define GPR_DWARFNUM_NAME(num) \ | 22 | #define GPR_DWARFNUM_NAME(num) \ |
22 | {.name = STR(%x##num), .dwarfnum = num} | 23 | {.name = STR(%x##num), .dwarfnum = num} |
23 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} | 24 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} |
25 | #define DWARFNUM2OFFSET(index) \ | ||
26 | (index * sizeof((struct user_pt_regs *)0)->regs[0]) | ||
24 | 27 | ||
25 | /* | 28 | /* |
26 | * Reference: | 29 | * Reference: |
@@ -78,3 +81,13 @@ const char *get_arch_regstr(unsigned int n) | |||
78 | return roff->name; | 81 | return roff->name; |
79 | return NULL; | 82 | return NULL; |
80 | } | 83 | } |
84 | |||
85 | int regs_query_register_offset(const char *name) | ||
86 | { | ||
87 | const struct pt_regs_dwarfnum *roff; | ||
88 | |||
89 | for (roff = regdwarfnum_table; roff->name != NULL; roff++) | ||
90 | if (!strcmp(roff->name, name)) | ||
91 | return DWARFNUM2OFFSET(roff->dwarfnum); | ||
92 | return -EINVAL; | ||
93 | } | ||