8288003: log events for os::dll_unload
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
03dca565cf
commit
c2ccf4ca85
@ -1786,6 +1786,18 @@ void * os::Linux::dll_load_in_vmthread(const char *filename, char *ebuf,
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* os::Linux::dll_path(void* lib) {
|
||||
struct link_map *lmap;
|
||||
const char* l_path = NULL;
|
||||
assert(lib != NULL, "dll_path parameter must not be NULL");
|
||||
|
||||
int res_dli = ::dlinfo(lib, RTLD_DI_LINKMAP, &lmap);
|
||||
if (res_dli == 0) {
|
||||
l_path = lmap->l_name;
|
||||
}
|
||||
return l_path;
|
||||
}
|
||||
|
||||
static bool _print_ascii_file(const char* filename, outputStream* st, const char* hdr = NULL) {
|
||||
int fd = ::open(filename, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -120,6 +120,7 @@ class Linux {
|
||||
static bool _stack_is_executable;
|
||||
static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
|
||||
static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
|
||||
static const char *dll_path(void* lib);
|
||||
|
||||
static void init_thread_fpu_state();
|
||||
static int get_fpu_control_word();
|
||||
|
@ -706,7 +706,26 @@ void* os::dll_lookup(void* handle, const char* name) {
|
||||
}
|
||||
|
||||
void os::dll_unload(void *lib) {
|
||||
::dlclose(lib);
|
||||
const char* l_path = LINUX_ONLY(os::Linux::dll_path(lib))
|
||||
NOT_LINUX("<not available>");
|
||||
if (l_path == NULL) l_path = "<not available>";
|
||||
int res = ::dlclose(lib);
|
||||
|
||||
if (res == 0) {
|
||||
Events::log_dll_message(NULL, "Unloaded shared library \"%s\" [" INTPTR_FORMAT "]",
|
||||
l_path, p2i(lib));
|
||||
log_info(os)("Unloaded shared library \"%s\" [" INTPTR_FORMAT "]", l_path, p2i(lib));
|
||||
} else {
|
||||
const char* error_report = ::dlerror();
|
||||
if (error_report == NULL) {
|
||||
error_report = "dlerror returned no error description";
|
||||
}
|
||||
|
||||
Events::log_dll_message(NULL, "Attempt to unload shared library \"%s\" [" INTPTR_FORMAT "] failed, %s",
|
||||
l_path, p2i(lib), error_report);
|
||||
log_info(os)("Attempt to unload shared library \"%s\" [" INTPTR_FORMAT "] failed, %s",
|
||||
l_path, p2i(lib), error_report);
|
||||
}
|
||||
}
|
||||
|
||||
jlong os::lseek(int fd, jlong offset, int whence) {
|
||||
|
@ -1236,7 +1236,18 @@ void os::die() {
|
||||
const char* os::dll_file_extension() { return ".dll"; }
|
||||
|
||||
void os::dll_unload(void *lib) {
|
||||
::FreeLibrary((HMODULE)lib);
|
||||
char name[MAX_PATH];
|
||||
if (::GetModuleFileName((HMODULE)lib, name, sizeof(name)) == 0) {
|
||||
snprintf(name, MAX_PATH, "<not available>");
|
||||
}
|
||||
if (::FreeLibrary((HMODULE)lib)) {
|
||||
Events::log_dll_message(NULL, "Unloaded dll \"%s\" [" INTPTR_FORMAT "]", name, p2i(lib));
|
||||
log_info(os)("Unloaded dll \"%s\" [" INTPTR_FORMAT "]", name, p2i(lib));
|
||||
} else {
|
||||
const DWORD errcode = ::GetLastError();
|
||||
Events::log_dll_message(NULL, "Attempt to unload dll \"%s\" [" INTPTR_FORMAT "] failed (error code %d)", name, p2i(lib), errcode);
|
||||
log_info(os)("Attempt to unload dll \"%s\" [" INTPTR_FORMAT "] failed (error code %d)", name, p2i(lib), errcode);
|
||||
}
|
||||
}
|
||||
|
||||
void* os::dll_lookup(void *lib, const char *name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user