1 /* libunwind - a platform-independent unwind library 2 Copyright (C) 2001-2002, 2005 Hewlett-Packard Co 3 Contributed by David Mosberger-Tang <davidm (at) hpl.hp.com> 4 5 This file is part of libunwind. 6 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: 14 15 The above copyright notice and this permission notice shall be 16 included in all copies or substantial portions of the Software. 17 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. */ 25 26 #include "libunwind_i.h" 27 28 #ifdef UNW_REMOTE_ONLY 29 30 static inline int 31 local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, 32 int need_unwind_info, void *arg) 33 { 34 return -UNW_ENOINFO; 35 } 36 37 #else /* !UNW_REMOTE_ONLY */ 38 39 static inline int 40 local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, 41 int need_unwind_info, void *arg) 42 { 43 unw_dyn_info_list_t *list; 44 unw_dyn_info_t *di; 45 46 #ifndef UNW_LOCAL_ONLY 47 # pragma weak _U_dyn_info_list_addr 48 if (!_U_dyn_info_list_addr) 49 return -UNW_ENOINFO; 50 #endif 51 52 list = (unw_dyn_info_list_t *) (uintptr_t) _U_dyn_info_list_addr (); 53 for (di = list->first; di; di = di->next) 54 if (ip >= di->start_ip && ip < di->end_ip) 55 return unwi_extract_dynamic_proc_info (as, ip, pi, di, need_unwind_info, 56 arg); 57 return -UNW_ENOINFO; 58 } 59 60 #endif /* !UNW_REMOTE_ONLY */ 61 62 #ifdef UNW_LOCAL_ONLY 63 64 static inline int 65 remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, 66 int need_unwind_info, void *arg) 67 { 68 return -UNW_ENOINFO; 69 } 70 71 #else /* !UNW_LOCAL_ONLY */ 72 73 static inline int 74 remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, 75 int need_unwind_info, void *arg) 76 { 77 return unwi_dyn_remote_find_proc_info (as, ip, pi, need_unwind_info, arg); 78 } 79 80 #endif /* !UNW_LOCAL_ONLY */ 81 82 HIDDEN int 83 unwi_find_dynamic_proc_info (unw_addr_space_t as, unw_word_t ip, 84 unw_proc_info_t *pi, int need_unwind_info, 85 void *arg) 86 { 87 if (as == unw_local_addr_space) 88 return local_find_proc_info (as, ip, pi, need_unwind_info, arg); 89 else 90 return remote_find_proc_info (as, ip, pi, need_unwind_info, arg); 91 } 92