ptrace.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
  9. */
  10. #ifndef __ASM_ARC_PTRACE_H
  11. #define __ASM_ARC_PTRACE_H
  12. #ifdef __KERNEL__
  13. #ifndef __ASSEMBLY__
  14. /* THE pt_regs: Defines how regs are saved during entry into kernel */
  15. struct pt_regs {
  16. /*
  17. * 1 word gutter after reg-file has been saved
  18. * Technically not needed, Since SP always points to a "full" location
  19. * (vs. "empty"). But pt_regs is shared with tools....
  20. */
  21. long res;
  22. /* Real registers */
  23. long bta; /* bta_l1, bta_l2, erbta */
  24. long lp_start;
  25. long lp_end;
  26. long lp_count;
  27. long status32; /* status32_l1, status32_l2, erstatus */
  28. long ret; /* ilink1, ilink2 or eret */
  29. long blink;
  30. long fp;
  31. long r26; /* gp */
  32. long r12;
  33. long r11;
  34. long r10;
  35. long r9;
  36. long r8;
  37. long r7;
  38. long r6;
  39. long r5;
  40. long r4;
  41. long r3;
  42. long r2;
  43. long r1;
  44. long r0;
  45. long sp; /* user/kernel sp depending on where we came from */
  46. long orig_r0;
  47. long orig_r8; /*to distinguish bet excp, sys call, int1 or int2 */
  48. };
  49. /* Callee saved registers - need to be saved only when you are scheduled out */
  50. struct callee_regs {
  51. long res; /* Again this is not needed */
  52. long r25;
  53. long r24;
  54. long r23;
  55. long r22;
  56. long r21;
  57. long r20;
  58. long r19;
  59. long r18;
  60. long r17;
  61. long r16;
  62. long r15;
  63. long r14;
  64. long r13;
  65. };
  66. #define instruction_pointer(regs) ((regs)->ret)
  67. #define profile_pc(regs) instruction_pointer(regs)
  68. /* return 1 if user mode or 0 if kernel mode */
  69. #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
  70. #define user_stack_pointer(regs)\
  71. ({ unsigned int sp; \
  72. if (user_mode(regs)) \
  73. sp = (regs)->sp;\
  74. else \
  75. sp = -1; \
  76. sp; \
  77. })
  78. /* return 1 if in syscall, 0 if Intr or Exception */
  79. #define in_syscall(regs) (((regs->orig_r8) >= 0 && \
  80. (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
  81. #define current_pt_regs() \
  82. ({ \
  83. /* open-coded current_thread_info() */ \
  84. register unsigned long sp asm ("sp"); \
  85. unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
  86. (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \
  87. })
  88. #endif /* !__ASSEMBLY__ */
  89. #endif /* __KERNEL__ */
  90. #ifndef __ASSEMBLY__
  91. /*
  92. * Userspace ABI: Register state needed by
  93. * -ptrace (gdbserver)
  94. * -sigcontext (SA_SIGNINFO signal frame)
  95. *
  96. * This is to decouple pt_regs from user-space ABI, to be able to change it
  97. * w/o affecting the ABI.
  98. * Although the layout (initial padding) is similar to pt_regs to have some
  99. * optimizations when copying pt_regs to/from user_regs_struct.
  100. *
  101. * Also, sigcontext only care about the scratch regs as that is what we really
  102. * save/restore for signal handling.
  103. */
  104. struct user_regs_struct {
  105. struct scratch {
  106. long pad;
  107. long bta, lp_start, lp_end, lp_count;
  108. long status32, ret, blink, fp, gp;
  109. long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
  110. long sp;
  111. } scratch;
  112. struct callee {
  113. long pad;
  114. long r25, r24, r23, r22, r21, r20;
  115. long r19, r18, r17, r16, r15, r14, r13;
  116. } callee;
  117. long efa; /* break pt addr, for break points in delay slots */
  118. long stop_pc; /* give dbg stop_pc directly after checking orig_r8 */
  119. };
  120. #endif /* !__ASSEMBLY__ */
  121. #endif /* __ASM_PTRACE_H */