diff options
Diffstat (limited to 'arch/powerpc/kernel/ptrace.c')
-rw-r--r-- | arch/powerpc/kernel/ptrace.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index ed2cfe17d25e..7a0c0199ea28 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -39,6 +39,109 @@ | |||
39 | #include <asm/system.h> | 39 | #include <asm/system.h> |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * The parameter save area on the stack is used to store arguments being passed | ||
43 | * to callee function and is located at fixed offset from stack pointer. | ||
44 | */ | ||
45 | #ifdef CONFIG_PPC32 | ||
46 | #define PARAMETER_SAVE_AREA_OFFSET 24 /* bytes */ | ||
47 | #else /* CONFIG_PPC32 */ | ||
48 | #define PARAMETER_SAVE_AREA_OFFSET 48 /* bytes */ | ||
49 | #endif | ||
50 | |||
51 | struct pt_regs_offset { | ||
52 | const char *name; | ||
53 | int offset; | ||
54 | }; | ||
55 | |||
56 | #define STR(s) #s /* convert to string */ | ||
57 | #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} | ||
58 | #define GPR_OFFSET_NAME(num) \ | ||
59 | {.name = STR(gpr##num), .offset = offsetof(struct pt_regs, gpr[num])} | ||
60 | #define REG_OFFSET_END {.name = NULL, .offset = 0} | ||
61 | |||
62 | static const struct pt_regs_offset regoffset_table[] = { | ||
63 | GPR_OFFSET_NAME(0), | ||
64 | GPR_OFFSET_NAME(1), | ||
65 | GPR_OFFSET_NAME(2), | ||
66 | GPR_OFFSET_NAME(3), | ||
67 | GPR_OFFSET_NAME(4), | ||
68 | GPR_OFFSET_NAME(5), | ||
69 | GPR_OFFSET_NAME(6), | ||
70 | GPR_OFFSET_NAME(7), | ||
71 | GPR_OFFSET_NAME(8), | ||
72 | GPR_OFFSET_NAME(9), | ||
73 | GPR_OFFSET_NAME(10), | ||
74 | GPR_OFFSET_NAME(11), | ||
75 | GPR_OFFSET_NAME(12), | ||
76 | GPR_OFFSET_NAME(13), | ||
77 | GPR_OFFSET_NAME(14), | ||
78 | GPR_OFFSET_NAME(15), | ||
79 | GPR_OFFSET_NAME(16), | ||
80 | GPR_OFFSET_NAME(17), | ||
81 | GPR_OFFSET_NAME(18), | ||
82 | GPR_OFFSET_NAME(19), | ||
83 | GPR_OFFSET_NAME(20), | ||
84 | GPR_OFFSET_NAME(21), | ||
85 | GPR_OFFSET_NAME(22), | ||
86 | GPR_OFFSET_NAME(23), | ||
87 | GPR_OFFSET_NAME(24), | ||
88 | GPR_OFFSET_NAME(25), | ||
89 | GPR_OFFSET_NAME(26), | ||
90 | GPR_OFFSET_NAME(27), | ||
91 | GPR_OFFSET_NAME(28), | ||
92 | GPR_OFFSET_NAME(29), | ||
93 | GPR_OFFSET_NAME(30), | ||
94 | GPR_OFFSET_NAME(31), | ||
95 | REG_OFFSET_NAME(nip), | ||
96 | REG_OFFSET_NAME(msr), | ||
97 | REG_OFFSET_NAME(ctr), | ||
98 | REG_OFFSET_NAME(link), | ||
99 | REG_OFFSET_NAME(xer), | ||
100 | REG_OFFSET_NAME(ccr), | ||
101 | #ifdef CONFIG_PPC64 | ||
102 | REG_OFFSET_NAME(softe), | ||
103 | #else | ||
104 | REG_OFFSET_NAME(mq), | ||
105 | #endif | ||
106 | REG_OFFSET_NAME(trap), | ||
107 | REG_OFFSET_NAME(dar), | ||
108 | REG_OFFSET_NAME(dsisr), | ||
109 | REG_OFFSET_END, | ||
110 | }; | ||
111 | |||
112 | /** | ||
113 | * regs_query_register_offset() - query register offset from its name | ||
114 | * @name: the name of a register | ||
115 | * | ||
116 | * regs_query_register_offset() returns the offset of a register in struct | ||
117 | * pt_regs from its name. If the name is invalid, this returns -EINVAL; | ||
118 | */ | ||
119 | int regs_query_register_offset(const char *name) | ||
120 | { | ||
121 | const struct pt_regs_offset *roff; | ||
122 | for (roff = regoffset_table; roff->name != NULL; roff++) | ||
123 | if (!strcmp(roff->name, name)) | ||
124 | return roff->offset; | ||
125 | return -EINVAL; | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * regs_query_register_name() - query register name from its offset | ||
130 | * @offset: the offset of a register in struct pt_regs. | ||
131 | * | ||
132 | * regs_query_register_name() returns the name of a register from its | ||
133 | * offset in struct pt_regs. If the @offset is invalid, this returns NULL; | ||
134 | */ | ||
135 | const char *regs_query_register_name(unsigned int offset) | ||
136 | { | ||
137 | const struct pt_regs_offset *roff; | ||
138 | for (roff = regoffset_table; roff->name != NULL; roff++) | ||
139 | if (roff->offset == offset) | ||
140 | return roff->name; | ||
141 | return NULL; | ||
142 | } | ||
143 | |||
144 | /* | ||
42 | * does not yet catch signals sent when the child dies. | 145 | * does not yet catch signals sent when the child dies. |
43 | * in exit.c or in signal.c. | 146 | * in exit.c or in signal.c. |
44 | */ | 147 | */ |