< prev index next >

src/share/vm/services/diagnosticCommand.cpp

Print this page




  54   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
  55   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
  56   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
  57   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
  58   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
  59   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
  60   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
  61   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
  62   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
  63   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  64 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  65   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  66   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  67   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  68   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
  70   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
  71 #endif // INCLUDE_SERVICES
  72 #if INCLUDE_JVMTI
  73   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));

  74 #endif // INCLUDE_JVMTI
  75   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
  76   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
  77   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
  78   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
  79   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
  80   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
  81 
  82   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
  83   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
  84   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
  85   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
  86 
  87   // Enhanced JMX Agent Support
  88   // These commands won't be exported via the DiagnosticCommandMBean until an
  89   // appropriate permission is created for them
  90   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  91   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  92   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  93   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));


 234 
 235   if (ret != Flag::SUCCESS) {
 236     output()->print_cr("%s", err_msg.buffer());
 237   }
 238 }
 239 
 240 int SetVMFlagDCmd::num_arguments() {
 241   ResourceMark rm;
 242   SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
 243   if (dcmd != NULL) {
 244     DCmdMark mark(dcmd);
 245     return dcmd->_dcmdparser.num_arguments();
 246   } else {
 247     return 0;
 248   }
 249 }
 250 
 251 void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
 252   if (JvmtiExport::should_post_data_dump()) {
 253     JvmtiExport::post_data_dump();





















































 254   }
 255 }
 256 
 257 void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
 258   // load sun.misc.VMSupport
 259   Symbol* klass = vmSymbols::sun_misc_VMSupport();
 260   Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
 261   instanceKlassHandle ik (THREAD, k);
 262   if (ik->should_be_initialized()) {
 263     ik->initialize(THREAD);
 264   }
 265   if (HAS_PENDING_EXCEPTION) {
 266     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 267     output()->cr();
 268     CLEAR_PENDING_EXCEPTION;
 269     return;
 270   }
 271 
 272   // invoke the serializePropertiesToByteArray method
 273   JavaValue result(T_OBJECT);




  54   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
  55   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
  56   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
  57   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
  58   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
  59   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
  60   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
  61   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
  62   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
  63   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  64 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  65   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  66   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  67   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  68   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
  70   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
  71 #endif // INCLUDE_SERVICES
  72 #if INCLUDE_JVMTI
  73   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
  74   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
  75 #endif // INCLUDE_JVMTI
  76   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
  77   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
  78   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
  79   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
  80   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
  81   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
  82 
  83   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
  84   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
  85   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
  86   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
  87 
  88   // Enhanced JMX Agent Support
  89   // These commands won't be exported via the DiagnosticCommandMBean until an
  90   // appropriate permission is created for them
  91   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  92   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  93   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  94   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));


 235 
 236   if (ret != Flag::SUCCESS) {
 237     output()->print_cr("%s", err_msg.buffer());
 238   }
 239 }
 240 
 241 int SetVMFlagDCmd::num_arguments() {
 242   ResourceMark rm;
 243   SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
 244   if (dcmd != NULL) {
 245     DCmdMark mark(dcmd);
 246     return dcmd->_dcmdparser.num_arguments();
 247   } else {
 248     return 0;
 249   }
 250 }
 251 
 252 void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
 253   if (JvmtiExport::should_post_data_dump()) {
 254     JvmtiExport::post_data_dump();
 255   }
 256 }
 257 
 258 JVMTIAgentLoadDCmd::JVMTIAgentLoadDCmd(outputStream* output, bool heap) :
 259                                                DCmdWithParser(output, heap),
 260   _libpath("library path", "Absolute path of the JVMTI agent to load.",
 261                                                               "STRING", true),
 262   _option("agent option", "Option string to pass the agent.", "STRING", false) {
 263   _dcmdparser.add_dcmd_argument(&_libpath);
 264   _dcmdparser.add_dcmd_argument(&_option);
 265 }
 266 
 267 void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) {
 268 
 269   if (_libpath.value() == NULL) {
 270     output()->print_cr("JVMTI.agent_load dcmd needs library path.");
 271     return;
 272   }
 273 
 274   char *suffix = strrchr(_libpath.value(), '.');
 275   bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
 276 
 277   if (is_java_agent) {
 278     if (_option.value() == NULL) {
 279       JvmtiExport::load_agent_library("instrument", "false",
 280                                               _libpath.value(), output());
 281     } else {
 282       int opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
 283       char *opt = (char *)os::malloc(opt_len, mtInternal);
 284       if (opt == NULL) {
 285         vm_exit_out_of_memory(opt_len, OOM_MALLOC_ERROR,
 286                                              "JVMTIAgentLoadDCmd::execute");
 287       }
 288 
 289       snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
 290       JvmtiExport::load_agent_library("instrument", "false", opt, output());
 291 
 292       os::free(opt);
 293     }
 294   } else {
 295     JvmtiExport::load_agent_library(_libpath.value(), "true",
 296                                                  _option.value(), output());
 297   }
 298 }
 299 
 300 int JVMTIAgentLoadDCmd::num_arguments() {
 301   ResourceMark rm;
 302   JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
 303   if (dcmd != NULL) {
 304     DCmdMark mark(dcmd);
 305     return dcmd->_dcmdparser.num_arguments();
 306   } else {
 307     return 0;
 308   }
 309 }
 310 
 311 void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
 312   // load sun.misc.VMSupport
 313   Symbol* klass = vmSymbols::sun_misc_VMSupport();
 314   Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
 315   instanceKlassHandle ik (THREAD, k);
 316   if (ik->should_be_initialized()) {
 317     ik->initialize(THREAD);
 318   }
 319   if (HAS_PENDING_EXCEPTION) {
 320     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 321     output()->cr();
 322     CLEAR_PENDING_EXCEPTION;
 323     return;
 324   }
 325 
 326   // invoke the serializePropertiesToByteArray method
 327   JavaValue result(T_OBJECT);


< prev index next >