Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | |
3 | * License. See the file "COPYING" in the main directory of this archive | |
4 | * for more details. | |
5 | * | |
6 | * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle | |
7 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. | |
8 | */ | |
9 | #ifndef _ASM_PTRACE_H | |
10 | #define _ASM_PTRACE_H | |
11 | ||
1da177e4 | 12 | |
0926bf95 | 13 | #include <linux/compiler.h> |
1da177e4 | 14 | #include <linux/linkage.h> |
f6a3176a | 15 | #include <linux/types.h> |
8f9a2b32 | 16 | #include <asm/isadep.h> |
61730c53 | 17 | #include <uapi/asm/ptrace.h> |
1da177e4 | 18 | |
0926bf95 DD |
19 | struct task_struct; |
20 | ||
d302d05c RB |
21 | extern int ptrace_getregs(struct task_struct *child, __s64 __user *data); |
22 | extern int ptrace_setregs(struct task_struct *child, __s64 __user *data); | |
23 | ||
24 | extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data); | |
25 | extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data); | |
26 | ||
0926bf95 DD |
27 | extern int ptrace_get_watch_regs(struct task_struct *child, |
28 | struct pt_watch_regs __user *addr); | |
29 | extern int ptrace_set_watch_regs(struct task_struct *child, | |
30 | struct pt_watch_regs __user *addr); | |
31 | ||
1da177e4 LT |
32 | /* |
33 | * Does the process account for user or for system time? | |
34 | */ | |
35 | #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER) | |
36 | ||
d7e7528b EP |
37 | static inline int is_syscall_success(struct pt_regs *regs) |
38 | { | |
39 | return !regs->regs[7]; | |
40 | } | |
41 | ||
42 | static inline long regs_return_value(struct pt_regs *regs) | |
43 | { | |
44 | if (is_syscall_success(regs)) | |
45 | return regs->regs[2]; | |
46 | else | |
47 | return -regs->regs[2]; | |
48 | } | |
49 | ||
1da177e4 LT |
50 | #define instruction_pointer(regs) ((regs)->cp0_epc) |
51 | #define profile_pc(regs) instruction_pointer(regs) | |
5208ba24 | 52 | #define user_stack_pointer(r) ((r)->regs[29]) |
1da177e4 | 53 | |
8b659a39 RB |
54 | extern asmlinkage void syscall_trace_enter(struct pt_regs *regs); |
55 | extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); | |
1da177e4 | 56 | |
ff2d8b19 | 57 | extern void die(const char *, struct pt_regs *) __noreturn; |
2d911e9a | 58 | |
ce384d83 | 59 | static inline void die_if_kernel(const char *str, struct pt_regs *regs) |
2d911e9a RB |
60 | { |
61 | if (unlikely(!user_mode(regs))) | |
62 | die(str, regs); | |
63 | } | |
64 | ||
baf9ff74 RB |
65 | #define current_pt_regs() \ |
66 | ({ \ | |
67 | unsigned long sp = (unsigned long)__builtin_frame_address(0); \ | |
68 | (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \ | |
69 | }) | |
70 | ||
1da177e4 | 71 | #endif /* _ASM_PTRACE_H */ |