1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2003-2005 Hewlett-Packard Co
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of libunwind.
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
26 #ifndef HPPA_LIBUNWIND_I_H
27 #define HPPA_LIBUNWIND_I_H
29 /* Target-dependent definitions that are internal to libunwind but need
30 to be shared with target-independent code. */
33 #include <libunwind.h>
41 /* no hppa-specific fast trace */
47 struct unw_accessors acc
;
48 unw_caching_policy_t caching_policy
;
49 #ifdef HAVE_ATOMIC_OPS_H
50 AO_t cache_generation
;
52 uint32_t cache_generation
;
54 unw_word_t dyn_generation
; /* see dyn-common.h */
55 unw_word_t dyn_info_list_addr
; /* (cached) dyn_info_list_addr */
56 struct dwarf_rs_cache global_cache
;
57 struct unw_debug_frame_list
*debug_frames
;
62 struct dwarf_cursor dwarf
; /* must be first */
64 /* Format of sigcontext structure and address at which it is
68 HPPA_SCF_NONE
, /* no signal frame encountered */
69 HPPA_SCF_LINUX_RT_SIGFRAME
/* POSIX ucontext_t */
72 unw_word_t sigcontext_addr
;
75 #define DWARF_GET_LOC(l) ((l).val)
78 # define DWARF_NULL_LOC DWARF_LOC (0, 0)
79 # define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0)
80 # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) })
81 # define DWARF_IS_REG_LOC(l) 0
82 # define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \
83 tdep_uc_addr((c)->as_arg, (r)), 0))
84 # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
85 # define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \
86 tdep_uc_addr((c)->as_arg, (r)), 0))
89 dwarf_getfp (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_fpreg_t
*val
)
91 if (!DWARF_GET_LOC (loc
))
93 *val
= *(unw_fpreg_t
*) DWARF_GET_LOC (loc
);
98 dwarf_putfp (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_fpreg_t val
)
100 if (!DWARF_GET_LOC (loc
))
102 *(unw_fpreg_t
*) DWARF_GET_LOC (loc
) = val
;
107 dwarf_get (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_word_t
*val
)
109 if (!DWARF_GET_LOC (loc
))
111 *val
= *(unw_word_t
*) DWARF_GET_LOC (loc
);
116 dwarf_put (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_word_t val
)
118 if (!DWARF_GET_LOC (loc
))
120 *(unw_word_t
*) DWARF_GET_LOC (loc
) = val
;
124 #else /* !UNW_LOCAL_ONLY */
125 # define DWARF_LOC_TYPE_FP (1 << 0)
126 # define DWARF_LOC_TYPE_REG (1 << 1)
127 # define DWARF_NULL_LOC DWARF_LOC (0, 0)
128 # define DWARF_IS_NULL_LOC(l) \
129 ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; })
130 # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) })
131 # define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0)
132 # define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0)
133 # define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG)
134 # define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
135 # define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \
136 | DWARF_LOC_TYPE_FP))
139 dwarf_getfp (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_fpreg_t
*val
)
141 char *valp
= (char *) &val
;
145 if (DWARF_IS_NULL_LOC (loc
))
148 if (DWARF_IS_REG_LOC (loc
))
149 return (*c
->as
->acc
.access_fpreg
) (c
->as
, DWARF_GET_LOC (loc
),
152 addr
= DWARF_GET_LOC (loc
);
153 if ((ret
= (*c
->as
->acc
.access_mem
) (c
->as
, addr
+ 0, (unw_word_t
*) valp
,
157 return (*c
->as
->acc
.access_mem
) (c
->as
, addr
+ 4, (unw_word_t
*) valp
+ 1, 0,
162 dwarf_putfp (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_fpreg_t val
)
164 char *valp
= (char *) &val
;
168 if (DWARF_IS_NULL_LOC (loc
))
171 if (DWARF_IS_REG_LOC (loc
))
172 return (*c
->as
->acc
.access_fpreg
) (c
->as
, DWARF_GET_LOC (loc
),
175 addr
= DWARF_GET_LOC (loc
);
176 if ((ret
= (*c
->as
->acc
.access_mem
) (c
->as
, addr
+ 0, (unw_word_t
*) valp
,
180 return (*c
->as
->acc
.access_mem
) (c
->as
, addr
+ 4, (unw_word_t
*) valp
+ 1,
185 dwarf_get (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_word_t
*val
)
187 if (DWARF_IS_NULL_LOC (loc
))
190 /* If a code-generator were to save a value of type unw_word_t in a
191 floating-point register, we would have to support this case. I
192 suppose it could happen with MMX registers, but does it really
194 assert (!DWARF_IS_FP_LOC (loc
));
196 if (DWARF_IS_REG_LOC (loc
))
197 return (*c
->as
->acc
.access_reg
) (c
->as
, DWARF_GET_LOC (loc
), val
,
200 return (*c
->as
->acc
.access_mem
) (c
->as
, DWARF_GET_LOC (loc
), val
,
205 dwarf_put (struct dwarf_cursor
*c
, dwarf_loc_t loc
, unw_word_t val
)
207 if (DWARF_IS_NULL_LOC (loc
))
210 /* If a code-generator were to save a value of type unw_word_t in a
211 floating-point register, we would have to support this case. I
212 suppose it could happen with MMX registers, but does it really
214 assert (!DWARF_IS_FP_LOC (loc
));
216 if (DWARF_IS_REG_LOC (loc
))
217 return (*c
->as
->acc
.access_reg
) (c
->as
, DWARF_GET_LOC (loc
), &val
,
220 return (*c
->as
->acc
.access_mem
) (c
->as
, DWARF_GET_LOC (loc
), &val
,
224 #endif /* !UNW_LOCAL_ONLY */
226 #define tdep_getcontext_trace unw_getcontext
227 #define tdep_init_done UNW_OBJ(init_done)
228 #define tdep_init UNW_OBJ(init)
229 /* Platforms that support UNW_INFO_FORMAT_TABLE need to define
230 tdep_search_unwind_table. */
231 #define tdep_search_unwind_table dwarf_search_unwind_table
232 #define tdep_find_unwind_table dwarf_find_unwind_table
233 #define tdep_uc_addr UNW_ARCH_OBJ(uc_addr)
234 #define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image)
235 #define tdep_access_reg UNW_OBJ(access_reg)
236 #define tdep_access_fpreg UNW_OBJ(access_fpreg)
237 #define tdep_fetch_frame(c,ip,n) do {} while(0)
238 #define tdep_cache_frame(c,rs) do {} while(0)
239 #define tdep_reuse_frame(c,rs) do {} while(0)
240 #define tdep_stash_frame(c,rs) do {} while(0)
241 #define tdep_trace(cur,addr,n) (-UNW_ENOINFO)
243 #ifdef UNW_LOCAL_ONLY
244 # define tdep_find_proc_info(c,ip,n) \
245 dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \
247 # define tdep_put_unwind_info(as,pi,arg) \
248 dwarf_put_unwind_info((as), (pi), (arg))
250 # define tdep_find_proc_info(c,ip,n) \
251 (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \
253 # define tdep_put_unwind_info(as,pi,arg) \
254 (*(as)->acc.put_unwind_info)((as), (pi), (arg))
257 #define tdep_get_as(c) ((c)->dwarf.as)
258 #define tdep_get_as_arg(c) ((c)->dwarf.as_arg)
259 #define tdep_get_ip(c) ((c)->dwarf.ip)
260 #define tdep_big_endian(as) 1
262 extern int tdep_init_done
;
264 extern void tdep_init (void);
265 extern int tdep_search_unwind_table (unw_addr_space_t as
, unw_word_t ip
,
266 unw_dyn_info_t
*di
, unw_proc_info_t
*pi
,
267 int need_unwind_info
, void *arg
);
268 extern void *tdep_uc_addr (ucontext_t
*uc
, int reg
);
269 extern int tdep_get_elf_image (struct elf_image
*ei
, pid_t pid
, unw_word_t ip
,
270 unsigned long *segbase
, unsigned long *mapoff
,
271 char *path
, size_t pathlen
);
272 extern int tdep_access_reg (struct cursor
*c
, unw_regnum_t reg
,
273 unw_word_t
*valp
, int write
);
274 extern int tdep_access_fpreg (struct cursor
*c
, unw_regnum_t reg
,
275 unw_fpreg_t
*valp
, int write
);
277 #endif /* HPPA_LIBUNWIND_I_H */