8224221: add memprotect calls to event log
Reviewed-by: dholmes, mdoerr
This commit is contained in:
parent
b77c2ea4e9
commit
247729cdd7
@ -2442,6 +2442,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) {
|
||||
//
|
||||
// See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm
|
||||
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
|
||||
bool rc = ::mprotect(addr, size, prot) == 0 ? true : false;
|
||||
|
||||
if (!rc) {
|
||||
@ -2482,6 +2483,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) {
|
||||
// A valid strategy is just to try again. This usually works. :-/
|
||||
|
||||
::usleep(1000);
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
|
||||
if (::mprotect(addr, size, prot) == 0) {
|
||||
const bool read_protected_2 =
|
||||
(SafeFetch32((int*)addr, 0x12345678) == 0x12345678 &&
|
||||
|
@ -1933,6 +1933,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
#ifdef __OpenBSD__
|
||||
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
|
||||
if (::mprotect(addr, size, prot) == 0) {
|
||||
return true;
|
||||
}
|
||||
@ -2017,6 +2018,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info
|
||||
bool os::pd_uncommit_memory(char* addr, size_t size) {
|
||||
#ifdef __OpenBSD__
|
||||
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
|
||||
return ::mprotect(addr, size, PROT_NONE) == 0;
|
||||
#else
|
||||
uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
|
||||
@ -2085,6 +2087,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
|
||||
assert(addr == bottom, "sanity check");
|
||||
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size());
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
|
||||
return ::mprotect(bottom, size, prot) == 0;
|
||||
}
|
||||
|
||||
|
@ -3450,6 +3450,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
|
||||
assert(addr == bottom, "sanity check");
|
||||
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size());
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
|
||||
return ::mprotect(bottom, size, prot) == 0;
|
||||
}
|
||||
|
||||
|
@ -2666,6 +2666,7 @@ bool os::pd_release_memory(char* addr, size_t bytes) {
|
||||
static bool solaris_mprotect(char* addr, size_t bytes, int prot) {
|
||||
assert(addr == (char*)align_down((uintptr_t)addr, os::vm_page_size()),
|
||||
"addr must be page aligned");
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+bytes), prot);
|
||||
int retVal = mprotect(addr, bytes, prot);
|
||||
return retVal == 0;
|
||||
}
|
||||
@ -4229,6 +4230,7 @@ jint os::init_2(void) {
|
||||
|
||||
// Mark the polling page as unreadable
|
||||
void os::make_polling_page_unreadable(void) {
|
||||
Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_NONE", p2i(_polling_page));
|
||||
if (mprotect((char *)_polling_page, page_size, PROT_NONE) != 0) {
|
||||
fatal("Could not disable polling page");
|
||||
}
|
||||
@ -4236,6 +4238,7 @@ void os::make_polling_page_unreadable(void) {
|
||||
|
||||
// Mark the polling page as readable
|
||||
void os::make_polling_page_readable(void) {
|
||||
Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_READ", p2i(_polling_page));
|
||||
if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) {
|
||||
fatal("Could not enable polling page");
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ const size_t minimumSymbolTableSize = 1024;
|
||||
diagnostic(bool, LogEvents, true, \
|
||||
"Enable the various ring buffer event logs") \
|
||||
\
|
||||
diagnostic(uintx, LogEventsBufferEntries, 10, \
|
||||
diagnostic(uintx, LogEventsBufferEntries, 20, \
|
||||
"Number of ring buffer event logs") \
|
||||
range(1, NOT_LP64(1*K) LP64_ONLY(1*M)) \
|
||||
\
|
||||
|
@ -232,7 +232,7 @@ class Events : AllStatic {
|
||||
};
|
||||
|
||||
inline void Events::log(Thread* thread, const char* format, ...) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _messages != NULL) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
_messages->logv(thread, format, ap);
|
||||
@ -241,7 +241,7 @@ inline void Events::log(Thread* thread, const char* format, ...) {
|
||||
}
|
||||
|
||||
inline void Events::log_exception(Thread* thread, const char* format, ...) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _exceptions != NULL) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
_exceptions->logv(thread, format, ap);
|
||||
@ -250,13 +250,13 @@ 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) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _exceptions != NULL) {
|
||||
_exceptions->log(thread, h_exception, message, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _redefinitions != NULL) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
_redefinitions->logv(thread, format, ap);
|
||||
@ -265,13 +265,13 @@ inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
|
||||
}
|
||||
|
||||
inline void Events::log_class_unloading(Thread* thread, InstanceKlass* ik) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _class_unloading != NULL) {
|
||||
_class_unloading->log(thread, ik);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
|
||||
if (LogEvents) {
|
||||
if (LogEvents && _deopt_messages != NULL) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
_deopt_messages->logv(thread, format, ap);
|
||||
|
Loading…
Reference in New Issue
Block a user