libunwind-x86_64.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
  5. This file is part of libunwind.
  6. Permission is hereby granted, free of charge, to any person obtaining
  7. a copy of this software and associated documentation files (the
  8. "Software"), to deal in the Software without restriction, including
  9. without limitation the rights to use, copy, modify, merge, publish,
  10. distribute, sublicense, and/or sell copies of the Software, and to
  11. permit persons to whom the Software is furnished to do so, subject to
  12. the following conditions:
  13. The above copyright notice and this permission notice shall be
  14. included in all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  22. #ifndef LIBUNWIND_H
  23. #define LIBUNWIND_H
  24. #if defined(__cplusplus) || defined(c_plusplus)
  25. extern "C" {
  26. #endif
  27. #include <sys/types.h>
  28. #include <inttypes.h>
  29. #include <ucontext.h>
  30. #define UNW_TARGET x86_64
  31. #define UNW_TARGET_X86_64 1
  32. #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
  33. /* This needs to be big enough to accommodate "struct cursor", while
  34. leaving some slack for future expansion. Changing this value will
  35. require recompiling all users of this library. Stack allocation is
  36. relatively cheap and unwind-state copying is relatively rare, so we
  37. want to err on making it rather too big than too small. */
  38. #define UNW_TDEP_CURSOR_LEN 127
  39. typedef uint64_t unw_word_t;
  40. typedef int64_t unw_sword_t;
  41. typedef long double unw_tdep_fpreg_t;
  42. typedef enum
  43. {
  44. UNW_X86_64_RAX,
  45. UNW_X86_64_RDX,
  46. UNW_X86_64_RCX,
  47. UNW_X86_64_RBX,
  48. UNW_X86_64_RSI,
  49. UNW_X86_64_RDI,
  50. UNW_X86_64_RBP,
  51. UNW_X86_64_RSP,
  52. UNW_X86_64_R8,
  53. UNW_X86_64_R9,
  54. UNW_X86_64_R10,
  55. UNW_X86_64_R11,
  56. UNW_X86_64_R12,
  57. UNW_X86_64_R13,
  58. UNW_X86_64_R14,
  59. UNW_X86_64_R15,
  60. UNW_X86_64_RIP,
  61. #ifdef CONFIG_MSABI_SUPPORT
  62. UNW_X86_64_XMM0,
  63. UNW_X86_64_XMM1,
  64. UNW_X86_64_XMM2,
  65. UNW_X86_64_XMM3,
  66. UNW_X86_64_XMM4,
  67. UNW_X86_64_XMM5,
  68. UNW_X86_64_XMM6,
  69. UNW_X86_64_XMM7,
  70. UNW_X86_64_XMM8,
  71. UNW_X86_64_XMM9,
  72. UNW_X86_64_XMM10,
  73. UNW_X86_64_XMM11,
  74. UNW_X86_64_XMM12,
  75. UNW_X86_64_XMM13,
  76. UNW_X86_64_XMM14,
  77. UNW_X86_64_XMM15,
  78. UNW_TDEP_LAST_REG = UNW_X86_64_XMM15,
  79. #else
  80. UNW_TDEP_LAST_REG = UNW_X86_64_RIP,
  81. #endif
  82. /* XXX Add other regs here */
  83. /* frame info (read-only) */
  84. UNW_X86_64_CFA,
  85. UNW_TDEP_IP = UNW_X86_64_RIP,
  86. UNW_TDEP_SP = UNW_X86_64_RSP,
  87. UNW_TDEP_BP = UNW_X86_64_RBP,
  88. UNW_TDEP_EH = UNW_X86_64_RAX
  89. }
  90. x86_64_regnum_t;
  91. #define UNW_TDEP_NUM_EH_REGS 2 /* XXX Not sure what this means */
  92. typedef struct unw_tdep_save_loc
  93. {
  94. /* Additional target-dependent info on a save location. */
  95. }
  96. unw_tdep_save_loc_t;
  97. /* On x86_64, we can directly use ucontext_t as the unwind context. */
  98. typedef ucontext_t unw_tdep_context_t;
  99. typedef struct
  100. {
  101. /* no x86-64-specific auxiliary proc-info */
  102. }
  103. unw_tdep_proc_info_t;
  104. #include "libunwind-dynamic.h"
  105. #include "libunwind-common.h"
  106. #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
  107. #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
  108. extern int unw_tdep_getcontext (unw_tdep_context_t *);
  109. extern int unw_tdep_is_fpreg (int);
  110. #if defined(__cplusplus) || defined(c_plusplus)
  111. }
  112. #endif
  113. #endif /* LIBUNWIND_H */