ptrace.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef __SPARC_PTRACE_H
  2. #define __SPARC_PTRACE_H
  3. #include <uapi/asm/ptrace.h>
  4. #if defined(__sparc__) && defined(__arch64__)
  5. #ifndef __ASSEMBLY__
  6. #include <linux/threads.h>
  7. #include <asm/switch_to.h>
  8. static inline int pt_regs_trap_type(struct pt_regs *regs)
  9. {
  10. return regs->magic & 0x1ff;
  11. }
  12. static inline bool pt_regs_is_syscall(struct pt_regs *regs)
  13. {
  14. return (regs->tstate & TSTATE_SYSCALL);
  15. }
  16. static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
  17. {
  18. return (regs->tstate &= ~TSTATE_SYSCALL);
  19. }
  20. #define arch_ptrace_stop_needed(exit_code, info) \
  21. ({ flush_user_windows(); \
  22. get_thread_wsaved() != 0; \
  23. })
  24. #define arch_ptrace_stop(exit_code, info) \
  25. synchronize_user_stack()
  26. #define current_pt_regs() \
  27. ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
  28. struct global_reg_snapshot {
  29. unsigned long tstate;
  30. unsigned long tpc;
  31. unsigned long tnpc;
  32. unsigned long o7;
  33. unsigned long i7;
  34. unsigned long rpc;
  35. struct thread_info *thread;
  36. unsigned long pad1;
  37. };
  38. struct global_pmu_snapshot {
  39. unsigned long pcr[4];
  40. unsigned long pic[4];
  41. };
  42. union global_cpu_snapshot {
  43. struct global_reg_snapshot reg;
  44. struct global_pmu_snapshot pmu;
  45. };
  46. extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
  47. #define force_successful_syscall_return() set_thread_noerror(1)
  48. #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
  49. #define instruction_pointer(regs) ((regs)->tpc)
  50. #define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
  51. #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
  52. static inline int is_syscall_success(struct pt_regs *regs)
  53. {
  54. return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
  55. }
  56. static inline long regs_return_value(struct pt_regs *regs)
  57. {
  58. return regs->u_regs[UREG_I0];
  59. }
  60. #ifdef CONFIG_SMP
  61. unsigned long profile_pc(struct pt_regs *);
  62. #else
  63. #define profile_pc(regs) instruction_pointer(regs)
  64. #endif
  65. #else /* __ASSEMBLY__ */
  66. #endif /* __ASSEMBLY__ */
  67. #else /* (defined(__sparc__) && defined(__arch64__)) */
  68. #ifndef __ASSEMBLY__
  69. #include <asm/switch_to.h>
  70. static inline bool pt_regs_is_syscall(struct pt_regs *regs)
  71. {
  72. return (regs->psr & PSR_SYSCALL);
  73. }
  74. static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
  75. {
  76. return (regs->psr &= ~PSR_SYSCALL);
  77. }
  78. #define arch_ptrace_stop_needed(exit_code, info) \
  79. ({ flush_user_windows(); \
  80. current_thread_info()->w_saved != 0; \
  81. })
  82. #define arch_ptrace_stop(exit_code, info) \
  83. synchronize_user_stack()
  84. #define current_pt_regs() \
  85. ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
  86. #define user_mode(regs) (!((regs)->psr & PSR_PS))
  87. #define instruction_pointer(regs) ((regs)->pc)
  88. #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
  89. unsigned long profile_pc(struct pt_regs *);
  90. #else /* (!__ASSEMBLY__) */
  91. #endif /* (!__ASSEMBLY__) */
  92. #endif /* (defined(__sparc__) && defined(__arch64__)) */
  93. #define STACK_BIAS 2047
  94. /* global_reg_snapshot offsets */
  95. #define GR_SNAP_TSTATE 0x00
  96. #define GR_SNAP_TPC 0x08
  97. #define GR_SNAP_TNPC 0x10
  98. #define GR_SNAP_O7 0x18
  99. #define GR_SNAP_I7 0x20
  100. #define GR_SNAP_RPC 0x28
  101. #define GR_SNAP_THREAD 0x30
  102. #define GR_SNAP_PAD1 0x38
  103. #endif /* !(__SPARC_PTRACE_H) */