Skip to content

Commit

Permalink
perf tools arm64: Add support for generating bpf prologue
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Will Deacon <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Bintian Wang <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
He Kuang authored and acmel committed Feb 8, 2017
1 parent e06094a commit 3bb53c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/perf/arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
endif
PERF_HAVE_JITDUMP := 1
PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
15 changes: 14 additions & 1 deletion tools/perf/arch/arm64/util/dwarf-regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@

#include <stddef.h>
#include <dwarf-regs.h>
#include <linux/ptrace.h> /* for struct user_pt_regs */
#include "util.h"

struct pt_regs_dwarfnum {
const char *name;
unsigned int dwarfnum;
};

#define STR(s) #s
#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
#define GPR_DWARFNUM_NAME(num) \
{.name = STR(%x##num), .dwarfnum = num}
#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
#define DWARFNUM2OFFSET(index) \
(index * sizeof((struct user_pt_regs *)0)->regs[0])

/*
* Reference:
Expand Down Expand Up @@ -78,3 +81,13 @@ const char *get_arch_regstr(unsigned int n)
return roff->name;
return NULL;
}

int regs_query_register_offset(const char *name)
{
const struct pt_regs_dwarfnum *roff;

for (roff = regdwarfnum_table; roff->name != NULL; roff++)
if (!strcmp(roff->name, name))
return DWARFNUM2OFFSET(roff->dwarfnum);
return -EINVAL;
}

0 comments on commit 3bb53c9

Please sign in to comment.