Skip to content

Commit 230726e

Browse files
committedJun 8, 2022
8287735: Provide separate event category for dll operations
Reviewed-by: coleenp, stuefe
1 parent ecf0078 commit 230726e

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed
 

‎src/hotspot/os/aix/os_aix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
10971097
// RTLD_LAZY is currently not implemented. The dl is loaded immediately with all its dependants.
10981098
void * result= ::dlopen(filename, RTLD_LAZY);
10991099
if (result != NULL) {
1100-
Events::log(NULL, "Loaded shared library %s", filename);
1100+
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
11011101
// Reload dll cache. Don't do this in signal handling.
11021102
LoadedLibraries::reload();
11031103
log_info(os)("shared library load of %s was successful", filename);
@@ -1112,7 +1112,7 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
11121112
snprintf(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
11131113
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
11141114
}
1115-
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
1115+
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
11161116
log_info(os)("shared library load of %s failed, %s", filename, error_report);
11171117
}
11181118
return NULL;

‎src/hotspot/os/bsd/os_bsd.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
979979

980980
void * result= ::dlopen(filename, RTLD_LAZY);
981981
if (result != NULL) {
982-
Events::log(NULL, "Loaded shared library %s", filename);
982+
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
983983
// Successful loading
984984
log_info(os)("shared library load of %s was successful", filename);
985985
return result;
@@ -994,7 +994,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
994994
::strncpy(ebuf, error_report, ebuflen-1);
995995
ebuf[ebuflen-1]='\0';
996996
}
997-
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
997+
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
998998
log_info(os)("shared library load of %s failed, %s", filename, error_report);
999999

10001000
return NULL;
@@ -1008,7 +1008,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
10081008
log_info(os)("attempting shared library load of %s", filename);
10091009
void * result= ::dlopen(filename, RTLD_LAZY);
10101010
if (result != NULL) {
1011-
Events::log(NULL, "Loaded shared library %s", filename);
1011+
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
10121012
// Successful loading
10131013
log_info(os)("shared library load of %s was successful", filename);
10141014
return result;
@@ -1025,7 +1025,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
10251025
::strncpy(ebuf, error_report, ebuflen-1);
10261026
ebuf[ebuflen-1]='\0';
10271027
}
1028-
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
1028+
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
10291029
log_info(os)("shared library load of %s failed, %s", filename, error_report);
10301030

10311031
int diag_msg_max_length=ebuflen-strlen(ebuf);

‎src/hotspot/os/linux/os_linux.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1747,10 +1747,10 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf,
17471747
::strncpy(ebuf, error_report, ebuflen-1);
17481748
ebuf[ebuflen-1]='\0';
17491749
}
1750-
Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
1750+
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
17511751
log_info(os)("shared library load of %s failed, %s", filename, error_report);
17521752
} else {
1753-
Events::log(NULL, "Loaded shared library %s", filename);
1753+
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
17541754
log_info(os)("shared library load of %s was successful", filename);
17551755
}
17561756
return result;

‎src/hotspot/os/windows/os_windows.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
15071507

15081508
void * result = LoadLibrary(name);
15091509
if (result != NULL) {
1510-
Events::log(NULL, "Loaded shared library %s", name);
1510+
Events::log_dll_message(NULL, "Loaded shared library %s", name);
15111511
// Recalculate pdb search path if a DLL was loaded successfully.
15121512
SymbolEngine::recalc_search_path();
15131513
log_info(os)("shared library load of %s was successful", name);
@@ -1518,7 +1518,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
15181518
// It may or may not be overwritten below (in the for loop and just above)
15191519
lasterror(ebuf, (size_t) ebuflen);
15201520
ebuf[ebuflen - 1] = '\0';
1521-
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
1521+
Events::log_dll_message(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
15221522
log_info(os)("shared library load of %s failed, error code %lu", name, errcode);
15231523

15241524
if (errcode == ERROR_MOD_NOT_FOUND) {

‎src/hotspot/share/utilities/events.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,7 @@ StringEventLog* Events::_redefinitions = NULL;
4141
UnloadingEventLog* Events::_class_unloading = NULL;
4242
StringEventLog* Events::_class_loading = NULL;
4343
StringEventLog* Events::_deopt_messages = NULL;
44+
StringEventLog* Events::_dll_messages = NULL;
4445

4546
EventLog::EventLog() {
4647
// This normally done during bootstrap when we're only single
@@ -99,6 +100,7 @@ void Events::init() {
99100
_class_unloading = new UnloadingEventLog("Classes unloaded", "unload");
100101
_class_loading = new StringEventLog("Classes loaded", "load");
101102
_deopt_messages = new StringEventLog("Deoptimization events", "deopt");
103+
_dll_messages = new StringEventLog("Dll operation events", "dll");
102104
}
103105
}
104106

‎src/hotspot/share/utilities/events.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class Events : AllStatic {
230230
// Deoptization related messages
231231
static StringEventLog* _deopt_messages;
232232

233+
// dynamic lib related messages
234+
static StringEventLog* _dll_messages;
235+
233236
// Redefinition related messages
234237
static StringEventLog* _redefinitions;
235238

@@ -267,6 +270,8 @@ class Events : AllStatic {
267270

268271
static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
269272

273+
static void log_dll_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
274+
270275
// Register default loggers
271276
static void init();
272277
};
@@ -337,6 +342,15 @@ inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
337342
}
338343
}
339344

345+
inline void Events::log_dll_message(Thread* thread, const char* format, ...) {
346+
if (LogEvents && _dll_messages != NULL) {
347+
va_list ap;
348+
va_start(ap, format);
349+
_dll_messages->logv(thread, format, ap);
350+
va_end(ap);
351+
}
352+
}
353+
340354
template <class T>
341355
inline void EventLogBase<T>::print_log_on(outputStream* out, int max) {
342356
struct MaybeLocker {

0 commit comments

Comments
 (0)