1976 #define RTLD_DL_SYMENT 1 1977 #endif 1978 #ifdef _LP64 1979 Elf64_Sym * info; 1980 #else 1981 Elf32_Sym * info; 1982 #endif 1983 if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, 1984 RTLD_DL_SYMENT)) { 1985 if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) { 1986 if (buf != NULL) { 1987 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 1988 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 1989 } 1990 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 1991 return true; 1992 } 1993 } 1994 if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 1995 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 1996 dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { 1997 return true; 1998 } 1999 } 2000 if (buf != NULL) buf[0] = '\0'; 2001 if (offset != NULL) *offset = -1; 2002 return false; 2003 } else { 2004 // no, only dladdr is available 2005 if (dladdr((void *)addr, &dlinfo)) { 2006 if (buf != NULL) { 2007 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 2008 jio_snprintf(buf, buflen, dlinfo.dli_sname); 2009 } 2010 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 2011 return true; 2012 } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 2013 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 2014 dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { 2015 return true; 2016 } 2017 } 2018 if (buf != NULL) buf[0] = '\0'; 2019 if (offset != NULL) *offset = -1; 2020 return false; 2021 } 2022 } 2023 2024 bool os::dll_address_to_library_name(address addr, char* buf, 2025 int buflen, int* offset) { 2026 Dl_info dlinfo; 2027 2028 if (dladdr((void*)addr, &dlinfo)){ 2029 if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname); 2030 if (offset) *offset = addr - (address)dlinfo.dli_fbase; 2031 return true; 2032 } else { 2033 if (buf) buf[0] = '\0'; 2034 if (offset) *offset = -1; | 1976 #define RTLD_DL_SYMENT 1 1977 #endif 1978 #ifdef _LP64 1979 Elf64_Sym * info; 1980 #else 1981 Elf32_Sym * info; 1982 #endif 1983 if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, 1984 RTLD_DL_SYMENT)) { 1985 if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) { 1986 if (buf != NULL) { 1987 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 1988 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 1989 } 1990 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 1991 return true; 1992 } 1993 } 1994 if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 1995 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 1996 buf, buflen, offset, dlinfo.dli_fname)) { 1997 return true; 1998 } 1999 } 2000 if (buf != NULL) buf[0] = '\0'; 2001 if (offset != NULL) *offset = -1; 2002 return false; 2003 } else { 2004 // no, only dladdr is available 2005 if (dladdr((void *)addr, &dlinfo)) { 2006 if (buf != NULL) { 2007 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 2008 jio_snprintf(buf, buflen, dlinfo.dli_sname); 2009 } 2010 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 2011 return true; 2012 } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 2013 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 2014 buf, buflen, offset, dlinfo.dli_fname)) { 2015 return true; 2016 } 2017 } 2018 if (buf != NULL) buf[0] = '\0'; 2019 if (offset != NULL) *offset = -1; 2020 return false; 2021 } 2022 } 2023 2024 bool os::dll_address_to_library_name(address addr, char* buf, 2025 int buflen, int* offset) { 2026 Dl_info dlinfo; 2027 2028 if (dladdr((void*)addr, &dlinfo)){ 2029 if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname); 2030 if (offset) *offset = addr - (address)dlinfo.dli_fbase; 2031 return true; 2032 } else { 2033 if (buf) buf[0] = '\0'; 2034 if (offset) *offset = -1; |