# HG changeset patch # User ysuenaga # Date 1473403136 25200 # Node ID 77a87b5e001cfd01fef1c56e69294fe7c594cf6c # Parent cc129ac8e6096dc1d1f138bdcde0d66052840e77 8164913: JVMTI.agent_load dcmd should show useful error message Summary: show useful error message Reviewed-by: dholmes, dsamersoff, sspitsyn diff -r cc129ac8e609 -r 77a87b5e001c hotspot/src/share/vm/prims/jvmtiExport.cpp --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp Tue Sep 06 22:52:35 2016 +0200 +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp Thu Sep 08 23:38:56 2016 -0700 @@ -2407,9 +2407,7 @@ delete agent_lib; } - // Agent_OnAttach executed so completion status is JNI_OK st->print_cr("%d", result); - result = JNI_OK; } } return result; diff -r cc129ac8e609 -r 77a87b5e001c hotspot/src/share/vm/services/diagnosticCommand.cpp --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp Tue Sep 06 22:52:35 2016 +0200 +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp Thu Sep 08 23:38:56 2016 -0700 @@ -277,11 +277,12 @@ char *suffix = strrchr(_libpath.value(), '.'); bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0); + jint result = JNI_ERR; if (is_java_agent) { if (_option.value() == NULL) { - JvmtiExport::load_agent_library("instrument", "false", - _libpath.value(), output()); + result = JvmtiExport::load_agent_library("instrument", "false", + _libpath.value(), output()); } else { size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2; if (opt_len > 4096) { @@ -298,14 +299,18 @@ } jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value()); - JvmtiExport::load_agent_library("instrument", "false", opt, output()); + result = JvmtiExport::load_agent_library("instrument", "false", + opt, output()); os::free(opt); } } else { - JvmtiExport::load_agent_library(_libpath.value(), "true", - _option.value(), output()); + result = JvmtiExport::load_agent_library(_libpath.value(), "true", + _option.value(), output()); } + + output()->print_cr("JVMTI agent attach %s.", + (result == JNI_OK) ? "succeeded" : "failed"); } int JVMTIAgentLoadDCmd::num_arguments() {