1 /* libunwind - a platform-independent unwind library 2 Copyright (C) 2003-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 "_UPT_internal.h" 27 28 #if UNW_TARGET_IA64 && defined(__linux) 29 # include "elf64.h" 30 # include "os-linux.h" 31 32 static inline int 33 get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, 34 int *countp) 35 { 36 unsigned long lo, hi, off; 37 struct UPT_info *ui = arg; 38 struct map_iterator mi; 39 char path[PATH_MAX]; 40 unw_word_t res; 41 int count = 0; 42 43 maps_init (&mi, ui->pid); 44 while (maps_next (&mi, &lo, &hi, &off)) 45 { 46 if (off) 47 continue; 48 49 invalidate_edi(&ui->edi); 50 51 Debug (16, "checking object %s\n", path); 52 53 if (tdep_find_unwind_table (&ui->edi, as, path, lo, off, 0) > 0) 54 { 55 res = _Uia64_find_dyn_list (as, &ui->edi.di_cache, arg); 56 if (res && count++ == 0) 57 { 58 Debug (12, "dyn_info_list_addr = 0x%lx\n", (long) res); 59 *dil_addr = res; 60 } 61 } 62 } 63 maps_close (&mi); 64 *countp = count; 65 return 0; 66 } 67 68 #else 69 70 static inline int 71 get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, 72 int *countp) 73 { 74 /* ANDROID support update. */ 75 # pragma message("Implement get_list_addr(), please.") 76 /* End of ANDROID update. */ 77 *countp = 0; 78 return 0; 79 } 80 81 #endif 82 83 int 84 _UPT_get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, 85 void *arg) 86 { 87 int count, ret; 88 89 Debug (12, "looking for dyn_info list\n"); 90 91 if ((ret = get_list_addr (as, dil_addr, arg, &count)) < 0) 92 return ret; 93 94 /* If multiple dynamic-info list addresses are found, we would have 95 to determine which was is the one actually in use (since the 96 dynamic name resolution algorithm will pick one "winner"). 97 Perhaps we'd have to track them all until we find one that's 98 non-empty. Hopefully, this case simply will never arise, since 99 only libunwind defines the dynamic info list head. */ 100 assert (count <= 1); 101 102 return (count > 0) ? 0 : -UNW_ENOINFO; 103 } 104