ptrace_64.h 8.3 KB

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