diff -r c7a3e57fdf4a -r b985cbb00e68 src/os/bsd/vm/os_bsd.cpp --- a/src/os/bsd/vm/os_bsd.cpp Thu Aug 01 03:44:03 2019 +0100 +++ b/src/os/bsd/vm/os_bsd.cpp Mon Aug 12 18:30:40 2019 +0300 @@ -1690,6 +1690,53 @@ #endif } +int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { +#ifdef RTLD_DI_LINKMAP + Dl_info dli; + void *handle; + Link_map *map; + Link_map *p; + + if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 || + dli.dli_fname == NULL) { + return 1; + } + handle = dlopen(dli.dli_fname, RTLD_LAZY); + if (handle == NULL) { + return 1; + } + dlinfo(handle, RTLD_DI_LINKMAP, &map); + if (map == NULL) { + dlclose(handle); + return 1; + } + + while (map->l_prev != NULL) + map = map->l_prev; + + while (map != NULL) { + // Value for top_address is returned as 0 since we don't have any information about module size + if (callback(map->l_name, (address)map->l_addr, (address)0, param)) { + dlclose(handle); + return 1; + } + map = map->l_next; + } + + dlclose(handle); +#elif defined(__APPLE__) + for (uint32_t i = 1; i < _dyld_image_count(); i++) { + // Value for top_address is returned as 0 since we don't have any information about module size + if (callback(_dyld_get_image_name(i), (address)_dyld_get_image_header(i), (address)0, param)) { + return 1; + } + } + return 0; +#else + return 1; +#endif +} + void os::print_os_info_brief(outputStream* st) { st->print("Bsd"); @@ -2562,6 +2609,10 @@ RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes)); } +size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) { + RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset)); +} + // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation. // Solaris uses poll(), bsd uses park(). // Poll() is likely a better choice, assuming that Thread.interrupt()