1 /* libunwind - a platform-independent unwind library 2 Copyright (C) 2008 CodeSourcery 3 4 This file is part of libunwind. 5 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 14 The above copyright notice and this permission notice shall be 15 included in all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 24 25 #ifndef LIBUNWIND_H 26 #define LIBUNWIND_H 27 28 #if defined(__cplusplus) || defined(c_plusplus) 29 extern "C" { 30 #endif 31 32 #include <inttypes.h> 33 #include <ucontext.h> 34 35 #ifdef mips 36 # undef mips 37 #endif 38 39 #define UNW_TARGET mips 40 #define UNW_TARGET_MIPS 1 41 42 #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ 43 44 /* This needs to be big enough to accommodate "struct cursor", while 45 leaving some slack for future expansion. Changing this value will 46 require recompiling all users of this library. Stack allocation is 47 relatively cheap and unwind-state copying is relatively rare, so we 48 want to err on making it rather too big than too small. */ 49 50 /* FIXME for MIPS. Too big? What do other things use for similar tasks? */ 51 #define UNW_TDEP_CURSOR_LEN 4096 52 53 /* The size of a "word" varies on MIPS. This type is used for memory 54 addresses and register values, which are 32-bit wide for O32 and N32 55 ABIs, and 64-bit wide for N64 ABI. */ 56 #if _MIPS_SIM == _ABI64 57 typedef uint64_t unw_word_t; 58 #else 59 typedef uint32_t unw_word_t; 60 #endif 61 typedef int32_t unw_sword_t; 62 63 /* FIXME: MIPS ABIs. */ 64 typedef long double unw_tdep_fpreg_t; 65 66 typedef enum 67 { 68 UNW_MIPS_R0, 69 UNW_MIPS_R1, 70 UNW_MIPS_R2, 71 UNW_MIPS_R3, 72 UNW_MIPS_R4, 73 UNW_MIPS_R5, 74 UNW_MIPS_R6, 75 UNW_MIPS_R7, 76 UNW_MIPS_R8, 77 UNW_MIPS_R9, 78 UNW_MIPS_R10, 79 UNW_MIPS_R11, 80 UNW_MIPS_R12, 81 UNW_MIPS_R13, 82 UNW_MIPS_R14, 83 UNW_MIPS_R15, 84 UNW_MIPS_R16, 85 UNW_MIPS_R17, 86 UNW_MIPS_R18, 87 UNW_MIPS_R19, 88 UNW_MIPS_R20, 89 UNW_MIPS_R21, 90 UNW_MIPS_R22, 91 UNW_MIPS_R23, 92 UNW_MIPS_R24, 93 UNW_MIPS_R25, 94 UNW_MIPS_R26, 95 UNW_MIPS_R27, 96 UNW_MIPS_R28, 97 UNW_MIPS_R29, 98 UNW_MIPS_R30, 99 UNW_MIPS_R31, 100 101 UNW_MIPS_PC = 64, 102 103 /* FIXME: Other registers! */ 104 105 /* For MIPS, the CFA is the value of SP (r29) at the call site in the 106 previous frame. */ 107 UNW_MIPS_CFA, 108 109 UNW_TDEP_LAST_REG = UNW_MIPS_PC, 110 111 UNW_TDEP_IP = UNW_MIPS_R31, 112 UNW_TDEP_SP = UNW_MIPS_R29, 113 UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */ 114 } 115 mips_regnum_t; 116 117 typedef enum 118 { 119 UNW_MIPS_ABI_O32, 120 UNW_MIPS_ABI_N32, 121 UNW_MIPS_ABI_N64 122 } 123 mips_abi_t; 124 125 #define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */ 126 127 typedef struct unw_tdep_save_loc 128 { 129 /* Additional target-dependent info on a save location. */ 130 } 131 unw_tdep_save_loc_t; 132 133 /* On x86, we can directly use ucontext_t as the unwind context. FIXME for 134 MIPS. */ 135 typedef ucontext_t unw_tdep_context_t; 136 137 #include "libunwind-dynamic.h" 138 139 typedef struct 140 { 141 /* no mips-specific auxiliary proc-info */ 142 } 143 unw_tdep_proc_info_t; 144 145 #include "libunwind-common.h" 146 147 /* There is no getcontext() on MIPS. Use a stub version which only saves GP 148 registers. FIXME: Not ideal, may not be sufficient for all libunwind 149 use cases. */ 150 #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) 151 extern int unw_tdep_getcontext (ucontext_t *uc); 152 153 #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) 154 extern int unw_tdep_is_fpreg (int); 155 156 #if defined(__cplusplus) || defined(c_plusplus) 157 } 158 #endif 159 160 #endif /* LIBUNWIND_H */ 161