mostang.com!davidm | a35b8d4 | 2002-12-19 07:16:50 +0000 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include "internal.h" |
| 4 | |
| 5 | static inline int |
| 6 | local_find_proc_info (unw_addr_space_t as, unw_word_t ip, |
| 7 | unw_proc_info_t *pi, |
| 8 | int need_unwind_info, void *arg) |
| 9 | { |
| 10 | unw_dyn_info_t *di; |
| 11 | |
| 12 | for (di = _U_dyn_info_list.first; di; di = di->next) |
| 13 | if (ip >= di->start_ip && ip < di->end_ip) |
| 14 | return unwi_extract_dynamic_proc_info (as, ip, pi, di, need_unwind_info, |
| 15 | arg); |
| 16 | return -UNW_ENOINFO; |
| 17 | } |
| 18 | |
| 19 | static inline int |
| 20 | remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, |
| 21 | int need_unwind_info, void *arg) |
| 22 | { |
| 23 | unw_word_t generation; |
| 24 | int ret; |
| 25 | |
| 26 | ret = unwi_dyn_remote_find_proc_info (as, ip, pi, &generation, |
| 27 | need_unwind_info, arg); |
| 28 | if (ret < 0) |
| 29 | return ret; |
| 30 | |
| 31 | /* Note: this can't go into dyn-remote.c because that file get's |
| 32 | compiled exactly once (there are no separate local/general |
| 33 | versions) and the call to unw_flush_cache() must evaluate to |
| 34 | either the local or generic version. */ |
| 35 | if (as->dyn_generation != generation) |
| 36 | { |
| 37 | unw_flush_cache (as, 0, 0); |
| 38 | as->dyn_generation = generation; |
| 39 | } |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | HIDDEN int |
| 44 | unwi_find_dynamic_proc_info (unw_addr_space_t as, unw_word_t ip, |
| 45 | unw_proc_info_t *pi, int need_unwind_info, |
| 46 | void *arg) |
| 47 | { |
| 48 | #ifdef UNW_LOCAL_ONLY |
| 49 | return local_find_proc_info (as, ip, pi, need_unwind_info, arg); |
| 50 | #else |
| 51 | # ifdef UNW_REMOTE_ONLY |
| 52 | return remote_find_proc_info (as, ip, pi, need_unwind_info, arg); |
| 53 | # else |
| 54 | if (as == unw_local_addr_space) |
| 55 | return local_find_proc_info (as, ip, pi, need_unwind_info, arg); |
| 56 | else |
| 57 | return remote_find_proc_info (as, ip, pi, need_unwind_info, arg); |
| 58 | # endif |
| 59 | #endif |
| 60 | } |