8224958: add os::dll_load calls to event log
Reviewed-by: dholmes, mdoerr, stuefe
This commit is contained in:
parent
189345db4a
commit
0bf2650bb1
@ -1327,16 +1327,21 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
|||||||
// RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants.
|
// RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants.
|
||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
|
Events::log(NULL, "Loaded shared library %s", filename);
|
||||||
// Reload dll cache. Don't do this in signal handling.
|
// Reload dll cache. Don't do this in signal handling.
|
||||||
LoadedLibraries::reload();
|
LoadedLibraries::reload();
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
// error analysis when dlopen fails
|
// error analysis when dlopen fails
|
||||||
const char* const error_report = ::dlerror();
|
const char* error_report = ::dlerror();
|
||||||
if (error_report && ebuf && ebuflen > 0) {
|
if (error_report == NULL) {
|
||||||
|
error_report = "dlerror returned no error description";
|
||||||
|
}
|
||||||
|
if (ebuf != NULL && ebuflen > 0) {
|
||||||
snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
|
snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
|
||||||
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
|
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
|
||||||
}
|
}
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1265,13 +1265,21 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
|||||||
#else
|
#else
|
||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
|
Events::log(NULL, "Loaded shared library %s", filename);
|
||||||
// Successful loading
|
// Successful loading
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* error_report = ::dlerror();
|
||||||
|
if (error_report == NULL) {
|
||||||
|
error_report = "dlerror returned no error description";
|
||||||
|
}
|
||||||
|
if (ebuf != NULL && ebuflen > 0) {
|
||||||
// Read system error message into ebuf
|
// Read system error message into ebuf
|
||||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
|
}
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // STATIC_BUILD
|
#endif // STATIC_BUILD
|
||||||
@ -1283,16 +1291,24 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
|||||||
#else
|
#else
|
||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
|
Events::log(NULL, "Loaded shared library %s", filename);
|
||||||
// Successful loading
|
// Successful loading
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Elf32_Ehdr elf_head;
|
Elf32_Ehdr elf_head;
|
||||||
|
|
||||||
|
const char* const error_report = ::dlerror();
|
||||||
|
if (error_report == NULL) {
|
||||||
|
error_report = "dlerror returned no error description";
|
||||||
|
}
|
||||||
|
if (ebuf != NULL && ebuflen > 0) {
|
||||||
// Read system error message into ebuf
|
// Read system error message into ebuf
|
||||||
// It may or may not be overwritten below
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
|
}
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
|
|
||||||
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
||||||
char* diag_msg_buf=ebuf+strlen(ebuf);
|
char* diag_msg_buf=ebuf+strlen(ebuf);
|
||||||
|
|
||||||
|
@ -1881,9 +1881,18 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf,
|
|||||||
int ebuflen) {
|
int ebuflen) {
|
||||||
void * result = ::dlopen(filename, RTLD_LAZY);
|
void * result = ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
::strncpy(ebuf, ::dlerror(), ebuflen - 1);
|
const char* error_report = ::dlerror();
|
||||||
|
if (error_report == NULL) {
|
||||||
|
error_report = "dlerror returned no error description";
|
||||||
|
}
|
||||||
|
if (ebuf != NULL && ebuflen > 0) {
|
||||||
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
}
|
}
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
|
} else {
|
||||||
|
Events::log(NULL, "Loaded shared library %s", filename);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,15 +1528,22 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
|||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
// Successful loading
|
// Successful loading
|
||||||
|
Events::log(NULL, "Loaded shared library %s", filename);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Elf32_Ehdr elf_head;
|
Elf32_Ehdr elf_head;
|
||||||
|
const char* error_report = ::dlerror();
|
||||||
// Read system error message into ebuf
|
if (error_report == NULL) {
|
||||||
// It may or may not be overwritten below
|
error_report = "dlerror returned no error description";
|
||||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
}
|
||||||
|
if (ebuf != NULL && ebuflen > 0) {
|
||||||
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
|
|
||||||
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
||||||
char* diag_msg_buf=ebuf+strlen(ebuf);
|
char* diag_msg_buf=ebuf+strlen(ebuf);
|
||||||
|
|
||||||
|
@ -1367,12 +1367,18 @@ static int _print_module(const char* fname, address base_address,
|
|||||||
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
||||||
void * result = LoadLibrary(name);
|
void * result = LoadLibrary(name);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
|
Events::log(NULL, "Loaded shared library %s", name);
|
||||||
// Recalculate pdb search path if a DLL was loaded successfully.
|
// Recalculate pdb search path if a DLL was loaded successfully.
|
||||||
SymbolEngine::recalc_search_path();
|
SymbolEngine::recalc_search_path();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD errcode = GetLastError();
|
DWORD errcode = GetLastError();
|
||||||
|
// Read system error message into ebuf
|
||||||
|
// It may or may not be overwritten below (in the for loop and just above)
|
||||||
|
lasterror(ebuf, (size_t) ebuflen);
|
||||||
|
ebuf[ebuflen - 1] = '\0';
|
||||||
|
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
|
||||||
|
|
||||||
if (errcode == ERROR_MOD_NOT_FOUND) {
|
if (errcode == ERROR_MOD_NOT_FOUND) {
|
||||||
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
|
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
|
||||||
ebuf[ebuflen - 1] = '\0';
|
ebuf[ebuflen - 1] = '\0';
|
||||||
@ -1384,11 +1390,6 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
|||||||
// for an architecture other than Hotspot is running in
|
// for an architecture other than Hotspot is running in
|
||||||
// - then print to buffer "DLL was built for a different architecture"
|
// - then print to buffer "DLL was built for a different architecture"
|
||||||
// else call os::lasterror to obtain system error message
|
// else call os::lasterror to obtain system error message
|
||||||
|
|
||||||
// Read system error message into ebuf
|
|
||||||
// It may or may not be overwritten below (in the for loop and just above)
|
|
||||||
lasterror(ebuf, (size_t) ebuflen);
|
|
||||||
ebuf[ebuflen - 1] = '\0';
|
|
||||||
int fd = ::open(name, O_RDONLY | O_BINARY, 0);
|
int fd = ::open(name, O_RDONLY | O_BINARY, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user