libunwind-mips.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2008 CodeSourcery
  3. This file is part of libunwind.
  4. Permission is hereby granted, free of charge, to any person obtaining
  5. a copy of this software and associated documentation files (the
  6. "Software"), to deal in the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sublicense, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  20. #ifndef LIBUNWIND_H
  21. #define LIBUNWIND_H
  22. #if defined(__cplusplus) || defined(c_plusplus)
  23. extern "C" {
  24. #endif
  25. #include <inttypes.h>
  26. #include <ucontext.h>
  27. #ifdef mips
  28. # undef mips
  29. #endif
  30. #define UNW_TARGET mips
  31. #define UNW_TARGET_MIPS 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. /* FIXME for MIPS. Too big? What do other things use for similar tasks? */
  39. #define UNW_TDEP_CURSOR_LEN 4096
  40. /* The size of a "word" varies on MIPS. This type is used for memory
  41. addresses and register values. To allow a single library to support
  42. multiple ABIs, and to support N32 at all, we must use a 64-bit type
  43. even when addresses are only 32 bits. */
  44. typedef uint64_t unw_word_t;
  45. typedef int32_t unw_sword_t;
  46. /* FIXME: MIPS ABIs. */
  47. typedef long double unw_tdep_fpreg_t;
  48. typedef enum
  49. {
  50. UNW_MIPS_R0,
  51. UNW_MIPS_R1,
  52. UNW_MIPS_R2,
  53. UNW_MIPS_R3,
  54. UNW_MIPS_R4,
  55. UNW_MIPS_R5,
  56. UNW_MIPS_R6,
  57. UNW_MIPS_R7,
  58. UNW_MIPS_R8,
  59. UNW_MIPS_R9,
  60. UNW_MIPS_R10,
  61. UNW_MIPS_R11,
  62. UNW_MIPS_R12,
  63. UNW_MIPS_R13,
  64. UNW_MIPS_R14,
  65. UNW_MIPS_R15,
  66. UNW_MIPS_R16,
  67. UNW_MIPS_R17,
  68. UNW_MIPS_R18,
  69. UNW_MIPS_R19,
  70. UNW_MIPS_R20,
  71. UNW_MIPS_R21,
  72. UNW_MIPS_R22,
  73. UNW_MIPS_R23,
  74. UNW_MIPS_R24,
  75. UNW_MIPS_R25,
  76. UNW_MIPS_R26,
  77. UNW_MIPS_R27,
  78. UNW_MIPS_R28,
  79. UNW_MIPS_R29,
  80. UNW_MIPS_R30,
  81. UNW_MIPS_R31,
  82. /* FIXME: Other registers! */
  83. /* For MIPS, the CFA is the value of SP (r29) at the call site in the
  84. previous frame. */
  85. UNW_MIPS_CFA,
  86. UNW_TDEP_LAST_REG = UNW_MIPS_R31,
  87. UNW_TDEP_IP = UNW_MIPS_R31,
  88. UNW_TDEP_SP = UNW_MIPS_R29,
  89. UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */
  90. }
  91. mips_regnum_t;
  92. typedef enum
  93. {
  94. UNW_MIPS_ABI_O32,
  95. UNW_MIPS_ABI_N32,
  96. UNW_MIPS_ABI_N64
  97. }
  98. mips_abi_t;
  99. #define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */
  100. typedef struct unw_tdep_save_loc
  101. {
  102. /* Additional target-dependent info on a save location. */
  103. }
  104. unw_tdep_save_loc_t;
  105. /* On x86, we can directly use ucontext_t as the unwind context. FIXME for
  106. MIPS. */
  107. typedef ucontext_t unw_tdep_context_t;
  108. #include "libunwind-dynamic.h"
  109. typedef struct
  110. {
  111. /* no mips-specific auxiliary proc-info */
  112. }
  113. unw_tdep_proc_info_t;
  114. #include "libunwind-common.h"
  115. /* There is no getcontext() on MIPS. Use a stub version which only saves GP
  116. registers. FIXME: Not ideal, may not be sufficient for all libunwind
  117. use cases. */
  118. #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
  119. extern int unw_tdep_getcontext (ucontext_t *uc);
  120. #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
  121. extern int unw_tdep_is_fpreg (int);
  122. #if defined(__cplusplus) || defined(c_plusplus)
  123. }
  124. #endif
  125. #endif /* LIBUNWIND_H */