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.
|
||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||
if (result != NULL) {
|
||||
Events::log(NULL, "Loaded shared library %s", filename);
|
||||
// Reload dll cache. Don't do this in signal handling.
|
||||
LoadedLibraries::reload();
|
||||
return result;
|
||||
} else {
|
||||
// error analysis when dlopen fails
|
||||
const char* const error_report = ::dlerror();
|
||||
if (error_report && ebuf && ebuflen > 0) {
|
||||
const char* error_report = ::dlerror();
|
||||
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",
|
||||
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
|
||||
}
|
||||
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1265,13 +1265,21 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
#else
|
||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||
if (result != NULL) {
|
||||
Events::log(NULL, "Loaded shared library %s", filename);
|
||||
// Successful loading
|
||||
return result;
|
||||
}
|
||||
|
||||
// Read system error message into ebuf
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
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
|
||||
::strncpy(ebuf, error_report, ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
}
|
||||
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||
|
||||
return NULL;
|
||||
#endif // STATIC_BUILD
|
||||
@ -1283,16 +1291,24 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
#else
|
||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||
if (result != NULL) {
|
||||
Events::log(NULL, "Loaded shared library %s", filename);
|
||||
// Successful loading
|
||||
return result;
|
||||
}
|
||||
|
||||
Elf32_Ehdr elf_head;
|
||||
|
||||
// Read system error message into ebuf
|
||||
// It may or may not be overwritten below
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
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
|
||||
::strncpy(ebuf, error_report, ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
}
|
||||
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||
|
||||
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
||||
char* diag_msg_buf=ebuf+strlen(ebuf);
|
||||
|
||||
|
@ -1881,8 +1881,17 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf,
|
||||
int ebuflen) {
|
||||
void * result = ::dlopen(filename, RTLD_LAZY);
|
||||
if (result == NULL) {
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen - 1);
|
||||
ebuf[ebuflen-1] = '\0';
|
||||
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';
|
||||
}
|
||||
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||
} else {
|
||||
Events::log(NULL, "Loaded shared library %s", filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1528,15 +1528,22 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||
if (result != NULL) {
|
||||
// Successful loading
|
||||
Events::log(NULL, "Loaded shared library %s", filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
Elf32_Ehdr elf_head;
|
||||
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';
|
||||
}
|
||||
|
||||
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
||||
|
||||
// Read system error message into ebuf
|
||||
// It may or may not be overwritten below
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
int diag_msg_max_length=ebuflen-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 * 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();
|
||||
return result;
|
||||
}
|
||||
|
||||
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) {
|
||||
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
|
||||
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
|
||||
// - then print to buffer "DLL was built for a different architecture"
|
||||
// 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);
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user