As to DebugNonSafepoints
you don't even need to set this flag. Look at debugInfoRec.cpp:
static inline bool compute_recording_non_safepoints() {
if (JvmtiExport::should_post_compiled_method_load()
&& FLAG_IS_DEFAULT(DebugNonSafepoints)) {
// The default value of this flag is taken to be true,
// if JVMTI is looking at nmethod codes.
// We anticipate that JVMTI may wish to participate in profiling.
return true;
}
// If the flag is set manually, use it, whether true or false.
// Otherwise, if JVMTI is not in the picture, use the default setting.
// (This is true in debug, just for the exercise, false in product mode.)
return DebugNonSafepoints;
}
If the flag is not set, debug info is still recorded when JVMTI CompiledMethodLoad notifications are enabled. You just need to request can_generate_compiled_method_load_events
capability and turn on JVMTI_EVENT_COMPILED_METHOD_LOAD
notifications.
That's exactly how I handle it in my async-profiler
project.
There is no safe way to change unmanageable JVM flags in run-time. However, there is an ugly hack to do this on Linux.
- Read
/proc/self/maps
to find the base address of libjvm.so
.
- Use ELF format reader to discover an offset of the desired symbol in the dynamic library.
- Write directly to the address of this symbol.
Here is a sample code for this trick.