< prev index next >

src/share/vm/services/diagnosticCommand.cpp

Print this page
rev 12474 : 8171924: Use SIZE_FORMAT to print size_t values.


 275     return;
 276   }
 277 
 278   char *suffix = strrchr(_libpath.value(), '.');
 279   bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
 280 
 281   if (is_java_agent) {
 282     if (_option.value() == NULL) {
 283       JvmtiExport::load_agent_library("instrument", "false",
 284                                       _libpath.value(), output());
 285     } else {
 286       size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
 287       if (opt_len > 4096) {
 288         output()->print_cr("JVMTI agent attach failed: Options is too long.");
 289         return;
 290       }
 291 
 292       char *opt = (char *)os::malloc(opt_len, mtInternal);
 293       if (opt == NULL) {
 294         output()->print_cr("JVMTI agent attach failed: "
 295                            "Could not allocate %zu bytes for argument.",
 296                            opt_len);
 297         return;
 298       }
 299 
 300       jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
 301       JvmtiExport::load_agent_library("instrument", "false", opt, output());
 302 
 303       os::free(opt);
 304     }
 305   } else {
 306     JvmtiExport::load_agent_library(_libpath.value(), "true",
 307                                     _option.value(), output());
 308   }
 309 }
 310 
 311 int JVMTIAgentLoadDCmd::num_arguments() {
 312   ResourceMark rm;
 313   JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
 314   if (dcmd != NULL) {
 315     DCmdMark mark(dcmd);




 275     return;
 276   }
 277 
 278   char *suffix = strrchr(_libpath.value(), '.');
 279   bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
 280 
 281   if (is_java_agent) {
 282     if (_option.value() == NULL) {
 283       JvmtiExport::load_agent_library("instrument", "false",
 284                                       _libpath.value(), output());
 285     } else {
 286       size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
 287       if (opt_len > 4096) {
 288         output()->print_cr("JVMTI agent attach failed: Options is too long.");
 289         return;
 290       }
 291 
 292       char *opt = (char *)os::malloc(opt_len, mtInternal);
 293       if (opt == NULL) {
 294         output()->print_cr("JVMTI agent attach failed: "
 295                            "Could not allocate " SIZE_FORMAT " bytes for argument.",
 296                            opt_len);
 297         return;
 298       }
 299 
 300       jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
 301       JvmtiExport::load_agent_library("instrument", "false", opt, output());
 302 
 303       os::free(opt);
 304     }
 305   } else {
 306     JvmtiExport::load_agent_library(_libpath.value(), "true",
 307                                     _option.value(), output());
 308   }
 309 }
 310 
 311 int JVMTIAgentLoadDCmd::num_arguments() {
 312   ResourceMark rm;
 313   JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
 314   if (dcmd != NULL) {
 315     DCmdMark mark(dcmd);


< prev index next >