ptrace.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include <linux/compiler.h>
  12. #include <linux/linkage.h>
  13. #include <linux/types.h>
  14. #include <asm/isadep.h>
  15. #include <uapi/asm/ptrace.h>
  16. struct task_struct;
  17. extern int ptrace_getregs(struct task_struct *child, __s64 __user *data);
  18. extern int ptrace_setregs(struct task_struct *child, __s64 __user *data);
  19. extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data);
  20. extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
  21. extern int ptrace_get_watch_regs(struct task_struct *child,
  22. struct pt_watch_regs __user *addr);
  23. extern int ptrace_set_watch_regs(struct task_struct *child,
  24. struct pt_watch_regs __user *addr);
  25. /*
  26. * Does the process account for user or for system time?
  27. */
  28. #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
  29. static inline int is_syscall_success(struct pt_regs *regs)
  30. {
  31. return !regs->regs[7];
  32. }
  33. static inline long regs_return_value(struct pt_regs *regs)
  34. {
  35. if (is_syscall_success(regs))
  36. return regs->regs[2];
  37. else
  38. return -regs->regs[2];
  39. }
  40. #define instruction_pointer(regs) ((regs)->cp0_epc)
  41. #define profile_pc(regs) instruction_pointer(regs)
  42. #define user_stack_pointer(r) ((r)->regs[29])
  43. extern asmlinkage void syscall_trace_enter(struct pt_regs *regs);
  44. extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
  45. extern void die(const char *, struct pt_regs *) __noreturn;
  46. static inline void die_if_kernel(const char *str, struct pt_regs *regs)
  47. {
  48. if (unlikely(!user_mode(regs)))
  49. die(str, regs);
  50. }
  51. #define current_pt_regs() \
  52. ({ \
  53. unsigned long sp = (unsigned long)__builtin_frame_address(0); \
  54. (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \
  55. })
  56. #endif /* _ASM_PTRACE_H */