| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2001-2005 Hewlett-Packard Co |
| David Mosberger-Tang | e6b9f35 | 2007-08-22 13:02:09 -0600 | [diff] [blame] | 3 | Copyright (C) 2007 David Mosberger-Tang |
| 4 | Contributed by David Mosberger-Tang <dmosberger@gmail.com> |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 5 | |
| 6 | This file is part of libunwind. |
| 7 | |
| 8 | Permission is hereby granted, free of charge, to any person obtaining |
| 9 | a copy of this software and associated documentation files (the |
| 10 | "Software"), to deal in the Software without restriction, including |
| 11 | without limitation the rights to use, copy, modify, merge, publish, |
| 12 | distribute, sublicense, and/or sell copies of the Software, and to |
| 13 | permit persons to whom the Software is furnished to do so, subject to |
| 14 | the following conditions: |
| 15 | |
| 16 | The above copyright notice and this permission notice shall be |
| 17 | included in all copies or substantial portions of the Software. |
| 18 | |
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 26 | |
| 27 | /* This files contains libunwind-internal definitions which are |
| 28 | subject to frequent change and are not to be exposed to |
| 29 | libunwind-users. */ |
| 30 | |
| 31 | #ifndef libunwind_i_h |
| 32 | #define libunwind_i_h |
| 33 | |
| 34 | #ifdef HAVE_CONFIG_H |
| 35 | # include "config.h" |
| 36 | #endif |
| 37 | |
| Tommi Rantala | dc680c0 | 2012-09-19 12:12:16 +0300 | [diff] [blame] | 38 | #include "compiler.h" |
| 39 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 40 | #ifdef HAVE___THREAD |
| 41 | /* For now, turn off per-thread caching. It uses up too much TLS |
| 42 | memory per thread even when the thread never uses libunwind at |
| 43 | all. */ |
| 44 | # undef HAVE___THREAD |
| 45 | #endif |
| 46 | |
| 47 | /* Platform-independent libunwind-internal declarations. */ |
| 48 | |
| 49 | #include <sys/types.h> /* HP-UX needs this before include of pthread.h */ |
| 50 | |
| 51 | #include <assert.h> |
| 52 | #include <libunwind.h> |
| 53 | #include <pthread.h> |
| 54 | #include <signal.h> |
| 55 | #include <stdlib.h> |
| 56 | #include <string.h> |
| 57 | #include <unistd.h> |
| Ken Werner | 2c865b6 | 2011-10-20 16:51:45 +0000 | [diff] [blame] | 58 | #include <sys/mman.h> |
| Matt Fischer | eac65dc | 2013-04-15 09:53:29 -0500 | [diff] [blame] | 59 | |
| 60 | #if defined(HAVE_ELF_H) |
| 61 | # include <elf.h> |
| 62 | #elif defined(HAVE_SYS_ELF_H) |
| 63 | # include <sys/elf.h> |
| 64 | #else |
| 65 | # error Could not locate <elf.h> |
| 66 | #endif |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 67 | |
| Konstantin Belousov | 905034c | 2010-03-06 00:41:37 +0200 | [diff] [blame] | 68 | #if defined(HAVE_ENDIAN_H) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 69 | # include <endian.h> |
| Konstantin Belousov | 905034c | 2010-03-06 00:41:37 +0200 | [diff] [blame] | 70 | #elif defined(HAVE_SYS_ENDIAN_H) |
| 71 | # include <sys/endian.h> |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 72 | #else |
| 73 | # define __LITTLE_ENDIAN 1234 |
| 74 | # define __BIG_ENDIAN 4321 |
| 75 | # if defined(__hpux) |
| 76 | # define __BYTE_ORDER __BIG_ENDIAN |
| Matt Fischer | eac65dc | 2013-04-15 09:53:29 -0500 | [diff] [blame] | 77 | # elif defined(__QNX__) |
| 78 | # if defined(__BIGENDIAN__) |
| 79 | # define __BYTE_ORDER __BIG_ENDIAN |
| 80 | # elif defined(__LITTLEENDIAN__) |
| 81 | # define __BYTE_ORDER __LITTLE_ENDIAN |
| 82 | # else |
| 83 | # error Host has unknown byte-order. |
| 84 | # endif |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 85 | # else |
| 86 | # error Host has unknown byte-order. |
| 87 | # endif |
| 88 | #endif |
| 89 | |
| Ladislav Michl | 10b064f | 2012-11-13 11:19:47 +0100 | [diff] [blame] | 90 | #if defined(HAVE__BUILTIN_UNREACHABLE) |
| 91 | # define unreachable() __builtin_unreachable() |
| 92 | #else |
| 93 | # define unreachable() do { } while (1) |
| 94 | #endif |
| 95 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 96 | #ifdef DEBUG |
| 97 | # define UNW_DEBUG 1 |
| 98 | #else |
| 99 | # define UNW_DEBUG 0 |
| 100 | #endif |
| 101 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 102 | /* Make it easy to write thread-safe code which may or may not be |
| 103 | linked against libpthread. The macros below can be used |
| 104 | unconditionally and if -lpthread is around, they'll call the |
| 105 | corresponding routines otherwise, they do nothing. */ |
| 106 | |
| 107 | #pragma weak pthread_mutex_init |
| 108 | #pragma weak pthread_mutex_lock |
| 109 | #pragma weak pthread_mutex_unlock |
| 110 | |
| 111 | #define mutex_init(l) \ |
| Tommi Rantala | 890e23e | 2012-09-21 08:38:52 +0300 | [diff] [blame] | 112 | (pthread_mutex_init != NULL ? pthread_mutex_init ((l), NULL) : 0) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 113 | #define mutex_lock(l) \ |
| Tommi Rantala | 890e23e | 2012-09-21 08:38:52 +0300 | [diff] [blame] | 114 | (pthread_mutex_lock != NULL ? pthread_mutex_lock (l) : 0) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 115 | #define mutex_unlock(l) \ |
| Tommi Rantala | 890e23e | 2012-09-21 08:38:52 +0300 | [diff] [blame] | 116 | (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 117 | |
| 118 | #ifdef HAVE_ATOMIC_OPS_H |
| 119 | # include <atomic_ops.h> |
| 120 | static inline int |
| 121 | cmpxchg_ptr (void *addr, void *old, void *new) |
| 122 | { |
| 123 | union |
| 124 | { |
| 125 | void *vp; |
| 126 | AO_t *aop; |
| 127 | } |
| 128 | u; |
| 129 | |
| 130 | u.vp = addr; |
| 131 | return AO_compare_and_swap(u.aop, (AO_t) old, (AO_t) new); |
| 132 | } |
| 133 | # define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr) |
| Tommi Rantala | 9a3565d | 2012-09-19 14:00:20 +0300 | [diff] [blame] | 134 | # define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 135 | /* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */ |
| 136 | # if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2) |
| 137 | # define HAVE_CMPXCHG |
| 138 | # endif |
| Tommi Rantala | 9a3565d | 2012-09-19 14:00:20 +0300 | [diff] [blame] | 139 | # define HAVE_FETCH_AND_ADD |
| Tommi Rantala | c2d6f85 | 2012-09-06 15:42:35 +0300 | [diff] [blame] | 140 | #elif defined(HAVE_SYNC_ATOMICS) || defined(HAVE_IA64INTRIN_H) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 141 | # ifdef HAVE_IA64INTRIN_H |
| 142 | # include <ia64intrin.h> |
| Tommi Rantala | c2d6f85 | 2012-09-06 15:42:35 +0300 | [diff] [blame] | 143 | # endif |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 144 | static inline int |
| 145 | cmpxchg_ptr (void *addr, void *old, void *new) |
| 146 | { |
| 147 | union |
| 148 | { |
| 149 | void *vp; |
| 150 | long *vlp; |
| 151 | } |
| 152 | u; |
| 153 | |
| 154 | u.vp = addr; |
| 155 | return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); |
| 156 | } |
| Tommi Rantala | c2d6f85 | 2012-09-06 15:42:35 +0300 | [diff] [blame] | 157 | # define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) |
| 158 | # define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) |
| 159 | # define HAVE_CMPXCHG |
| 160 | # define HAVE_FETCH_AND_ADD |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 161 | #endif |
| 162 | #define atomic_read(ptr) (*(ptr)) |
| 163 | |
| 164 | #define UNWI_OBJ(fn) UNW_PASTE(UNW_PREFIX,UNW_PASTE(I,fn)) |
| 165 | #define UNWI_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_UI,UNW_TARGET),_), fn) |
| 166 | |
| 167 | #define unwi_full_mask UNWI_ARCH_OBJ(full_mask) |
| 168 | |
| 169 | /* Type of a mask that can be used to inhibit preemption. At the |
| 170 | userlevel, preemption is caused by signals and hence sigset_t is |
| 171 | appropriate. In constrast, the Linux kernel uses "unsigned long" |
| 172 | to hold the processor "flags" instead. */ |
| 173 | typedef sigset_t intrmask_t; |
| 174 | |
| 175 | extern intrmask_t unwi_full_mask; |
| 176 | |
| Arun Sharma | 491d576 | 2009-10-16 14:01:50 -0700 | [diff] [blame] | 177 | /* Silence compiler warnings about variables which are used only if libunwind |
| 178 | is configured in a certain way */ |
| Tommi Rantala | a15874f | 2012-02-14 15:37:55 +0200 | [diff] [blame] | 179 | static inline void mark_as_used(void *v UNUSED) { |
| Arun Sharma | 491d576 | 2009-10-16 14:01:50 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| Paul Pluzhnikov | 9aa0d6d | 2009-09-21 13:04:33 -0700 | [diff] [blame] | 182 | #if defined(CONFIG_BLOCK_SIGNALS) |
| Arun Sharma | af9daf6 | 2009-10-15 19:29:49 -0700 | [diff] [blame] | 183 | # define SIGPROCMASK(how, new_mask, old_mask) \ |
| 184 | sigprocmask((how), (new_mask), (old_mask)) |
| Paul Pluzhnikov | 9aa0d6d | 2009-09-21 13:04:33 -0700 | [diff] [blame] | 185 | #else |
| Arun Sharma | 4ab26bc | 2009-10-16 15:52:44 -0700 | [diff] [blame] | 186 | # define SIGPROCMASK(how, new_mask, old_mask) mark_as_used(old_mask) |
| Paul Pluzhnikov | 9aa0d6d | 2009-09-21 13:04:33 -0700 | [diff] [blame] | 187 | #endif |
| 188 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 189 | #define define_lock(name) \ |
| 190 | pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER |
| 191 | #define lock_init(l) mutex_init (l) |
| 192 | #define lock_acquire(l,m) \ |
| 193 | do { \ |
| Paul Pluzhnikov | 9aa0d6d | 2009-09-21 13:04:33 -0700 | [diff] [blame] | 194 | SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &(m)); \ |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 195 | mutex_lock (l); \ |
| 196 | } while (0) |
| 197 | #define lock_release(l,m) \ |
| 198 | do { \ |
| 199 | mutex_unlock (l); \ |
| Paul Pluzhnikov | 9aa0d6d | 2009-09-21 13:04:33 -0700 | [diff] [blame] | 200 | SIGPROCMASK (SIG_SETMASK, &(m), NULL); \ |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 201 | } while (0) |
| 202 | |
| 203 | #define SOS_MEMORY_SIZE 16384 /* see src/mi/mempool.c */ |
| 204 | |
| Konstantin Belousov | 8ccebc9 | 2010-03-06 16:23:24 +0200 | [diff] [blame] | 205 | #ifndef MAP_ANONYMOUS |
| 206 | # define MAP_ANONYMOUS MAP_ANON |
| 207 | #endif |
| Arun Sharma | c0a9d0c | 2011-01-23 18:06:51 -0800 | [diff] [blame] | 208 | #define GET_MEMORY(mem, size) \ |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 209 | do { \ |
| 210 | /* Hopefully, mmap() goes straight through to a system call stub... */ \ |
| Tommi Rantala | 890e23e | 2012-09-21 08:38:52 +0300 | [diff] [blame] | 211 | mem = mmap (NULL, size, PROT_READ | PROT_WRITE, \ |
| 212 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 213 | if (mem == MAP_FAILED) \ |
| 214 | mem = NULL; \ |
| 215 | } while (0) |
| 216 | |
| 217 | #define unwi_find_dynamic_proc_info UNWI_OBJ(find_dynamic_proc_info) |
| 218 | #define unwi_extract_dynamic_proc_info UNWI_OBJ(extract_dynamic_proc_info) |
| 219 | #define unwi_put_dynamic_unwind_info UNWI_OBJ(put_dynamic_unwind_info) |
| 220 | #define unwi_dyn_remote_find_proc_info UNWI_OBJ(dyn_remote_find_proc_info) |
| 221 | #define unwi_dyn_remote_put_unwind_info UNWI_OBJ(dyn_remote_put_unwind_info) |
| 222 | #define unwi_dyn_validate_cache UNWI_OBJ(dyn_validate_cache) |
| 223 | |
| 224 | extern int unwi_find_dynamic_proc_info (unw_addr_space_t as, |
| 225 | unw_word_t ip, |
| 226 | unw_proc_info_t *pi, |
| 227 | int need_unwind_info, void *arg); |
| 228 | extern int unwi_extract_dynamic_proc_info (unw_addr_space_t as, |
| 229 | unw_word_t ip, |
| 230 | unw_proc_info_t *pi, |
| 231 | unw_dyn_info_t *di, |
| 232 | int need_unwind_info, |
| 233 | void *arg); |
| 234 | extern void unwi_put_dynamic_unwind_info (unw_addr_space_t as, |
| 235 | unw_proc_info_t *pi, void *arg); |
| 236 | |
| 237 | /* These handle the remote (cross-address-space) case of accessing |
| 238 | dynamic unwind info. */ |
| 239 | |
| 240 | extern int unwi_dyn_remote_find_proc_info (unw_addr_space_t as, |
| 241 | unw_word_t ip, |
| 242 | unw_proc_info_t *pi, |
| 243 | int need_unwind_info, |
| 244 | void *arg); |
| 245 | extern void unwi_dyn_remote_put_unwind_info (unw_addr_space_t as, |
| 246 | unw_proc_info_t *pi, |
| 247 | void *arg); |
| 248 | extern int unwi_dyn_validate_cache (unw_addr_space_t as, void *arg); |
| 249 | |
| 250 | extern unw_dyn_info_list_t _U_dyn_info_list; |
| 251 | extern pthread_mutex_t _U_dyn_info_list_lock; |
| 252 | |
| 253 | #if UNW_DEBUG |
| Christopher Ferris | 76dbee5 | 2014-02-12 21:12:09 -0800 | [diff] [blame^] | 254 | # define unwi_debug_level UNWI_ARCH_OBJ(debug_level) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 255 | extern long unwi_debug_level; |
| 256 | |
| Christopher Ferris | 76dbee5 | 2014-02-12 21:12:09 -0800 | [diff] [blame^] | 257 | # ifdef ANDROID |
| 258 | # include <log/log.h> |
| 259 | # define LOG_TAG "libunwind" |
| 260 | |
| 261 | # define Debug(level, format, ...) \ |
| 262 | do { \ |
| 263 | if (unwi_debug_level >= (level)) \ |
| 264 | { \ |
| 265 | ALOGI("%*c>%s: " format, ((level) <= 16) ? (level) : 16, ' ', \ |
| 266 | __FUNCTION__, ##__VA_ARGS__); \ |
| 267 | } \ |
| 268 | } while (0) |
| 269 | # define Dprintf(format, ...) ALOGI(format, ##__VA_ARGS__); |
| 270 | #else |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 271 | # include <stdio.h> |
| 272 | # define Debug(level,format...) \ |
| 273 | do { \ |
| 274 | if (unwi_debug_level >= level) \ |
| 275 | { \ |
| 276 | int _n = level; \ |
| 277 | if (_n > 16) \ |
| 278 | _n = 16; \ |
| 279 | fprintf (stderr, "%*c>%s: ", _n, ' ', __FUNCTION__); \ |
| 280 | fprintf (stderr, format); \ |
| 281 | } \ |
| 282 | } while (0) |
| Arun Sharma | ec53de8 | 2009-03-16 18:42:27 +0000 | [diff] [blame] | 283 | # define Dprintf(format...) fprintf (stderr, format) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 284 | # ifdef __GNUC__ |
| 285 | # undef inline |
| 286 | # define inline UNUSED |
| 287 | # endif |
| Christopher Ferris | 76dbee5 | 2014-02-12 21:12:09 -0800 | [diff] [blame^] | 288 | # endif |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 289 | #else |
| 290 | # define Debug(level,format...) |
| Arun Sharma | ec53de8 | 2009-03-16 18:42:27 +0000 | [diff] [blame] | 291 | # define Dprintf(format...) |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 292 | #endif |
| 293 | |
| Arun Sharma | 491d576 | 2009-10-16 14:01:50 -0700 | [diff] [blame] | 294 | static ALWAYS_INLINE int |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 295 | print_error (const char *string) |
| 296 | { |
| Arun Sharma | 491d576 | 2009-10-16 14:01:50 -0700 | [diff] [blame] | 297 | return write (2, string, strlen (string)); |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | #define mi_init UNWI_ARCH_OBJ(mi_init) |
| 301 | |
| 302 | extern void mi_init (void); /* machine-independent initializations */ |
| 303 | extern unw_word_t _U_dyn_info_list_addr (void); |
| 304 | |
| 305 | /* This is needed/used by ELF targets only. */ |
| 306 | |
| 307 | struct elf_image |
| 308 | { |
| 309 | void *image; /* pointer to mmap'd image */ |
| 310 | size_t size; /* (file-) size of the image */ |
| 311 | }; |
| 312 | |
| Arun Sharma | 25ee9f8 | 2012-03-12 18:45:08 -0700 | [diff] [blame] | 313 | struct elf_dyn_info |
| 314 | { |
| Christopher Ferris | 16b95a6 | 2014-01-22 16:07:26 -0800 | [diff] [blame] | 315 | /* ANDROID support update.*/ |
| 316 | /* Removed: struct elf_image ei; */ |
| 317 | /* End of ANDROID update. */ |
| Arun Sharma | 25ee9f8 | 2012-03-12 18:45:08 -0700 | [diff] [blame] | 318 | unw_dyn_info_t di_cache; |
| 319 | unw_dyn_info_t di_debug; /* additional table info for .debug_frame */ |
| 320 | #if UNW_TARGET_IA64 |
| 321 | unw_dyn_info_t ktab; |
| 322 | #endif |
| 323 | #if UNW_TARGET_ARM |
| 324 | unw_dyn_info_t di_arm; /* additional table info for .ARM.exidx */ |
| 325 | #endif |
| 326 | }; |
| 327 | |
| Tommi Rantala | 18c26d4 | 2012-08-12 21:24:35 +0300 | [diff] [blame] | 328 | static inline void invalidate_edi (struct elf_dyn_info *edi) |
| Arun Sharma | 25ee9f8 | 2012-03-12 18:45:08 -0700 | [diff] [blame] | 329 | { |
| Christopher Ferris | 16b95a6 | 2014-01-22 16:07:26 -0800 | [diff] [blame] | 330 | /* ANDROID support update.*/ |
| 331 | /* Removed: if (edi->ei.image) */ |
| 332 | /* munmap (edi->ei.image, edi->ei.size); */ |
| 333 | /* End of ANDROID update. */ |
| Arun Sharma | 25ee9f8 | 2012-03-12 18:45:08 -0700 | [diff] [blame] | 334 | memset (edi, 0, sizeof (*edi)); |
| 335 | edi->di_cache.format = -1; |
| 336 | edi->di_debug.format = -1; |
| 337 | #if UNW_TARGET_ARM |
| 338 | edi->di_arm.format = -1; |
| 339 | #endif |
| 340 | } |
| 341 | |
| 342 | |
| Lassi Tuura | ae5c1f2 | 2011-04-17 20:33:09 -0700 | [diff] [blame] | 343 | /* Provide a place holder for architecture to override for fast access |
| 344 | to memory when known not to need to validate and know the access |
| 345 | will be local to the process. A suitable override will improve |
| 346 | unw_tdep_trace() performance in particular. */ |
| 347 | #define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ |
| 348 | do { (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); } \ |
| 349 | while (0) |
| 350 | |
| Ken Werner | 91494b7 | 2011-10-25 15:19:49 +0000 | [diff] [blame] | 351 | /* Define GNU and processor specific values for the Phdr p_type field in case |
| 352 | they aren't defined by <elf.h>. */ |
| 353 | #ifndef PT_GNU_EH_FRAME |
| 354 | # define PT_GNU_EH_FRAME 0x6474e550 |
| 355 | #endif /* !PT_GNU_EH_FRAME */ |
| 356 | #ifndef PT_ARM_EXIDX |
| 357 | # define PT_ARM_EXIDX 0x70000001 /* ARM unwind segment */ |
| 358 | #endif /* !PT_ARM_EXIDX */ |
| 359 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 360 | #include "tdep/libunwind_i.h" |
| 361 | |
| David Mosberger-Tang | e6b9f35 | 2007-08-22 13:02:09 -0600 | [diff] [blame] | 362 | #ifndef tdep_get_func_addr |
| 363 | # define tdep_get_func_addr(as,addr,v) (*(v) = addr, 0) |
| 364 | #endif |
| 365 | |
| Tommi Rantala | c2f7574 | 2012-09-04 17:04:14 +0300 | [diff] [blame] | 366 | #define UNW_ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) |
| 367 | |
| hp.com!davidm | d5ab898 | 2005-05-20 11:28:16 +0000 | [diff] [blame] | 368 | #endif /* libunwind_i_h */ |