diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-08-07 09:20:43 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-10 15:32:59 -0400 |
commit | 2bcd355b71dafa5793a680c5db043abe9f708418 (patch) | |
tree | 7611a9e7ccdc79f39cc355f54c8a7064bfa96d45 | |
parent | 239cc47819ec5e1acde42d416755c332ed5cf2c8 (diff) |
perf tools: Add interface to arch registers sets
Adding header files to access unified API for arch registers.
util/perf_regs.h - global perf_reg declarations
arch/x86/include/perf_regs.h - x86 arch specific
Adding perf_reg_name function to obtain register name based on the reg
ID value, and PERF_REGS_MASK macro with mask definition of all current
arch registers (will be used in unwind patches).
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: "Frank Ch. Eigler" <fche@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Benjamin Redelings <benjamin.redelings@nescent.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
Link: http://lkml.kernel.org/r/1344345647-11536-9-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/Makefile | 13 | ||||
-rw-r--r-- | tools/perf/arch/x86/include/perf_regs.h | 80 | ||||
-rw-r--r-- | tools/perf/util/perf_regs.h | 14 |
3 files changed, 106 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index de6aa8c706cf..27ae84bb5e4c 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -55,13 +55,15 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ | |||
55 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ | 55 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ |
56 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ | 56 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ |
57 | -e s/sh[234].*/sh/ ) | 57 | -e s/sh[234].*/sh/ ) |
58 | NO_PERF_REGS := 1 | ||
58 | 59 | ||
59 | CC = $(CROSS_COMPILE)gcc | 60 | CC = $(CROSS_COMPILE)gcc |
60 | AR = $(CROSS_COMPILE)ar | 61 | AR = $(CROSS_COMPILE)ar |
61 | 62 | ||
62 | # Additional ARCH settings for x86 | 63 | # Additional ARCH settings for x86 |
63 | ifeq ($(ARCH),i386) | 64 | ifeq ($(ARCH),i386) |
64 | ARCH := x86 | 65 | ARCH := x86 |
66 | NO_PERF_REGS := 0 | ||
65 | endif | 67 | endif |
66 | ifeq ($(ARCH),x86_64) | 68 | ifeq ($(ARCH),x86_64) |
67 | ARCH := x86 | 69 | ARCH := x86 |
@@ -74,6 +76,7 @@ ifeq ($(ARCH),x86_64) | |||
74 | ARCH_CFLAGS := -DARCH_X86_64 | 76 | ARCH_CFLAGS := -DARCH_X86_64 |
75 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S | 77 | ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S |
76 | endif | 78 | endif |
79 | NO_PERF_REGS := 0 | ||
77 | endif | 80 | endif |
78 | 81 | ||
79 | # Treat warnings as errors unless directed not to | 82 | # Treat warnings as errors unless directed not to |
@@ -326,6 +329,7 @@ LIB_H += $(TRACE_EVENT_DIR)event-parse.h | |||
326 | LIB_H += util/target.h | 329 | LIB_H += util/target.h |
327 | LIB_H += util/rblist.h | 330 | LIB_H += util/rblist.h |
328 | LIB_H += util/intlist.h | 331 | LIB_H += util/intlist.h |
332 | LIB_H += util/perf_regs.h | ||
329 | 333 | ||
330 | LIB_OBJS += $(OUTPUT)util/abspath.o | 334 | LIB_OBJS += $(OUTPUT)util/abspath.o |
331 | LIB_OBJS += $(OUTPUT)util/alias.o | 335 | LIB_OBJS += $(OUTPUT)util/alias.o |
@@ -704,6 +708,13 @@ else | |||
704 | endif | 708 | endif |
705 | endif | 709 | endif |
706 | 710 | ||
711 | ifeq ($(NO_PERF_REGS),0) | ||
712 | ifeq ($(ARCH),x86) | ||
713 | LIB_H += arch/x86/include/perf_regs.h | ||
714 | endif | ||
715 | else | ||
716 | BASIC_CFLAGS += -DNO_PERF_REGS | ||
717 | endif | ||
707 | 718 | ||
708 | ifdef NO_STRLCPY | 719 | ifdef NO_STRLCPY |
709 | BASIC_CFLAGS += -DNO_STRLCPY | 720 | BASIC_CFLAGS += -DNO_STRLCPY |
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h new file mode 100644 index 000000000000..46fc9f15c6b3 --- /dev/null +++ b/tools/perf/arch/x86/include/perf_regs.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef ARCH_PERF_REGS_H | ||
2 | #define ARCH_PERF_REGS_H | ||
3 | |||
4 | #include <stdlib.h> | ||
5 | #include "../../util/types.h" | ||
6 | #include "../../../../../arch/x86/include/asm/perf_regs.h" | ||
7 | |||
8 | #ifndef ARCH_X86_64 | ||
9 | #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) | ||
10 | #else | ||
11 | #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ | ||
12 | (1ULL << PERF_REG_X86_ES) | \ | ||
13 | (1ULL << PERF_REG_X86_FS) | \ | ||
14 | (1ULL << PERF_REG_X86_GS)) | ||
15 | #define PERF_REGS_MASK (((1ULL << PERF_REG_X86_64_MAX) - 1) & ~REG_NOSUPPORT) | ||
16 | #endif | ||
17 | #define PERF_REG_IP PERF_REG_X86_IP | ||
18 | #define PERF_REG_SP PERF_REG_X86_SP | ||
19 | |||
20 | static inline const char *perf_reg_name(int id) | ||
21 | { | ||
22 | switch (id) { | ||
23 | case PERF_REG_X86_AX: | ||
24 | return "AX"; | ||
25 | case PERF_REG_X86_BX: | ||
26 | return "BX"; | ||
27 | case PERF_REG_X86_CX: | ||
28 | return "CX"; | ||
29 | case PERF_REG_X86_DX: | ||
30 | return "DX"; | ||
31 | case PERF_REG_X86_SI: | ||
32 | return "SI"; | ||
33 | case PERF_REG_X86_DI: | ||
34 | return "DI"; | ||
35 | case PERF_REG_X86_BP: | ||
36 | return "BP"; | ||
37 | case PERF_REG_X86_SP: | ||
38 | return "SP"; | ||
39 | case PERF_REG_X86_IP: | ||
40 | return "IP"; | ||
41 | case PERF_REG_X86_FLAGS: | ||
42 | return "FLAGS"; | ||
43 | case PERF_REG_X86_CS: | ||
44 | return "CS"; | ||
45 | case PERF_REG_X86_SS: | ||
46 | return "SS"; | ||
47 | case PERF_REG_X86_DS: | ||
48 | return "DS"; | ||
49 | case PERF_REG_X86_ES: | ||
50 | return "ES"; | ||
51 | case PERF_REG_X86_FS: | ||
52 | return "FS"; | ||
53 | case PERF_REG_X86_GS: | ||
54 | return "GS"; | ||
55 | #ifdef ARCH_X86_64 | ||
56 | case PERF_REG_X86_R8: | ||
57 | return "R8"; | ||
58 | case PERF_REG_X86_R9: | ||
59 | return "R9"; | ||
60 | case PERF_REG_X86_R10: | ||
61 | return "R10"; | ||
62 | case PERF_REG_X86_R11: | ||
63 | return "R11"; | ||
64 | case PERF_REG_X86_R12: | ||
65 | return "R12"; | ||
66 | case PERF_REG_X86_R13: | ||
67 | return "R13"; | ||
68 | case PERF_REG_X86_R14: | ||
69 | return "R14"; | ||
70 | case PERF_REG_X86_R15: | ||
71 | return "R15"; | ||
72 | #endif /* ARCH_X86_64 */ | ||
73 | default: | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | return NULL; | ||
78 | } | ||
79 | |||
80 | #endif /* ARCH_PERF_REGS_H */ | ||
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h new file mode 100644 index 000000000000..9bd6c4e069c8 --- /dev/null +++ b/tools/perf/util/perf_regs.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef __PERF_REGS_H | ||
2 | #define __PERF_REGS_H | ||
3 | |||
4 | #ifndef NO_PERF_REGS | ||
5 | #include <perf_regs.h> | ||
6 | #else | ||
7 | #define PERF_REGS_MASK 0 | ||
8 | |||
9 | static inline const char *perf_reg_name(int id __used) | ||
10 | { | ||
11 | return NULL; | ||
12 | } | ||
13 | #endif /* NO_PERF_REGS */ | ||
14 | #endif /* __PERF_REGS_H */ | ||