1642 ::close(fd); |
1642 ::close(fd); |
1643 |
1643 |
1644 return true; |
1644 return true; |
1645 } |
1645 } |
1646 |
1646 |
|
1647 int _print_dll_info_cb(const char * name, address base_address, address top_address, void * param) { |
|
1648 outputStream * out = (outputStream *) param; |
|
1649 out->print_cr(PTR_FORMAT " \t%s", base_address, name); |
|
1650 return 0; |
|
1651 } |
|
1652 |
1647 void os::print_dll_info(outputStream *st) { |
1653 void os::print_dll_info(outputStream *st) { |
1648 st->print_cr("Dynamic libraries:"); |
1654 st->print_cr("Dynamic libraries:"); |
|
1655 if (get_loaded_modules_info(_print_dll_info_cb, (void *)st)) { |
|
1656 st->print_cr("Error: Cannot print dynamic libraries."); |
|
1657 } |
|
1658 } |
|
1659 |
|
1660 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { |
1649 #ifdef RTLD_DI_LINKMAP |
1661 #ifdef RTLD_DI_LINKMAP |
1650 Dl_info dli; |
1662 Dl_info dli; |
1651 void *handle; |
1663 void *handle; |
1652 Link_map *map; |
1664 Link_map *map; |
1653 Link_map *p; |
1665 Link_map *p; |
1654 |
1666 |
1655 if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || |
1667 if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || |
1656 dli.dli_fname == NULL) { |
1668 dli.dli_fname == NULL) { |
1657 st->print_cr("Error: Cannot print dynamic libraries."); |
1669 return 1; |
1658 return; |
|
1659 } |
1670 } |
1660 handle = dlopen(dli.dli_fname, RTLD_LAZY); |
1671 handle = dlopen(dli.dli_fname, RTLD_LAZY); |
1661 if (handle == NULL) { |
1672 if (handle == NULL) { |
1662 st->print_cr("Error: Cannot print dynamic libraries."); |
1673 return 1; |
1663 return; |
|
1664 } |
1674 } |
1665 dlinfo(handle, RTLD_DI_LINKMAP, &map); |
1675 dlinfo(handle, RTLD_DI_LINKMAP, &map); |
1666 if (map == NULL) { |
1676 if (map == NULL) { |
1667 st->print_cr("Error: Cannot print dynamic libraries."); |
1677 dlclose(handle); |
1668 return; |
1678 return 1; |
1669 } |
1679 } |
1670 |
1680 |
1671 while (map->l_prev != NULL) |
1681 while (map->l_prev != NULL) |
1672 map = map->l_prev; |
1682 map = map->l_prev; |
1673 |
1683 |
1674 while (map != NULL) { |
1684 while (map != NULL) { |
1675 st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name); |
1685 // Value for top_address is returned as 0 since we don't have any information about module size |
|
1686 if (callback(map->l_name, (address)map->l_addr, (address)0, param)) { |
|
1687 dlclose(handle); |
|
1688 return 1; |
|
1689 } |
1676 map = map->l_next; |
1690 map = map->l_next; |
1677 } |
1691 } |
1678 |
1692 |
1679 dlclose(handle); |
1693 dlclose(handle); |
1680 #elif defined(__APPLE__) |
1694 #elif defined(__APPLE__) |
1681 for (uint32_t i = 1; i < _dyld_image_count(); i++) { |
1695 for (uint32_t i = 1; i < _dyld_image_count(); i++) { |
1682 st->print_cr(PTR_FORMAT " \t%s", _dyld_get_image_header(i), |
1696 // Value for top_address is returned as 0 since we don't have any information about module size |
1683 _dyld_get_image_name(i)); |
1697 if (callback(_dyld_get_image_name(i), (address)_dyld_get_image_header(i), (address)0, param)) { |
1684 } |
1698 return 1; |
|
1699 } |
|
1700 } |
|
1701 return 0; |
1685 #else |
1702 #else |
1686 st->print_cr("Error: Cannot print dynamic libraries."); |
1703 return 1; |
1687 #endif |
1704 #endif |
1688 } |
1705 } |
1689 |
1706 |
1690 void os::print_os_info_brief(outputStream* st) { |
1707 void os::print_os_info_brief(outputStream* st) { |
1691 st->print("Bsd"); |
1708 st->print("Bsd"); |