diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2005-09-03 18:57:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:06:18 -0400 |
commit | b3319f50acbe3a26c258cdd899b9baa2e5e94efc (patch) | |
tree | 7ef77c9cc60055323b40cb5a0a6760b56c37da31 /arch | |
parent | c3c433e4f33afe255389ba3b1a003dc8deb3de9a (diff) |
[PATCH] m68k: indent sys_ptrace
This reformats and properly indents sys_ptrace (only whitespace changes).
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/m68k/kernel/ptrace.c | 333 |
1 files changed, 166 insertions, 167 deletions
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index f4e1e5eb8e12..9bb25ea78677 100644 --- a/arch/m68k/kernel/ptrace.c +++ b/arch/m68k/kernel/ptrace.c | |||
@@ -95,7 +95,7 @@ static inline int put_reg(struct task_struct *task, int regno, | |||
95 | if (regno == PT_USP) | 95 | if (regno == PT_USP) |
96 | addr = &task->thread.usp; | 96 | addr = &task->thread.usp; |
97 | else if (regno < sizeof(regoff)/sizeof(regoff[0])) | 97 | else if (regno < sizeof(regoff)/sizeof(regoff[0])) |
98 | addr = (unsigned long *) (task->thread.esp0 + regoff[regno]); | 98 | addr = (unsigned long *)(task->thread.esp0 + regoff[regno]); |
99 | else | 99 | else |
100 | return -1; | 100 | return -1; |
101 | *addr = data; | 101 | *addr = data; |
@@ -157,216 +157,215 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) | |||
157 | 157 | ||
158 | switch (request) { | 158 | switch (request) { |
159 | /* when I and D space are separate, these will need to be fixed. */ | 159 | /* when I and D space are separate, these will need to be fixed. */ |
160 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 160 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
161 | case PTRACE_PEEKDATA: { | 161 | case PTRACE_PEEKDATA: { |
162 | unsigned long tmp; | 162 | unsigned long tmp; |
163 | int copied; | 163 | int copied; |
164 | 164 | ||
165 | copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); | 165 | copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); |
166 | ret = -EIO; | 166 | ret = -EIO; |
167 | if (copied != sizeof(tmp)) | 167 | if (copied != sizeof(tmp)) |
168 | break; | ||
169 | ret = put_user(tmp,(unsigned long *) data); | ||
170 | break; | 168 | break; |
171 | } | 169 | ret = put_user(tmp, (unsigned long *)data); |
170 | break; | ||
171 | } | ||
172 | 172 | ||
173 | /* read the word at location addr in the USER area. */ | 173 | /* read the word at location addr in the USER area. */ |
174 | case PTRACE_PEEKUSR: { | 174 | case PTRACE_PEEKUSR: { |
175 | unsigned long tmp; | 175 | unsigned long tmp; |
176 | 176 | ||
177 | ret = -EIO; | 177 | ret = -EIO; |
178 | if ((addr & 3) || addr < 0 || | 178 | if ((addr & 3) || addr < 0 || |
179 | addr > sizeof(struct user) - 3) | 179 | addr > sizeof(struct user) - 3) |
180 | break; | 180 | break; |
181 | 181 | ||
182 | tmp = 0; /* Default return condition */ | 182 | tmp = 0; /* Default return condition */ |
183 | addr = addr >> 2; /* temporary hack. */ | 183 | addr = addr >> 2; /* temporary hack. */ |
184 | ret = -EIO; | 184 | ret = -EIO; |
185 | if (addr < 19) { | 185 | if (addr < 19) { |
186 | tmp = get_reg(child, addr); | 186 | tmp = get_reg(child, addr); |
187 | if (addr == PT_SR) | 187 | if (addr == PT_SR) |
188 | tmp >>= 16; | 188 | tmp >>= 16; |
189 | } else if (addr >= 21 && addr < 49) { | 189 | } else if (addr >= 21 && addr < 49) { |
190 | tmp = child->thread.fp[addr - 21]; | 190 | tmp = child->thread.fp[addr - 21]; |
191 | #ifdef CONFIG_M68KFPU_EMU | 191 | #ifdef CONFIG_M68KFPU_EMU |
192 | /* Convert internal fpu reg representation | 192 | /* Convert internal fpu reg representation |
193 | * into long double format | 193 | * into long double format |
194 | */ | 194 | */ |
195 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) | 195 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) |
196 | tmp = ((tmp & 0xffff0000) << 15) | | 196 | tmp = ((tmp & 0xffff0000) << 15) | |
197 | ((tmp & 0x0000ffff) << 16); | 197 | ((tmp & 0x0000ffff) << 16); |
198 | #endif | 198 | #endif |
199 | } else | 199 | } else |
200 | break; | ||
201 | ret = put_user(tmp,(unsigned long *) data); | ||
202 | break; | 200 | break; |
203 | } | 201 | ret = put_user(tmp, (unsigned long *)data); |
202 | break; | ||
203 | } | ||
204 | 204 | ||
205 | /* when I and D space are separate, this will have to be fixed. */ | 205 | /* when I and D space are separate, this will have to be fixed. */ |
206 | case PTRACE_POKETEXT: /* write the word at location addr. */ | 206 | case PTRACE_POKETEXT: /* write the word at location addr. */ |
207 | case PTRACE_POKEDATA: | 207 | case PTRACE_POKEDATA: |
208 | ret = 0; | 208 | ret = 0; |
209 | if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) | 209 | if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) |
210 | break; | ||
211 | ret = -EIO; | ||
212 | break; | 210 | break; |
211 | ret = -EIO; | ||
212 | break; | ||
213 | 213 | ||
214 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ | 214 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ |
215 | ret = -EIO; | 215 | ret = -EIO; |
216 | if ((addr & 3) || addr < 0 || | 216 | if ((addr & 3) || addr < 0 || |
217 | addr > sizeof(struct user) - 3) | 217 | addr > sizeof(struct user) - 3) |
218 | break; | ||
219 | |||
220 | addr = addr >> 2; /* temporary hack. */ | ||
221 | |||
222 | if (addr == PT_SR) { | ||
223 | data &= SR_MASK; | ||
224 | data <<= 16; | ||
225 | data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); | ||
226 | } | ||
227 | if (addr < 19) { | ||
228 | if (put_reg(child, addr, data)) | ||
229 | break; | ||
230 | ret = 0; | ||
231 | break; | ||
232 | } | ||
233 | if (addr >= 21 && addr < 48) | ||
234 | { | ||
235 | #ifdef CONFIG_M68KFPU_EMU | ||
236 | /* Convert long double format | ||
237 | * into internal fpu reg representation | ||
238 | */ | ||
239 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { | ||
240 | data = (unsigned long)data << 15; | ||
241 | data = (data & 0xffff0000) | | ||
242 | ((data & 0x0000ffff) >> 1); | ||
243 | } | ||
244 | #endif | ||
245 | child->thread.fp[addr - 21] = data; | ||
246 | ret = 0; | ||
247 | } | ||
248 | break; | 218 | break; |
249 | 219 | ||
250 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ | 220 | addr = addr >> 2; /* temporary hack. */ |
251 | case PTRACE_CONT: { /* restart after signal. */ | ||
252 | long tmp; | ||
253 | 221 | ||
254 | ret = -EIO; | 222 | if (addr == PT_SR) { |
255 | if (!valid_signal(data)) | 223 | data &= SR_MASK; |
224 | data <<= 16; | ||
225 | data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); | ||
226 | } | ||
227 | if (addr < 19) { | ||
228 | if (put_reg(child, addr, data)) | ||
256 | break; | 229 | break; |
257 | if (request == PTRACE_SYSCALL) { | ||
258 | child->thread.work.syscall_trace = ~0; | ||
259 | } else { | ||
260 | child->thread.work.syscall_trace = 0; | ||
261 | } | ||
262 | child->exit_code = data; | ||
263 | /* make sure the single step bit is not set. */ | ||
264 | tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); | ||
265 | put_reg(child, PT_SR, tmp); | ||
266 | child->thread.work.delayed_trace = 0; | ||
267 | wake_up_process(child); | ||
268 | ret = 0; | 230 | ret = 0; |
269 | break; | 231 | break; |
270 | } | 232 | } |
271 | 233 | if (addr >= 21 && addr < 48) { | |
272 | /* | 234 | #ifdef CONFIG_M68KFPU_EMU |
273 | * make the child exit. Best I can do is send it a sigkill. | 235 | /* Convert long double format |
274 | * perhaps it should be put in the status that it wants to | 236 | * into internal fpu reg representation |
275 | * exit. | 237 | */ |
276 | */ | 238 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { |
277 | case PTRACE_KILL: { | 239 | data = (unsigned long)data << 15; |
278 | long tmp; | 240 | data = (data & 0xffff0000) | |
279 | 241 | ((data & 0x0000ffff) >> 1); | |
242 | } | ||
243 | #endif | ||
244 | child->thread.fp[addr - 21] = data; | ||
280 | ret = 0; | 245 | ret = 0; |
281 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ | ||
282 | break; | ||
283 | child->exit_code = SIGKILL; | ||
284 | /* make sure the single step bit is not set. */ | ||
285 | tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); | ||
286 | put_reg(child, PT_SR, tmp); | ||
287 | child->thread.work.delayed_trace = 0; | ||
288 | wake_up_process(child); | ||
289 | break; | ||
290 | } | 246 | } |
247 | break; | ||
291 | 248 | ||
292 | case PTRACE_SINGLESTEP: { /* set the trap flag. */ | 249 | case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ |
293 | long tmp; | 250 | case PTRACE_CONT: { /* restart after signal. */ |
251 | long tmp; | ||
294 | 252 | ||
295 | ret = -EIO; | 253 | ret = -EIO; |
296 | if (!valid_signal(data)) | 254 | if (!valid_signal(data)) |
297 | break; | 255 | break; |
256 | if (request == PTRACE_SYSCALL) { | ||
257 | child->thread.work.syscall_trace = ~0; | ||
258 | } else { | ||
298 | child->thread.work.syscall_trace = 0; | 259 | child->thread.work.syscall_trace = 0; |
299 | tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); | 260 | } |
300 | put_reg(child, PT_SR, tmp); | 261 | child->exit_code = data; |
301 | child->thread.work.delayed_trace = 1; | 262 | /* make sure the single step bit is not set. */ |
263 | tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); | ||
264 | put_reg(child, PT_SR, tmp); | ||
265 | child->thread.work.delayed_trace = 0; | ||
266 | wake_up_process(child); | ||
267 | ret = 0; | ||
268 | break; | ||
269 | } | ||
302 | 270 | ||
303 | child->exit_code = data; | 271 | /* |
304 | /* give it a chance to run. */ | 272 | * make the child exit. Best I can do is send it a sigkill. |
305 | wake_up_process(child); | 273 | * perhaps it should be put in the status that it wants to |
306 | ret = 0; | 274 | * exit. |
275 | */ | ||
276 | case PTRACE_KILL: { | ||
277 | long tmp; | ||
278 | |||
279 | ret = 0; | ||
280 | if (child->exit_state == EXIT_ZOMBIE) /* already dead */ | ||
307 | break; | 281 | break; |
308 | } | 282 | child->exit_code = SIGKILL; |
283 | /* make sure the single step bit is not set. */ | ||
284 | tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); | ||
285 | put_reg(child, PT_SR, tmp); | ||
286 | child->thread.work.delayed_trace = 0; | ||
287 | wake_up_process(child); | ||
288 | break; | ||
289 | } | ||
290 | |||
291 | case PTRACE_SINGLESTEP: { /* set the trap flag. */ | ||
292 | long tmp; | ||
309 | 293 | ||
310 | case PTRACE_DETACH: /* detach a process that was attached. */ | 294 | ret = -EIO; |
311 | ret = ptrace_detach(child, data); | 295 | if (!valid_signal(data)) |
312 | break; | 296 | break; |
297 | child->thread.work.syscall_trace = 0; | ||
298 | tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); | ||
299 | put_reg(child, PT_SR, tmp); | ||
300 | child->thread.work.delayed_trace = 1; | ||
301 | |||
302 | child->exit_code = data; | ||
303 | /* give it a chance to run. */ | ||
304 | wake_up_process(child); | ||
305 | ret = 0; | ||
306 | break; | ||
307 | } | ||
308 | |||
309 | case PTRACE_DETACH: /* detach a process that was attached. */ | ||
310 | ret = ptrace_detach(child, data); | ||
311 | break; | ||
313 | 312 | ||
314 | case PTRACE_GETREGS: { /* Get all gp regs from the child. */ | 313 | case PTRACE_GETREGS: { /* Get all gp regs from the child. */ |
315 | int i; | 314 | int i; |
316 | unsigned long tmp; | 315 | unsigned long tmp; |
317 | for (i = 0; i < 19; i++) { | 316 | for (i = 0; i < 19; i++) { |
318 | tmp = get_reg(child, i); | 317 | tmp = get_reg(child, i); |
319 | if (i == PT_SR) | 318 | if (i == PT_SR) |
320 | tmp >>= 16; | 319 | tmp >>= 16; |
321 | if (put_user(tmp, (unsigned long *) data)) { | 320 | if (put_user(tmp, (unsigned long *)data)) { |
322 | ret = -EFAULT; | 321 | ret = -EFAULT; |
323 | break; | 322 | break; |
324 | } | ||
325 | data += sizeof(long); | ||
326 | } | 323 | } |
327 | ret = 0; | 324 | data += sizeof(long); |
328 | break; | ||
329 | } | 325 | } |
326 | ret = 0; | ||
327 | break; | ||
328 | } | ||
330 | 329 | ||
331 | case PTRACE_SETREGS: { /* Set all gp regs in the child. */ | 330 | case PTRACE_SETREGS: { /* Set all gp regs in the child. */ |
332 | int i; | 331 | int i; |
333 | unsigned long tmp; | 332 | unsigned long tmp; |
334 | for (i = 0; i < 19; i++) { | 333 | for (i = 0; i < 19; i++) { |
335 | if (get_user(tmp, (unsigned long *) data)) { | 334 | if (get_user(tmp, (unsigned long *)data)) { |
336 | ret = -EFAULT; | 335 | ret = -EFAULT; |
337 | break; | 336 | break; |
338 | } | 337 | } |
339 | if (i == PT_SR) { | 338 | if (i == PT_SR) { |
340 | tmp &= SR_MASK; | 339 | tmp &= SR_MASK; |
341 | tmp <<= 16; | 340 | tmp <<= 16; |
342 | tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); | 341 | tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); |
343 | } | ||
344 | put_reg(child, i, tmp); | ||
345 | data += sizeof(long); | ||
346 | } | 342 | } |
347 | ret = 0; | 343 | put_reg(child, i, tmp); |
348 | break; | 344 | data += sizeof(long); |
349 | } | 345 | } |
346 | ret = 0; | ||
347 | break; | ||
348 | } | ||
350 | 349 | ||
351 | case PTRACE_GETFPREGS: { /* Get the child FPU state. */ | 350 | case PTRACE_GETFPREGS: { /* Get the child FPU state. */ |
352 | ret = 0; | 351 | ret = 0; |
353 | if (copy_to_user((void *)data, &child->thread.fp, | 352 | if (copy_to_user((void *)data, &child->thread.fp, |
354 | sizeof(struct user_m68kfp_struct))) | 353 | sizeof(struct user_m68kfp_struct))) |
355 | ret = -EFAULT; | 354 | ret = -EFAULT; |
356 | break; | 355 | break; |
357 | } | 356 | } |
358 | 357 | ||
359 | case PTRACE_SETFPREGS: { /* Set the child FPU state. */ | 358 | case PTRACE_SETFPREGS: { /* Set the child FPU state. */ |
360 | ret = 0; | 359 | ret = 0; |
361 | if (copy_from_user(&child->thread.fp, (void *)data, | 360 | if (copy_from_user(&child->thread.fp, (void *)data, |
362 | sizeof(struct user_m68kfp_struct))) | 361 | sizeof(struct user_m68kfp_struct))) |
363 | ret = -EFAULT; | 362 | ret = -EFAULT; |
364 | break; | 363 | break; |
365 | } | 364 | } |
366 | 365 | ||
367 | default: | 366 | default: |
368 | ret = ptrace_request(child, request, addr, data); | 367 | ret = ptrace_request(child, request, addr, data); |
369 | break; | 368 | break; |
370 | } | 369 | } |
371 | out_tsk: | 370 | out_tsk: |
372 | put_task_struct(child); | 371 | put_task_struct(child); |