1688 #else |
1688 #else |
1689 st->print_cr("Error: Cannot print dynamic libraries."); |
1689 st->print_cr("Error: Cannot print dynamic libraries."); |
1690 #endif |
1690 #endif |
1691 } |
1691 } |
1692 |
1692 |
|
1693 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { |
|
1694 #ifdef RTLD_DI_LINKMAP |
|
1695 Dl_info dli; |
|
1696 void *handle; |
|
1697 Link_map *map; |
|
1698 Link_map *p; |
|
1699 |
|
1700 if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || |
|
1701 dli.dli_fname == NULL) { |
|
1702 return 1; |
|
1703 } |
|
1704 handle = dlopen(dli.dli_fname, RTLD_LAZY); |
|
1705 if (handle == NULL) { |
|
1706 return 1; |
|
1707 } |
|
1708 dlinfo(handle, RTLD_DI_LINKMAP, &map); |
|
1709 if (map == NULL) { |
|
1710 dlclose(handle); |
|
1711 return 1; |
|
1712 } |
|
1713 |
|
1714 while (map->l_prev != NULL) |
|
1715 map = map->l_prev; |
|
1716 |
|
1717 while (map != NULL) { |
|
1718 // Value for top_address is returned as 0 since we don't have any information about module size |
|
1719 if (callback(map->l_name, (address)map->l_addr, (address)0, param)) { |
|
1720 dlclose(handle); |
|
1721 return 1; |
|
1722 } |
|
1723 map = map->l_next; |
|
1724 } |
|
1725 |
|
1726 dlclose(handle); |
|
1727 #elif defined(__APPLE__) |
|
1728 for (uint32_t i = 1; i < _dyld_image_count(); i++) { |
|
1729 // Value for top_address is returned as 0 since we don't have any information about module size |
|
1730 if (callback(_dyld_get_image_name(i), (address)_dyld_get_image_header(i), (address)0, param)) { |
|
1731 return 1; |
|
1732 } |
|
1733 } |
|
1734 return 0; |
|
1735 #else |
|
1736 return 1; |
|
1737 #endif |
|
1738 } |
|
1739 |
1693 void os::print_os_info_brief(outputStream* st) { |
1740 void os::print_os_info_brief(outputStream* st) { |
1694 st->print("Bsd"); |
1741 st->print("Bsd"); |
1695 |
1742 |
1696 os::Posix::print_uname_info(st); |
1743 os::Posix::print_uname_info(st); |
1697 } |
1744 } |
2558 } |
2605 } |
2559 } |
2606 } |
2560 |
2607 |
2561 size_t os::read(int fd, void *buf, unsigned int nBytes) { |
2608 size_t os::read(int fd, void *buf, unsigned int nBytes) { |
2562 RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes)); |
2609 RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes)); |
|
2610 } |
|
2611 |
|
2612 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) { |
|
2613 RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset)); |
2563 } |
2614 } |
2564 |
2615 |
2565 // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation. |
2616 // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation. |
2566 // Solaris uses poll(), bsd uses park(). |
2617 // Solaris uses poll(), bsd uses park(). |
2567 // Poll() is likely a better choice, assuming that Thread.interrupt() |
2618 // Poll() is likely a better choice, assuming that Thread.interrupt() |