ptrace.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /* $Id: ptrace.h,v 1.14 2002/02/09 19:49:32 davem Exp $ */
  2. #ifndef _SPARC64_PTRACE_H
  3. #define _SPARC64_PTRACE_H
  4. #include <asm/pstate.h>
  5. /* This struct defines the way the registers are stored on the
  6. * stack during a system call and basically all traps.
  7. */
  8. #define PT_REGS_MAGIC 0x57ac6c00
  9. #ifndef __ASSEMBLY__
  10. struct pt_regs {
  11. unsigned long u_regs[16]; /* globals and ins */
  12. unsigned long tstate;
  13. unsigned long tpc;
  14. unsigned long tnpc;
  15. unsigned int y;
  16. /* We encode a magic number, PT_REGS_MAGIC, along
  17. * with the %tt (trap type) register value at trap
  18. * entry time. The magic number allows us to identify
  19. * accurately a trap stack frame in the stack
  20. * unwinder, and the %tt value allows us to test
  21. * things like "in a system call" etc. for an arbitray
  22. * process.
  23. *
  24. * The PT_REGS_MAGIC is choosen such that it can be
  25. * loaded completely using just a sethi instruction.
  26. */
  27. unsigned int magic;
  28. };
  29. struct pt_regs32 {
  30. unsigned int psr;
  31. unsigned int pc;
  32. unsigned int npc;
  33. unsigned int y;
  34. unsigned int u_regs[16]; /* globals and ins */
  35. };
  36. #define UREG_G0 0
  37. #define UREG_G1 1
  38. #define UREG_G2 2
  39. #define UREG_G3 3
  40. #define UREG_G4 4
  41. #define UREG_G5 5
  42. #define UREG_G6 6
  43. #define UREG_G7 7
  44. #define UREG_I0 8
  45. #define UREG_I1 9
  46. #define UREG_I2 10
  47. #define UREG_I3 11
  48. #define UREG_I4 12
  49. #define UREG_I5 13
  50. #define UREG_I6 14
  51. #define UREG_I7 15
  52. #define UREG_FP UREG_I6
  53. #define UREG_RETPC UREG_I7
  54. /* A V9 register window */
  55. struct reg_window {
  56. unsigned long locals[8];
  57. unsigned long ins[8];
  58. };
  59. /* A 32-bit register window. */
  60. struct reg_window32 {
  61. unsigned int locals[8];
  62. unsigned int ins[8];
  63. };
  64. /* A V9 Sparc stack frame */
  65. struct sparc_stackf {
  66. unsigned long locals[8];
  67. unsigned long ins[6];
  68. struct sparc_stackf *fp;
  69. unsigned long callers_pc;
  70. char *structptr;
  71. unsigned long xargs[6];
  72. unsigned long xxargs[1];
  73. };
  74. /* A 32-bit Sparc stack frame */
  75. struct sparc_stackf32 {
  76. unsigned int locals[8];
  77. unsigned int ins[6];
  78. unsigned int fp;
  79. unsigned int callers_pc;
  80. unsigned int structptr;
  81. unsigned int xargs[6];
  82. unsigned int xxargs[1];
  83. };
  84. struct sparc_trapf {
  85. unsigned long locals[8];
  86. unsigned long ins[8];
  87. unsigned long _unused;
  88. struct pt_regs *regs;
  89. };
  90. #define TRACEREG_SZ sizeof(struct pt_regs)
  91. #define STACKFRAME_SZ sizeof(struct sparc_stackf)
  92. #define TRACEREG32_SZ sizeof(struct pt_regs32)
  93. #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
  94. #ifdef __KERNEL__
  95. #define __ARCH_WANT_COMPAT_SYS_PTRACE
  96. #define force_successful_syscall_return() \
  97. do { current_thread_info()->syscall_noerror = 1; \
  98. } while (0)
  99. #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
  100. #define instruction_pointer(regs) ((regs)->tpc)
  101. #define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
  102. #ifdef CONFIG_SMP
  103. extern unsigned long profile_pc(struct pt_regs *);
  104. #else
  105. #define profile_pc(regs) instruction_pointer(regs)
  106. #endif
  107. extern void show_regs(struct pt_regs *);
  108. extern void __show_regs(struct pt_regs *);
  109. #endif
  110. #else /* __ASSEMBLY__ */
  111. /* For assembly code. */
  112. #define TRACEREG_SZ 0xa0
  113. #define STACKFRAME_SZ 0xc0
  114. #define TRACEREG32_SZ 0x50
  115. #define STACKFRAME32_SZ 0x60
  116. #endif
  117. #ifdef __KERNEL__
  118. #define STACK_BIAS 2047
  119. #endif
  120. /* These are for pt_regs. */
  121. #define PT_V9_G0 0x00
  122. #define PT_V9_G1 0x08
  123. #define PT_V9_G2 0x10
  124. #define PT_V9_G3 0x18
  125. #define PT_V9_G4 0x20
  126. #define PT_V9_G5 0x28
  127. #define PT_V9_G6 0x30
  128. #define PT_V9_G7 0x38
  129. #define PT_V9_I0 0x40
  130. #define PT_V9_I1 0x48
  131. #define PT_V9_I2 0x50
  132. #define PT_V9_I3 0x58
  133. #define PT_V9_I4 0x60
  134. #define PT_V9_I5 0x68
  135. #define PT_V9_I6 0x70
  136. #define PT_V9_FP PT_V9_I6
  137. #define PT_V9_I7 0x78
  138. #define PT_V9_TSTATE 0x80
  139. #define PT_V9_TPC 0x88
  140. #define PT_V9_TNPC 0x90
  141. #define PT_V9_Y 0x98
  142. #define PT_V9_MAGIC 0x9c
  143. #define PT_TSTATE PT_V9_TSTATE
  144. #define PT_TPC PT_V9_TPC
  145. #define PT_TNPC PT_V9_TNPC
  146. /* These for pt_regs32. */
  147. #define PT_PSR 0x0
  148. #define PT_PC 0x4
  149. #define PT_NPC 0x8
  150. #define PT_Y 0xc
  151. #define PT_G0 0x10
  152. #define PT_WIM PT_G0
  153. #define PT_G1 0x14
  154. #define PT_G2 0x18
  155. #define PT_G3 0x1c
  156. #define PT_G4 0x20
  157. #define PT_G5 0x24
  158. #define PT_G6 0x28
  159. #define PT_G7 0x2c
  160. #define PT_I0 0x30
  161. #define PT_I1 0x34
  162. #define PT_I2 0x38
  163. #define PT_I3 0x3c
  164. #define PT_I4 0x40
  165. #define PT_I5 0x44
  166. #define PT_I6 0x48
  167. #define PT_FP PT_I6
  168. #define PT_I7 0x4c
  169. /* Reg_window offsets */
  170. #define RW_V9_L0 0x00
  171. #define RW_V9_L1 0x08
  172. #define RW_V9_L2 0x10
  173. #define RW_V9_L3 0x18
  174. #define RW_V9_L4 0x20
  175. #define RW_V9_L5 0x28
  176. #define RW_V9_L6 0x30
  177. #define RW_V9_L7 0x38
  178. #define RW_V9_I0 0x40
  179. #define RW_V9_I1 0x48
  180. #define RW_V9_I2 0x50
  181. #define RW_V9_I3 0x58
  182. #define RW_V9_I4 0x60
  183. #define RW_V9_I5 0x68
  184. #define RW_V9_I6 0x70
  185. #define RW_V9_I7 0x78
  186. #define RW_L0 0x00
  187. #define RW_L1 0x04
  188. #define RW_L2 0x08
  189. #define RW_L3 0x0c
  190. #define RW_L4 0x10
  191. #define RW_L5 0x14
  192. #define RW_L6 0x18
  193. #define RW_L7 0x1c
  194. #define RW_I0 0x20
  195. #define RW_I1 0x24
  196. #define RW_I2 0x28
  197. #define RW_I3 0x2c
  198. #define RW_I4 0x30
  199. #define RW_I5 0x34
  200. #define RW_I6 0x38
  201. #define RW_I7 0x3c
  202. /* Stack_frame offsets */
  203. #define SF_V9_L0 0x00
  204. #define SF_V9_L1 0x08
  205. #define SF_V9_L2 0x10
  206. #define SF_V9_L3 0x18
  207. #define SF_V9_L4 0x20
  208. #define SF_V9_L5 0x28
  209. #define SF_V9_L6 0x30
  210. #define SF_V9_L7 0x38
  211. #define SF_V9_I0 0x40
  212. #define SF_V9_I1 0x48
  213. #define SF_V9_I2 0x50
  214. #define SF_V9_I3 0x58
  215. #define SF_V9_I4 0x60
  216. #define SF_V9_I5 0x68
  217. #define SF_V9_FP 0x70
  218. #define SF_V9_PC 0x78
  219. #define SF_V9_RETP 0x80
  220. #define SF_V9_XARG0 0x88
  221. #define SF_V9_XARG1 0x90
  222. #define SF_V9_XARG2 0x98
  223. #define SF_V9_XARG3 0xa0
  224. #define SF_V9_XARG4 0xa8
  225. #define SF_V9_XARG5 0xb0
  226. #define SF_V9_XXARG 0xb8
  227. #define SF_L0 0x00
  228. #define SF_L1 0x04
  229. #define SF_L2 0x08
  230. #define SF_L3 0x0c
  231. #define SF_L4 0x10
  232. #define SF_L5 0x14
  233. #define SF_L6 0x18
  234. #define SF_L7 0x1c
  235. #define SF_I0 0x20
  236. #define SF_I1 0x24
  237. #define SF_I2 0x28
  238. #define SF_I3 0x2c
  239. #define SF_I4 0x30
  240. #define SF_I5 0x34
  241. #define SF_FP 0x38
  242. #define SF_PC 0x3c
  243. #define SF_RETP 0x40
  244. #define SF_XARG0 0x44
  245. #define SF_XARG1 0x48
  246. #define SF_XARG2 0x4c
  247. #define SF_XARG3 0x50
  248. #define SF_XARG4 0x54
  249. #define SF_XARG5 0x58
  250. #define SF_XXARG 0x5c
  251. /* Stuff for the ptrace system call */
  252. #define PTRACE_GETREGS 12
  253. #define PTRACE_SETREGS 13
  254. #define PTRACE_GETFPREGS 14
  255. #define PTRACE_SETFPREGS 15
  256. #define PTRACE_READDATA 16
  257. #define PTRACE_WRITEDATA 17
  258. #define PTRACE_READTEXT 18
  259. #define PTRACE_WRITETEXT 19
  260. #define PTRACE_GETFPAREGS 20
  261. #define PTRACE_SETFPAREGS 21
  262. /* There are for debugging 64-bit processes, either from a 32 or 64 bit
  263. * parent. Thus their complements are for debugging 32-bit processes only.
  264. */
  265. #define PTRACE_GETREGS64 22
  266. #define PTRACE_SETREGS64 23
  267. /* PTRACE_SYSCALL is 24 */
  268. #define PTRACE_GETFPREGS64 25
  269. #define PTRACE_SETFPREGS64 26
  270. #endif /* !(_SPARC64_PTRACE_H) */