diff options
author | Ian Munsie <imunsie@au.ibm.com> | 2010-04-20 02:58:32 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2010-04-21 23:48:31 -0400 |
commit | cd932c593995abee1d1a8a0bfe608f7d103d87ad (patch) | |
tree | be2af882f976f0f30ad9bb04b7189fcaffcf8475 /tools/perf/util/probe-finder.c | |
parent | 6eca8cc35b50af1037bc919106dd6dd332c959c2 (diff) |
perf: Move arch specific code into separate arch directory
The perf userspace tool included some architecture specific code to map
registers from the DWARF register number into the names used by the regs
and stack access API.
This moves the architecture specific code out into a separate
arch/x86 directory along with the infrastructure required to use it.
Signed-off-by: Ian Munsie <imunsie@au.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 3e7977560be5..e7ee52fd0e09 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <stdarg.h> | 32 | #include <stdarg.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <dwarf-regs.h> | ||
34 | 35 | ||
35 | #include "string.h" | 36 | #include "string.h" |
36 | #include "event.h" | 37 | #include "event.h" |
@@ -38,61 +39,9 @@ | |||
38 | #include "util.h" | 39 | #include "util.h" |
39 | #include "probe-finder.h" | 40 | #include "probe-finder.h" |
40 | 41 | ||
41 | |||
42 | /* | ||
43 | * Generic dwarf analysis helpers | ||
44 | */ | ||
45 | |||
46 | #define X86_32_MAX_REGS 8 | ||
47 | const char *x86_32_regs_table[X86_32_MAX_REGS] = { | ||
48 | "%ax", | ||
49 | "%cx", | ||
50 | "%dx", | ||
51 | "%bx", | ||
52 | "$stack", /* Stack address instead of %sp */ | ||
53 | "%bp", | ||
54 | "%si", | ||
55 | "%di", | ||
56 | }; | ||
57 | |||
58 | #define X86_64_MAX_REGS 16 | ||
59 | const char *x86_64_regs_table[X86_64_MAX_REGS] = { | ||
60 | "%ax", | ||
61 | "%dx", | ||
62 | "%cx", | ||
63 | "%bx", | ||
64 | "%si", | ||
65 | "%di", | ||
66 | "%bp", | ||
67 | "%sp", | ||
68 | "%r8", | ||
69 | "%r9", | ||
70 | "%r10", | ||
71 | "%r11", | ||
72 | "%r12", | ||
73 | "%r13", | ||
74 | "%r14", | ||
75 | "%r15", | ||
76 | }; | ||
77 | |||
78 | /* TODO: switching by dwarf address size */ | ||
79 | #ifdef __x86_64__ | ||
80 | #define ARCH_MAX_REGS X86_64_MAX_REGS | ||
81 | #define arch_regs_table x86_64_regs_table | ||
82 | #else | ||
83 | #define ARCH_MAX_REGS X86_32_MAX_REGS | ||
84 | #define arch_regs_table x86_32_regs_table | ||
85 | #endif | ||
86 | |||
87 | /* Kprobe tracer basic type is up to u64 */ | 42 | /* Kprobe tracer basic type is up to u64 */ |
88 | #define MAX_BASIC_TYPE_BITS 64 | 43 | #define MAX_BASIC_TYPE_BITS 64 |
89 | 44 | ||
90 | /* Return architecture dependent register string (for kprobe-tracer) */ | ||
91 | static const char *get_arch_regstr(unsigned int n) | ||
92 | { | ||
93 | return (n <= ARCH_MAX_REGS) ? arch_regs_table[n] : NULL; | ||
94 | } | ||
95 | |||
96 | /* | 45 | /* |
97 | * Compare the tail of two strings. | 46 | * Compare the tail of two strings. |
98 | * Return 0 if whole of either string is same as another's tail part. | 47 | * Return 0 if whole of either string is same as another's tail part. |
@@ -447,7 +396,7 @@ static int convert_location(Dwarf_Op *op, struct probe_finder *pf) | |||
447 | 396 | ||
448 | regs = get_arch_regstr(regn); | 397 | regs = get_arch_regstr(regn); |
449 | if (!regs) { | 398 | if (!regs) { |
450 | pr_warning("%u exceeds max register number.\n", regn); | 399 | pr_warning("Mapping for DWARF register number %u missing on this architecture.", regn); |
451 | return -ERANGE; | 400 | return -ERANGE; |
452 | } | 401 | } |
453 | 402 | ||