8328630: Add logging when needed symbols in dll are missing.

Reviewed-by: dholmes, luhenry, mli
This commit is contained in:
Robbin Ehn 2024-04-09 15:00:50 +00:00
parent 2e925f263d
commit 23d161de29
2 changed files with 19 additions and 2 deletions

View File

@ -722,7 +722,16 @@ void* os::get_default_process_handle() {
}
void* os::dll_lookup(void* handle, const char* name) {
return dlsym(handle, name);
::dlerror(); // Clear any previous error
void* ret = ::dlsym(handle, name);
if (ret == nullptr) {
const char* tmp = ::dlerror();
// It is possible that we found a NULL symbol, hence no error.
if (tmp != nullptr) {
log_debug(os)("Symbol %s not found in dll: %s", name, tmp);
}
}
return ret;
}
void os::dll_unload(void *lib) {

View File

@ -1280,7 +1280,15 @@ void os::dll_unload(void *lib) {
}
void* os::dll_lookup(void *lib, const char *name) {
return (void*)::GetProcAddress((HMODULE)lib, name);
::SetLastError(0); // Clear old pending errors
void* ret = ::GetProcAddress((HMODULE)lib, name);
if (ret == nullptr) {
char buf[512];
if (os::lasterror(buf, sizeof(buf)) > 0) {
log_debug(os)("Symbol %s not found in dll: %s", name, buf);
}
}
return ret;
}
// Directory routines copied from src/win32/native/java/io/dirent_md.c