• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.  To allow a single library to support
55    multiple ABIs, and to support N32 at all, we must use a 64-bit type
56    even when addresses are only 32 bits.  */
57 typedef uint64_t unw_word_t;
58 typedef int32_t unw_sword_t;
59 
60 /* FIXME: MIPS ABIs.  */
61 typedef long double unw_tdep_fpreg_t;
62 
63 typedef enum
64   {
65     UNW_MIPS_R0,
66     UNW_MIPS_R1,
67     UNW_MIPS_R2,
68     UNW_MIPS_R3,
69     UNW_MIPS_R4,
70     UNW_MIPS_R5,
71     UNW_MIPS_R6,
72     UNW_MIPS_R7,
73     UNW_MIPS_R8,
74     UNW_MIPS_R9,
75     UNW_MIPS_R10,
76     UNW_MIPS_R11,
77     UNW_MIPS_R12,
78     UNW_MIPS_R13,
79     UNW_MIPS_R14,
80     UNW_MIPS_R15,
81     UNW_MIPS_R16,
82     UNW_MIPS_R17,
83     UNW_MIPS_R18,
84     UNW_MIPS_R19,
85     UNW_MIPS_R20,
86     UNW_MIPS_R21,
87     UNW_MIPS_R22,
88     UNW_MIPS_R23,
89     UNW_MIPS_R24,
90     UNW_MIPS_R25,
91     UNW_MIPS_R26,
92     UNW_MIPS_R27,
93     UNW_MIPS_R28,
94     UNW_MIPS_R29,
95     UNW_MIPS_R30,
96     UNW_MIPS_R31,
97 
98     UNW_MIPS_PC = 34,
99 
100     /* FIXME: Other registers!  */
101 
102     /* For MIPS, the CFA is the value of SP (r29) at the call site in the
103        previous frame.  */
104     UNW_MIPS_CFA,
105 
106     UNW_TDEP_LAST_REG = UNW_MIPS_R31,
107 
108     UNW_TDEP_IP = UNW_MIPS_R31,
109     UNW_TDEP_SP = UNW_MIPS_R29,
110     UNW_TDEP_EH = UNW_MIPS_R0   /* FIXME.  */
111   }
112 mips_regnum_t;
113 
114 typedef enum
115   {
116     UNW_MIPS_ABI_O32,
117     UNW_MIPS_ABI_N32,
118     UNW_MIPS_ABI_N64
119   }
120 mips_abi_t;
121 
122 #define UNW_TDEP_NUM_EH_REGS	2	/* FIXME for MIPS.  */
123 
124 typedef struct unw_tdep_save_loc
125   {
126     /* Additional target-dependent info on a save location.  */
127     /* ANDROID support update. */
128     char __reserved;
129     /* End of ANDROID update. */
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     /* ANDROID support update. */
143     char __reserved;
144     /* End of ANDROID update. */
145   }
146 unw_tdep_proc_info_t;
147 
148 #include "libunwind-common.h"
149 
150 /* There is no getcontext() on MIPS.  Use a stub version which only saves GP
151    registers.  FIXME: Not ideal, may not be sufficient for all libunwind
152    use cases.  */
153 #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
154 extern int unw_tdep_getcontext (ucontext_t *uc);
155 
156 #define unw_tdep_is_fpreg		UNW_ARCH_OBJ(is_fpreg)
157 extern int unw_tdep_is_fpreg (int);
158 
159 #if defined(__cplusplus) || defined(c_plusplus)
160 }
161 #endif
162 
163 #endif /* LIBUNWIND_H */
164