equal
deleted
inserted
replaced
275 return; |
275 return; |
276 } |
276 } |
277 |
277 |
278 char *suffix = strrchr(_libpath.value(), '.'); |
278 char *suffix = strrchr(_libpath.value(), '.'); |
279 bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0); |
279 bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0); |
|
280 jint result = JNI_ERR; |
280 |
281 |
281 if (is_java_agent) { |
282 if (is_java_agent) { |
282 if (_option.value() == NULL) { |
283 if (_option.value() == NULL) { |
283 JvmtiExport::load_agent_library("instrument", "false", |
284 result = JvmtiExport::load_agent_library("instrument", "false", |
284 _libpath.value(), output()); |
285 _libpath.value(), output()); |
285 } else { |
286 } else { |
286 size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2; |
287 size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2; |
287 if (opt_len > 4096) { |
288 if (opt_len > 4096) { |
288 output()->print_cr("JVMTI agent attach failed: Options is too long."); |
289 output()->print_cr("JVMTI agent attach failed: Options is too long."); |
289 return; |
290 return; |
296 opt_len); |
297 opt_len); |
297 return; |
298 return; |
298 } |
299 } |
299 |
300 |
300 jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value()); |
301 jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value()); |
301 JvmtiExport::load_agent_library("instrument", "false", opt, output()); |
302 result = JvmtiExport::load_agent_library("instrument", "false", |
|
303 opt, output()); |
302 |
304 |
303 os::free(opt); |
305 os::free(opt); |
304 } |
306 } |
305 } else { |
307 } else { |
306 JvmtiExport::load_agent_library(_libpath.value(), "true", |
308 result = JvmtiExport::load_agent_library(_libpath.value(), "true", |
307 _option.value(), output()); |
309 _option.value(), output()); |
308 } |
310 } |
|
311 |
|
312 output()->print_cr("JVMTI agent attach %s.", |
|
313 (result == JNI_OK) ? "succeeded" : "failed"); |
309 } |
314 } |
310 |
315 |
311 int JVMTIAgentLoadDCmd::num_arguments() { |
316 int JVMTIAgentLoadDCmd::num_arguments() { |
312 ResourceMark rm; |
317 ResourceMark rm; |
313 JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false); |
318 JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false); |