8228902: add os::dll_load to the unified logging os category

Reviewed-by: coleenp, mdoerr
This commit is contained in:
Matthias Baesken 2019-08-02 10:10:42 +02:00
parent 2e6e33eba1
commit f454862e65
5 changed files with 23 additions and 0 deletions

View file

@ -1313,6 +1313,8 @@ bool os::dll_address_to_library_name(address addr, char* buf,
// for the same architecture as Hotspot is running on.
void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", filename);
if (ebuf && ebuflen > 0) {
ebuf[0] = '\0';
ebuf[ebuflen - 1] = '\0';
@ -1329,6 +1331,7 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
Events::log(NULL, "Loaded shared library %s", filename);
// Reload dll cache. Don't do this in signal handling.
LoadedLibraries::reload();
log_info(os)("shared library load of %s was successful", filename);
return result;
} else {
// error analysis when dlopen fails
@ -1341,6 +1344,7 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
}
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
}
return NULL;
}

View file

@ -1263,10 +1263,13 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
#ifdef STATIC_BUILD
return os::get_default_process_handle();
#else
log_info(os)("attempting shared library load of %s", filename);
void * result= ::dlopen(filename, RTLD_LAZY);
if (result != NULL) {
Events::log(NULL, "Loaded shared library %s", filename);
// Successful loading
log_info(os)("shared library load of %s was successful", filename);
return result;
}
@ -1280,6 +1283,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
ebuf[ebuflen-1]='\0';
}
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
return NULL;
#endif // STATIC_BUILD
@ -1289,10 +1293,12 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
#ifdef STATIC_BUILD
return os::get_default_process_handle();
#else
log_info(os)("attempting shared library load of %s", filename);
void * result= ::dlopen(filename, RTLD_LAZY);
if (result != NULL) {
Events::log(NULL, "Loaded shared library %s", filename);
// Successful loading
log_info(os)("shared library load of %s was successful", filename);
return result;
}
@ -1308,6 +1314,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
ebuf[ebuflen-1]='\0';
}
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
int diag_msg_max_length=ebuflen-strlen(ebuf);
char* diag_msg_buf=ebuf+strlen(ebuf);

View file

@ -1739,6 +1739,8 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
void * result = NULL;
bool load_attempted = false;
log_info(os)("attempting shared library load of %s", filename);
// Check whether the library to load might change execution rights
// of the stack. If they are changed, the protection of the stack
// guard pages will be lost. We need a safepoint to fix this.
@ -1990,8 +1992,10 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf,
ebuf[ebuflen-1]='\0';
}
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
} else {
Events::log(NULL, "Loaded shared library %s", filename);
log_info(os)("shared library load of %s was successful", filename);
}
return result;
}

View file

@ -1532,10 +1532,13 @@ static void change_endianness(Elf32_Half& val) {
// same architecture as Hotspot is running on
void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", filename);
void * result= ::dlopen(filename, RTLD_LAZY);
if (result != NULL) {
// Successful loading
Events::log(NULL, "Loaded shared library %s", filename);
log_info(os)("shared library load of %s was successful", filename);
return result;
}
@ -1550,6 +1553,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
}
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
log_info(os)("shared library load of %s failed, %s", filename, error_report);
int diag_msg_max_length=ebuflen-strlen(ebuf);
char* diag_msg_buf=ebuf+strlen(ebuf);

View file

@ -1365,11 +1365,14 @@ static int _print_module(const char* fname, address base_address,
// in case of error it checks if .dll/.so was built for the
// same architecture as Hotspot is running on
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", name);
void * result = LoadLibrary(name);
if (result != NULL) {
Events::log(NULL, "Loaded shared library %s", name);
// Recalculate pdb search path if a DLL was loaded successfully.
SymbolEngine::recalc_search_path();
log_info(os)("shared library load of %s was successful", name);
return result;
}
DWORD errcode = GetLastError();
@ -1378,6 +1381,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
lasterror(ebuf, (size_t) ebuflen);
ebuf[ebuflen - 1] = '\0';
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
log_info(os)("shared library load of %s failed, error code %lu", name, errcode);
if (errcode == ERROR_MOD_NOT_FOUND) {
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);