1720 buf[0] = '\0'; |
1720 buf[0] = '\0'; |
1721 if (offset) *offset = -1; |
1721 if (offset) *offset = -1; |
1722 return false; |
1722 return false; |
1723 } |
1723 } |
1724 |
1724 |
1725 // Prints the names and full paths of all opened dynamic libraries |
1725 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { |
1726 // for current process |
|
1727 void os::print_dll_info(outputStream * st) { |
|
1728 Dl_info dli; |
1726 Dl_info dli; |
1729 void *handle; |
1727 // Sanity check? |
|
1728 if (dladdr(CAST_FROM_FN_PTR(void *, os::get_loaded_modules_info), &dli) == 0 || |
|
1729 dli.dli_fname == NULL) { |
|
1730 return 1; |
|
1731 } |
|
1732 |
|
1733 void * handle = dlopen(dli.dli_fname, RTLD_LAZY); |
|
1734 if (handle == NULL) { |
|
1735 return 1; |
|
1736 } |
|
1737 |
1730 Link_map *map; |
1738 Link_map *map; |
1731 Link_map *p; |
|
1732 |
|
1733 st->print_cr("Dynamic libraries:"); st->flush(); |
|
1734 |
|
1735 if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || |
|
1736 dli.dli_fname == NULL) { |
|
1737 st->print_cr("Error: Cannot print dynamic libraries."); |
|
1738 return; |
|
1739 } |
|
1740 handle = dlopen(dli.dli_fname, RTLD_LAZY); |
|
1741 if (handle == NULL) { |
|
1742 st->print_cr("Error: Cannot print dynamic libraries."); |
|
1743 return; |
|
1744 } |
|
1745 dlinfo(handle, RTLD_DI_LINKMAP, &map); |
1739 dlinfo(handle, RTLD_DI_LINKMAP, &map); |
1746 if (map == NULL) { |
1740 if (map == NULL) { |
|
1741 dlclose(handle); |
|
1742 return 1; |
|
1743 } |
|
1744 |
|
1745 while (map->l_prev != NULL) { |
|
1746 map = map->l_prev; |
|
1747 } |
|
1748 |
|
1749 while (map != NULL) { |
|
1750 // Iterate through all map entries and call callback with fields of interest |
|
1751 if(callback(map->l_name, (address)map->l_addr, (address)0, param)) { |
|
1752 dlclose(handle); |
|
1753 return 1; |
|
1754 } |
|
1755 map = map->l_next; |
|
1756 } |
|
1757 |
|
1758 dlclose(handle); |
|
1759 return 0; |
|
1760 } |
|
1761 |
|
1762 int _print_dll_info_cb(const char * name, address base_address, address top_address, void * param) { |
|
1763 outputStream * out = (outputStream *) param; |
|
1764 out->print_cr(PTR_FORMAT " \t%s", base_address, name); |
|
1765 return 0; |
|
1766 } |
|
1767 |
|
1768 void os::print_dll_info(outputStream * st) { |
|
1769 st->print_cr("Dynamic libraries:"); st->flush(); |
|
1770 if (get_loaded_modules_info(_print_dll_info_cb, (void *)st)) { |
1747 st->print_cr("Error: Cannot print dynamic libraries."); |
1771 st->print_cr("Error: Cannot print dynamic libraries."); |
1748 return; |
1772 } |
1749 } |
|
1750 |
|
1751 while (map->l_prev != NULL) |
|
1752 map = map->l_prev; |
|
1753 |
|
1754 while (map != NULL) { |
|
1755 st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name); |
|
1756 map = map->l_next; |
|
1757 } |
|
1758 |
|
1759 dlclose(handle); |
|
1760 } |
1773 } |
1761 |
1774 |
1762 // Loads .dll/.so and |
1775 // Loads .dll/.so and |
1763 // in case of error it checks if .dll/.so was built for the |
1776 // in case of error it checks if .dll/.so was built for the |
1764 // same architecture as Hotspot is running on |
1777 // same architecture as Hotspot is running on |