public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tools: Support bpf prologue for arm64
@ 2015-08-29  3:16 He Kuang
  2015-08-31 20:16 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 5+ messages in thread
From: He Kuang @ 2015-08-29  3:16 UTC (permalink / raw)
  To: wangnan0, a.p.zijlstra, mingo, acme, jolsa; +Cc: linux-kernel

This patch implements arch_get_reg_info() for arm64 to enable
HAVE_BPF_PROLOGUE feature. For arm64, structure pt_regs is not composed
by fields of register names but an array of regs, so here we simply
multiply fixed register size by index number to get the byte offset.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/arch/arm64/Makefile          |  1 +
 tools/perf/arch/arm64/util/dwarf-regs.c | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
index 7fbca17..1256e6e 100644
--- a/tools/perf/arch/arm64/Makefile
+++ b/tools/perf/arch/arm64/Makefile
@@ -1,3 +1,4 @@
 ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 endif
+PERF_HAVE_ARCH_GET_REG_INFO := 1
diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c
index d49efeb..cb2c50a 100644
--- a/tools/perf/arch/arm64/util/dwarf-regs.c
+++ b/tools/perf/arch/arm64/util/dwarf-regs.c
@@ -10,6 +10,10 @@
 
 #include <stddef.h>
 #include <dwarf-regs.h>
+#include <string.h>
+#include <linux/ptrace.h>
+
+#define PT_REG_SIZE (sizeof(((struct user_pt_regs *)0)->regs[0]))
 
 struct pt_regs_dwarfnum {
 	const char *name;
@@ -78,3 +82,25 @@ const char *get_arch_regstr(unsigned int n)
 			return roff->name;
 	return NULL;
 }
+
+#ifdef HAVE_BPF_PROLOGUE
+int arch_get_reg_info(const char *name, int *offset)
+{
+	const struct pt_regs_dwarfnum *roff;
+
+	if (!name || !offset)
+		return -1;
+
+	for (roff = regdwarfnum_table; roff->name != NULL; roff++) {
+		if (!strcmp(roff->name, name)) {
+			if (roff->dwarfnum < 0)
+				return -1;
+
+			*offset = roff->dwarfnum * PT_REG_SIZE;
+			return 0;
+		}
+	}
+
+	return -1;
+}
+#endif
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-02 10:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-29  3:16 [PATCH] perf tools: Support bpf prologue for arm64 He Kuang
2015-08-31 20:16 ` Arnaldo Carvalho de Melo
2015-09-01  2:04   ` He Kuang
2015-09-02 10:34   ` Will Deacon
2015-09-02 10:50     ` Wangnan (F)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox