14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/shared/vmGCOperations.hpp" 27 #include "runtime/javaCalls.hpp" 28 #include "services/diagnosticArgument.hpp" 29 #include "services/diagnosticCommand.hpp" 30 #include "services/diagnosticFramework.hpp" 31 #include "services/heapDumper.hpp" 32 #include "services/management.hpp" 33 #include "utilities/macros.hpp" 34 35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 36 37 void DCmdRegistrant::register_dcmds(){ 38 // Registration of the diagnostic commands 39 // First argument specifies which interfaces will export the command 40 // Second argument specifies if the command is enabled 41 // Third argument specifies if the command is hidden 42 uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI 43 | DCmd_Source_MBean; 44 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); 45 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); 46 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); 47 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); 48 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); 49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); 50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); 51 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); 52 #if INCLUDE_SERVICES // Heap dumping/inspection supported 53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false)); 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false)); 56 #endif // INCLUDE_SERVICES 57 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); 58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false)); 59 60 // Enhanced JMX Agent Support 61 // These commands won't be exported via the DiagnosticCommandMBean until an 62 // appropriate permission is created for them 63 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; 64 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); 65 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false)); 66 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); 67 68 } 69 70 #ifndef HAVE_EXTRA_DCMD 71 void DCmdRegistrant::register_dcmds_ext(){ 72 // Do nothing here 73 } 74 #endif 75 76 77 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), 78 _all("-all", "Show help for all commands", "BOOLEAN", false, "false"), 402 _dcmdparser.add_dcmd_option(&_locks); 403 } 404 405 void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) { 406 // thread stacks 407 VM_PrintThreads op1(output(), _locks.value()); 408 VMThread::execute(&op1); 409 410 // JNI global handles 411 VM_PrintJNI op2(output()); 412 VMThread::execute(&op2); 413 414 // Deadlock detection 415 VM_FindDeadlocks op3(output()); 416 VMThread::execute(&op3); 417 } 418 419 int ThreadDumpDCmd::num_arguments() { 420 ResourceMark rm; 421 ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false); 422 if (dcmd != NULL) { 423 DCmdMark mark(dcmd); 424 return dcmd->_dcmdparser.num_arguments(); 425 } else { 426 return 0; 427 } 428 } 429 430 // Enhanced JMX Agent support 431 432 JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) : 433 434 DCmdWithParser(output, heap_allocated), 435 436 _config_file 437 ("config.file", 438 "set com.sun.management.config.file", "STRING", false), 439 440 _jmxremote_host 441 ("jmxremote.host", | 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc_implementation/shared/vmGCOperations.hpp" 27 #include "runtime/javaCalls.hpp" 28 #include "services/diagnosticArgument.hpp" 29 #include "services/diagnosticCommand.hpp" 30 #include "services/diagnosticFramework.hpp" 31 #include "services/heapDumper.hpp" 32 #include "services/management.hpp" 33 #include "utilities/macros.hpp" 34 #include "evtrace/traceEvents.hpp" 35 36 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 37 38 void DCmdRegistrant::register_dcmds(){ 39 // Registration of the diagnostic commands 40 // First argument specifies which interfaces will export the command 41 // Second argument specifies if the command is enabled 42 // Third argument specifies if the command is hidden 43 uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI 44 | DCmd_Source_MBean; 45 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); 46 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); 47 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); 48 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); 49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); 50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); 51 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); 52 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); 53 #if INCLUDE_SERVICES // Heap dumping/inspection supported 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false)); 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); 56 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false)); 57 #endif // INCLUDE_SERVICES 58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); 59 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false)); 60 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventTracingMarkerDCmd>(full_export, true, false)); 61 62 // Enhanced JMX Agent Support 63 // These commands won't be exported via the DiagnosticCommandMBean until an 64 // appropriate permission is created for them 65 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; 66 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); 67 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false)); 68 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); 69 70 } 71 72 #ifndef HAVE_EXTRA_DCMD 73 void DCmdRegistrant::register_dcmds_ext(){ 74 // Do nothing here 75 } 76 #endif 77 78 79 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), 80 _all("-all", "Show help for all commands", "BOOLEAN", false, "false"), 404 _dcmdparser.add_dcmd_option(&_locks); 405 } 406 407 void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) { 408 // thread stacks 409 VM_PrintThreads op1(output(), _locks.value()); 410 VMThread::execute(&op1); 411 412 // JNI global handles 413 VM_PrintJNI op2(output()); 414 VMThread::execute(&op2); 415 416 // Deadlock detection 417 VM_FindDeadlocks op3(output()); 418 VMThread::execute(&op3); 419 } 420 421 int ThreadDumpDCmd::num_arguments() { 422 ResourceMark rm; 423 ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false); 424 if (dcmd != NULL) { 425 DCmdMark mark(dcmd); 426 return dcmd->_dcmdparser.num_arguments(); 427 } else { 428 return 0; 429 } 430 } 431 432 EventTracingMarkerDCmd::EventTracingMarkerDCmd(outputStream* output, bool heap) 433 : DCmdWithParser(output, heap), 434 _label("label", "description for the marker", "STRING", true) 435 { 436 _dcmdparser.add_dcmd_argument(&_label); 437 } 438 439 void EventTracingMarkerDCmd::execute(DCmdSource source, TRAPS) { 440 TraceEvents::write_marker(_label.value()); 441 } 442 443 int EventTracingMarkerDCmd::num_arguments() { 444 ResourceMark rm; 445 EventTracingMarkerDCmd* dcmd = new EventTracingMarkerDCmd(NULL, false); 446 if (dcmd != NULL) { 447 DCmdMark mark(dcmd); 448 return dcmd->_dcmdparser.num_arguments(); 449 } else { 450 return 0; 451 } 452 } 453 454 // Enhanced JMX Agent support 455 456 JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) : 457 458 DCmdWithParser(output, heap_allocated), 459 460 _config_file 461 ("config.file", 462 "set com.sun.management.config.file", "STRING", false), 463 464 _jmxremote_host 465 ("jmxremote.host", |