aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2015-08-31 12:41:11 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-31 16:56:37 -0400
commitc5e991ee9dff0f8136168ed2d0d1a8cc3620dac4 (patch)
tree2b9c3ae2a63f6b8d38d21aa6eb9ffa517e58f1a6
parentfc36f9485aee3a62b22be1f561543a31bce6d48e (diff)
perf/x86: Add list of register names
This patch adds a way to locate a register identifier (PERF_X86_REG_*) based on its name, e.g., AX. This will be used by a subsequent patch to improved flexibility of perf record. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1441039273-16260-3-git-send-email-eranian@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/arch/x86/util/Build1
-rw-r--r--tools/perf/arch/x86/util/perf_regs.c30
-rw-r--r--tools/perf/util/perf_regs.h7
3 files changed, 38 insertions, 0 deletions
diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build
index 2c55e1b336c5..ff63649fa9ac 100644
--- a/tools/perf/arch/x86/util/Build
+++ b/tools/perf/arch/x86/util/Build
@@ -2,6 +2,7 @@ libperf-y += header.o
2libperf-y += tsc.o 2libperf-y += tsc.o
3libperf-y += pmu.o 3libperf-y += pmu.o
4libperf-y += kvm-stat.o 4libperf-y += kvm-stat.o
5libperf-y += perf_regs.o
5 6
6libperf-$(CONFIG_DWARF) += dwarf-regs.o 7libperf-$(CONFIG_DWARF) += dwarf-regs.o
7 8
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
new file mode 100644
index 000000000000..087c84ef5234
--- /dev/null
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -0,0 +1,30 @@
1#include "../../perf.h"
2#include "../../util/perf_regs.h"
3
4#define REG(n, b) { .name = #n, .mask = 1ULL << (b) }
5#define REG_END { .name = NULL }
6const struct sample_reg sample_reg_masks[] = {
7 REG(AX, PERF_REG_X86_AX),
8 REG(BX, PERF_REG_X86_BX),
9 REG(CX, PERF_REG_X86_CX),
10 REG(DX, PERF_REG_X86_DX),
11 REG(SI, PERF_REG_X86_SI),
12 REG(DI, PERF_REG_X86_DI),
13 REG(BP, PERF_REG_X86_BP),
14 REG(SP, PERF_REG_X86_SP),
15 REG(IP, PERF_REG_X86_IP),
16 REG(FLAGS, PERF_REG_X86_FLAGS),
17 REG(CS, PERF_REG_X86_CS),
18 REG(SS, PERF_REG_X86_SS),
19#ifdef HAVE_ARCH_X86_64_SUPPORT
20 REG(R8, PERF_REG_X86_R8),
21 REG(R9, PERF_REG_X86_R9),
22 REG(R10, PERF_REG_X86_R10),
23 REG(R11, PERF_REG_X86_R11),
24 REG(R12, PERF_REG_X86_R12),
25 REG(R13, PERF_REG_X86_R13),
26 REG(R14, PERF_REG_X86_R14),
27 REG(R15, PERF_REG_X86_R15),
28#endif
29 REG_END
30};
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index 980dbf76bc98..92c1fff2153e 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -5,6 +5,13 @@
5 5
6struct regs_dump; 6struct regs_dump;
7 7
8struct sample_reg {
9 const char *name;
10 uint64_t mask;
11};
12
13extern const struct sample_reg sample_reg_masks[];
14
8#ifdef HAVE_PERF_REGS_SUPPORT 15#ifdef HAVE_PERF_REGS_SUPPORT
9#include <perf_regs.h> 16#include <perf_regs.h>
10 17