@@ -990,11 +990,17 @@ Engine *Profiler::selectCpuEngine(Arguments &args) {
990990 return &noop_engine;
991991 } else if (args._cpu >= 0 || strcmp (args._event , EVENT_CPU) == 0 ) {
992992 if (VM::isOpenJ9 ()) {
993- if (!J9Ext::is_jvmti_jmethodid_safe ()) {
994- Log::warn (" Safe jmethodID access is not available on this JVM. Using "
995- " CPU profiler on your own risk." );
993+ if (!J9Ext::shouldUseAsgct () || !J9Ext::can_use_ASGCT ()) {
994+ if (!J9Ext::is_jvmti_jmethodid_safe ()) {
995+ fprintf (stderr, " [ddprof] [WARN] Safe jmethodID access is not available on this JVM. Using "
996+ " CPU profiler on your own risk. Use -XX:+KeepJNIIDs=true JVM "
997+ " flag to make access to jmethodIDs safe, if your JVM supports it\n " );
998+ return &noop_engine;
999+ }
1000+ TEST_LOG (" J9[cpu]=jvmti" );
1001+ return &j9_engine;
9961002 }
997- return &j9_engine ;
1003+ TEST_LOG ( " J9[cpu]=asgct " ) ;
9981004 }
9991005 return !ctimer.check (args)
10001006 ? (Engine *)&ctimer
@@ -1017,14 +1023,18 @@ Engine *Profiler::selectWallEngine(Arguments &args) {
10171023 return &noop_engine;
10181024 }
10191025 if (VM::isOpenJ9 ()) {
1020- if (args._wallclock_sampler == JVMTI) {
1026+ if (args._wallclock_sampler == JVMTI || ! J9Ext::shouldUseAsgct () || ! J9Ext::can_use_ASGCT () ) {
10211027 if (!J9Ext::is_jvmti_jmethodid_safe ()) {
1022- Log::warn (" Safe jmethodID access is not available on this JVM. Using "
1023- " wallclock profiler on your own risk." );
1028+ fprintf (stderr, " [ddprof] [WARN] Safe jmethodID access is not available on this JVM. Using "
1029+ " wallclock profiler on your own risk. Use -XX:+KeepJNIIDs=true JVM "
1030+ " flag to make access to jmethodIDs safe, if your JVM supports it\n " );
1031+ return &noop_engine;
10241032 }
10251033 j9_engine.sampleIdleThreads ();
1034+ TEST_LOG (" J9[wall]=jvmti" );
10261035 return (Engine *)&j9_engine;
10271036 } else {
1037+ TEST_LOG (" J9[wall]=asgct" );
10281038 return (Engine *)&wall_asgct_engine;
10291039 }
10301040 }
@@ -1480,3 +1490,16 @@ int Profiler::lookupClass(const char *key, size_t length) {
14801490 // unable to lookup the class
14811491 return -1 ;
14821492}
1493+
1494+ int Profiler::status (char * status, int max_len) {
1495+ return snprintf (status, max_len,
1496+ " == Java-Profiler Status ===\n "
1497+ " Running : %s\n "
1498+ " CPU Engine : %s\n "
1499+ " WallClock Engine : %s\n "
1500+ " Allocations : %s\n " ,
1501+ _state == RUNNING ? " true" : " false" ,
1502+ _cpu_engine != nullptr ? _cpu_engine->name () : " None" ,
1503+ _wall_engine != nullptr ? _wall_engine->name () : " None" ,
1504+ _alloc_engine != nullptr ? _alloc_engine->name () : " None" );
1505+ }
0 commit comments