ptrace-common.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * linux/arch/ppc64/kernel/ptrace-common.h
  3. *
  4. * Copyright (c) 2002 Stephen Rothwell, IBM Coproration
  5. * Extracted from ptrace.c and ptrace32.c
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file README.legal in the main directory of
  9. * this archive for more details.
  10. */
  11. #ifndef _PPC64_PTRACE_COMMON_H
  12. #define _PPC64_PTRACE_COMMON_H
  13. /*
  14. * Set of msr bits that gdb can change on behalf of a process.
  15. */
  16. #define MSR_DEBUGCHANGE (MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)
  17. /*
  18. * Get contents of register REGNO in task TASK.
  19. */
  20. static inline unsigned long get_reg(struct task_struct *task, int regno)
  21. {
  22. unsigned long tmp = 0;
  23. /*
  24. * Put the correct FP bits in, they might be wrong as a result
  25. * of our lazy FP restore.
  26. */
  27. if (regno == PT_MSR) {
  28. tmp = ((unsigned long *)task->thread.regs)[PT_MSR];
  29. tmp |= task->thread.fpexc_mode;
  30. } else if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) {
  31. tmp = ((unsigned long *)task->thread.regs)[regno];
  32. }
  33. return tmp;
  34. }
  35. /*
  36. * Write contents of register REGNO in task TASK.
  37. */
  38. static inline int put_reg(struct task_struct *task, int regno,
  39. unsigned long data)
  40. {
  41. if (regno < PT_SOFTE) {
  42. if (regno == PT_MSR)
  43. data = (data & MSR_DEBUGCHANGE)
  44. | (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
  45. ((unsigned long *)task->thread.regs)[regno] = data;
  46. return 0;
  47. }
  48. return -EIO;
  49. }
  50. static inline void set_single_step(struct task_struct *task)
  51. {
  52. struct pt_regs *regs = task->thread.regs;
  53. if (regs != NULL)
  54. regs->msr |= MSR_SE;
  55. set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
  56. }
  57. static inline void clear_single_step(struct task_struct *task)
  58. {
  59. struct pt_regs *regs = task->thread.regs;
  60. if (regs != NULL)
  61. regs->msr &= ~MSR_SE;
  62. clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
  63. }
  64. #endif /* _PPC64_PTRACE_COMMON_H */