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