libunwind-x86.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2002-2004 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #ifndef LIBUNWIND_H
  22. #define LIBUNWIND_H
  23. #if defined(__cplusplus) || defined(c_plusplus)
  24. extern "C" {
  25. #endif
  26. #include <sys/types.h>
  27. #include <inttypes.h>
  28. #include <ucontext.h>
  29. #define UNW_TARGET x86
  30. #define UNW_TARGET_X86 1
  31. #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
  32. /* This needs to be big enough to accommodate "struct cursor", while
  33. leaving some slack for future expansion. Changing this value will
  34. require recompiling all users of this library. Stack allocation is
  35. relatively cheap and unwind-state copying is relatively rare, so we
  36. want to err on making it rather too big than too small. */
  37. #define UNW_TDEP_CURSOR_LEN 127
  38. typedef uint32_t unw_word_t;
  39. typedef int32_t unw_sword_t;
  40. typedef union {
  41. struct { uint8_t b[4]; } val32;
  42. struct { uint8_t b[10]; } val80;
  43. struct { uint8_t b[16]; } val128;
  44. } unw_tdep_fpreg_t;
  45. typedef enum
  46. {
  47. /* Note: general registers are expected to start with index 0.
  48. This convention facilitates architecture-independent
  49. implementation of the C++ exception handling ABI. See
  50. _Unwind_SetGR() and _Unwind_GetGR() for details.
  51. The described register usage convention is based on "System V
  52. Application Binary Interface, Intel386 Architecture Processor
  53. Supplement, Fourth Edition" at
  54. http://www.linuxbase.org/spec/refspecs/elf/abi386-4.pdf
  55. It would have been nice to use the same register numbering as
  56. DWARF, but that doesn't work because the libunwind requires
  57. that the exception argument registers be consecutive, which the
  58. wouldn't be with the DWARF numbering. */
  59. UNW_X86_EAX, /* scratch (exception argument 1) */
  60. UNW_X86_EDX, /* scratch (exception argument 2) */
  61. UNW_X86_ECX, /* scratch */
  62. UNW_X86_EBX, /* preserved */
  63. UNW_X86_ESI, /* preserved */
  64. UNW_X86_EDI, /* preserved */
  65. UNW_X86_EBP, /* (optional) frame-register */
  66. UNW_X86_ESP, /* (optional) frame-register */
  67. UNW_X86_EIP, /* frame-register */
  68. UNW_X86_EFLAGS, /* scratch (except for "direction", which is fixed */
  69. UNW_X86_TRAPNO, /* scratch */
  70. /* MMX/stacked-fp registers */
  71. UNW_X86_ST0, /* fp return value */
  72. UNW_X86_ST1, /* scratch */
  73. UNW_X86_ST2, /* scratch */
  74. UNW_X86_ST3, /* scratch */
  75. UNW_X86_ST4, /* scratch */
  76. UNW_X86_ST5, /* scratch */
  77. UNW_X86_ST6, /* scratch */
  78. UNW_X86_ST7, /* scratch */
  79. UNW_X86_FCW, /* scratch */
  80. UNW_X86_FSW, /* scratch */
  81. UNW_X86_FTW, /* scratch */
  82. UNW_X86_FOP, /* scratch */
  83. UNW_X86_FCS, /* scratch */
  84. UNW_X86_FIP, /* scratch */
  85. UNW_X86_FEA, /* scratch */
  86. UNW_X86_FDS, /* scratch */
  87. /* SSE registers */
  88. UNW_X86_XMM0_lo, /* scratch */
  89. UNW_X86_XMM0_hi, /* scratch */
  90. UNW_X86_XMM1_lo, /* scratch */
  91. UNW_X86_XMM1_hi, /* scratch */
  92. UNW_X86_XMM2_lo, /* scratch */
  93. UNW_X86_XMM2_hi, /* scratch */
  94. UNW_X86_XMM3_lo, /* scratch */
  95. UNW_X86_XMM3_hi, /* scratch */
  96. UNW_X86_XMM4_lo, /* scratch */
  97. UNW_X86_XMM4_hi, /* scratch */
  98. UNW_X86_XMM5_lo, /* scratch */
  99. UNW_X86_XMM5_hi, /* scratch */
  100. UNW_X86_XMM6_lo, /* scratch */
  101. UNW_X86_XMM6_hi, /* scratch */
  102. UNW_X86_XMM7_lo, /* scratch */
  103. UNW_X86_XMM7_hi, /* scratch */
  104. UNW_X86_MXCSR, /* scratch */
  105. /* segment registers */
  106. UNW_X86_GS, /* special */
  107. UNW_X86_FS, /* special */
  108. UNW_X86_ES, /* special */
  109. UNW_X86_DS, /* special */
  110. UNW_X86_SS, /* special */
  111. UNW_X86_CS, /* special */
  112. UNW_X86_TSS, /* special */
  113. UNW_X86_LDT, /* special */
  114. /* frame info (read-only) */
  115. UNW_X86_CFA,
  116. UNW_X86_XMM0, /* scratch */
  117. UNW_X86_XMM1, /* scratch */
  118. UNW_X86_XMM2, /* scratch */
  119. UNW_X86_XMM3, /* scratch */
  120. UNW_X86_XMM4, /* scratch */
  121. UNW_X86_XMM5, /* scratch */
  122. UNW_X86_XMM6, /* scratch */
  123. UNW_X86_XMM7, /* scratch */
  124. UNW_TDEP_LAST_REG = UNW_X86_XMM7,
  125. UNW_TDEP_IP = UNW_X86_EIP,
  126. UNW_TDEP_SP = UNW_X86_ESP,
  127. UNW_TDEP_EH = UNW_X86_EAX
  128. }
  129. x86_regnum_t;
  130. #define UNW_TDEP_NUM_EH_REGS 2 /* eax and edx are exception args */
  131. typedef struct unw_tdep_save_loc
  132. {
  133. /* Additional target-dependent info on a save location. */
  134. }
  135. unw_tdep_save_loc_t;
  136. /* On x86, we can directly use ucontext_t as the unwind context. */
  137. typedef ucontext_t unw_tdep_context_t;
  138. #include "libunwind-dynamic.h"
  139. typedef struct
  140. {
  141. /* no x86-specific auxiliary proc-info */
  142. }
  143. unw_tdep_proc_info_t;
  144. #include "libunwind-common.h"
  145. #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
  146. extern int unw_tdep_getcontext (unw_tdep_context_t *);
  147. #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
  148. extern int unw_tdep_is_fpreg (int);
  149. #if defined(__cplusplus) || defined(c_plusplus)
  150. }
  151. #endif
  152. #endif /* LIBUNWIND_H */