8328880: Events::log_exception should limit the size of the logging message
Reviewed-by: shade, kvn
This commit is contained in:
parent
c89a1c35bd
commit
ea3370982b
src/hotspot/share/utilities
@ -151,7 +151,9 @@ void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) {
|
||||
ik->name()->print_value_on(&st);
|
||||
}
|
||||
|
||||
void ExceptionsEventLog::log(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
|
||||
void ExceptionsEventLog::log(Thread* thread, Handle h_exception,
|
||||
const char* message, const char* file, int line,
|
||||
int message_length_limit) {
|
||||
if (!should_log()) return;
|
||||
|
||||
double timestamp = fetch_timestamp();
|
||||
@ -163,8 +165,11 @@ void ExceptionsEventLog::log(Thread* thread, Handle h_exception, const char* mes
|
||||
_records[index].data.size());
|
||||
st.print("Exception <");
|
||||
h_exception->print_value_on(&st);
|
||||
st.print("%s%s> (" PTR_FORMAT ") \n"
|
||||
if (message != nullptr) {
|
||||
int len = message_length_limit > 0 ? message_length_limit : (int)strlen(message);
|
||||
st.print(": %.*s", len, message);
|
||||
}
|
||||
st.print("> (" PTR_FORMAT ") \n"
|
||||
"thrown [%s, line %d]",
|
||||
message ? ": " : "", message ? message : "",
|
||||
p2i(h_exception()), file, line);
|
||||
}
|
||||
|
@ -207,7 +207,9 @@ class ExceptionsEventLog : public ExtendedStringEventLog {
|
||||
ExceptionsEventLog(const char* name, const char* short_name, int count = LogEventsBufferEntries)
|
||||
: ExtendedStringEventLog(name, short_name, count) {}
|
||||
|
||||
void log(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
|
||||
// Message length limit of zero means no limit.
|
||||
void log(Thread* thread, Handle h_exception, const char* message,
|
||||
const char* file, int line, int message_length_limit = 0);
|
||||
};
|
||||
|
||||
|
||||
@ -275,7 +277,7 @@ class Events : AllStatic {
|
||||
|
||||
// Log exception related message
|
||||
static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
|
||||
static void log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
|
||||
static void log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line, int message_length_limit = 0);
|
||||
|
||||
static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
|
||||
|
||||
@ -345,9 +347,11 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void Events::log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
|
||||
inline void Events::log_exception(Thread* thread, Handle h_exception,
|
||||
const char* message, const char* file,
|
||||
int line, int message_length_limit) {
|
||||
if (LogEvents && _exceptions != nullptr) {
|
||||
_exceptions->log(thread, h_exception, message, file, line);
|
||||
_exceptions->log(thread, h_exception, message, file, line, message_length_limit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ void Exceptions::_throw(JavaThread* thread, const char* file, int line, Handle h
|
||||
thread->set_pending_exception(h_exception(), file, line);
|
||||
|
||||
// vm log
|
||||
Events::log_exception(thread, h_exception, message, file, line);
|
||||
Events::log_exception(thread, h_exception, message, file, line, MAX_LEN);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user