ptrace_32.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #ifndef _SPARC_PTRACE_H
  2. #define _SPARC_PTRACE_H
  3. #include <asm/psr.h>
  4. /* This struct defines the way the registers are stored on the
  5. * stack during a system call and basically all traps.
  6. */
  7. #ifndef __ASSEMBLY__
  8. #include <linux/types.h>
  9. struct pt_regs {
  10. unsigned long psr;
  11. unsigned long pc;
  12. unsigned long npc;
  13. unsigned long y;
  14. unsigned long u_regs[16]; /* globals and ins */
  15. };
  16. #define UREG_G0 0
  17. #define UREG_G1 1
  18. #define UREG_G2 2
  19. #define UREG_G3 3
  20. #define UREG_G4 4
  21. #define UREG_G5 5
  22. #define UREG_G6 6
  23. #define UREG_G7 7
  24. #define UREG_I0 8
  25. #define UREG_I1 9
  26. #define UREG_I2 10
  27. #define UREG_I3 11
  28. #define UREG_I4 12
  29. #define UREG_I5 13
  30. #define UREG_I6 14
  31. #define UREG_I7 15
  32. #define UREG_WIM UREG_G0
  33. #define UREG_FADDR UREG_G0
  34. #define UREG_FP UREG_I6
  35. #define UREG_RETPC UREG_I7
  36. /* A register window */
  37. struct reg_window {
  38. unsigned long locals[8];
  39. unsigned long ins[8];
  40. };
  41. /* A Sparc stack frame */
  42. struct sparc_stackf {
  43. unsigned long locals[8];
  44. unsigned long ins[6];
  45. struct sparc_stackf *fp;
  46. unsigned long callers_pc;
  47. char *structptr;
  48. unsigned long xargs[6];
  49. unsigned long xxargs[1];
  50. };
  51. #define TRACEREG_SZ sizeof(struct pt_regs)
  52. #define STACKFRAME_SZ sizeof(struct sparc_stackf)
  53. #ifdef __KERNEL__
  54. #include <asm/system.h>
  55. static inline bool pt_regs_is_syscall(struct pt_regs *regs)
  56. {
  57. return (regs->psr & PSR_SYSCALL);
  58. }
  59. static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
  60. {
  61. return (regs->psr &= ~PSR_SYSCALL);
  62. }
  63. #define arch_ptrace_stop_needed(exit_code, info) \
  64. ({ flush_user_windows(); \
  65. current_thread_info()->w_saved != 0; \
  66. })
  67. #define arch_ptrace_stop(exit_code, info) \
  68. synchronize_user_stack()
  69. #define user_mode(regs) (!((regs)->psr & PSR_PS))
  70. #define instruction_pointer(regs) ((regs)->pc)
  71. #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
  72. unsigned long profile_pc(struct pt_regs *);
  73. extern void show_regs(struct pt_regs *);
  74. #endif
  75. #else /* __ASSEMBLY__ */
  76. /* For assembly code. */
  77. #define TRACEREG_SZ 0x50
  78. #define STACKFRAME_SZ 0x60
  79. #endif
  80. /*
  81. * The asm-offsets.h is a generated file, so we cannot include it.
  82. * It may be OK for glibc headers, but it's utterly pointless for C code.
  83. * The assembly code using those offsets has to include it explicitly.
  84. */
  85. /* #include <asm/asm-offsets.h> */
  86. /* These are for pt_regs. */
  87. #define PT_PSR 0x0
  88. #define PT_PC 0x4
  89. #define PT_NPC 0x8
  90. #define PT_Y 0xc
  91. #define PT_G0 0x10
  92. #define PT_WIM PT_G0
  93. #define PT_G1 0x14
  94. #define PT_G2 0x18
  95. #define PT_G3 0x1c
  96. #define PT_G4 0x20
  97. #define PT_G5 0x24
  98. #define PT_G6 0x28
  99. #define PT_G7 0x2c
  100. #define PT_I0 0x30
  101. #define PT_I1 0x34
  102. #define PT_I2 0x38
  103. #define PT_I3 0x3c
  104. #define PT_I4 0x40
  105. #define PT_I5 0x44
  106. #define PT_I6 0x48
  107. #define PT_FP PT_I6
  108. #define PT_I7 0x4c
  109. /* Reg_window offsets */
  110. #define RW_L0 0x00
  111. #define RW_L1 0x04
  112. #define RW_L2 0x08
  113. #define RW_L3 0x0c
  114. #define RW_L4 0x10
  115. #define RW_L5 0x14
  116. #define RW_L6 0x18
  117. #define RW_L7 0x1c
  118. #define RW_I0 0x20
  119. #define RW_I1 0x24
  120. #define RW_I2 0x28
  121. #define RW_I3 0x2c
  122. #define RW_I4 0x30
  123. #define RW_I5 0x34
  124. #define RW_I6 0x38
  125. #define RW_I7 0x3c
  126. /* Stack_frame offsets */
  127. #define SF_L0 0x00
  128. #define SF_L1 0x04
  129. #define SF_L2 0x08
  130. #define SF_L3 0x0c
  131. #define SF_L4 0x10
  132. #define SF_L5 0x14
  133. #define SF_L6 0x18
  134. #define SF_L7 0x1c
  135. #define SF_I0 0x20
  136. #define SF_I1 0x24
  137. #define SF_I2 0x28
  138. #define SF_I3 0x2c
  139. #define SF_I4 0x30
  140. #define SF_I5 0x34
  141. #define SF_FP 0x38
  142. #define SF_PC 0x3c
  143. #define SF_RETP 0x40
  144. #define SF_XARG0 0x44
  145. #define SF_XARG1 0x48
  146. #define SF_XARG2 0x4c
  147. #define SF_XARG3 0x50
  148. #define SF_XARG4 0x54
  149. #define SF_XARG5 0x58
  150. #define SF_XXARG 0x5c
  151. /* Stuff for the ptrace system call */
  152. #define PTRACE_SPARC_DETACH 11
  153. #define PTRACE_GETREGS 12
  154. #define PTRACE_SETREGS 13
  155. #define PTRACE_GETFPREGS 14
  156. #define PTRACE_SETFPREGS 15
  157. #define PTRACE_READDATA 16
  158. #define PTRACE_WRITEDATA 17
  159. #define PTRACE_READTEXT 18
  160. #define PTRACE_WRITETEXT 19
  161. #define PTRACE_GETFPAREGS 20
  162. #define PTRACE_SETFPAREGS 21
  163. #endif /* !(_SPARC_PTRACE_H) */