src/share/vm/services/diagnosticCommand.cpp

Print this page

        

*** 28,60 **** #include "services/diagnosticArgument.hpp" #include "services/diagnosticCommand.hpp" #include "services/diagnosticFramework.hpp" #include "services/heapDumper.hpp" #include "services/management.hpp" void DCmdRegistrant::register_dcmds(){ // Registration of the diagnostic commands ! // First boolean argument specifies if the command is enabled ! // Second boolean argument specifies if the command is hidden ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false)); #if INCLUDE_SERVICES // Heap dumping supported ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false)); #endif // INCLUDE_SERVICES ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false)); ! //Enhanced JMX Agent Support ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false)); } #ifndef HAVE_EXTRA_DCMD void DCmdRegistrant::register_dcmds_ext(){ --- 28,68 ---- #include "services/diagnosticArgument.hpp" #include "services/diagnosticCommand.hpp" #include "services/diagnosticFramework.hpp" #include "services/heapDumper.hpp" #include "services/management.hpp" + #include "services/nmtDCmd.hpp" void DCmdRegistrant::register_dcmds(){ // Registration of the diagnostic commands ! // First argument specifies which interfaces will export the command ! // Second argument specifies if the command is enabled ! // Third argument specifies if the command is hidden ! uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI ! | DCmd_Source_MBean; ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); #if INCLUDE_SERVICES // Heap dumping supported ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(full_export, true, false)); #endif // INCLUDE_SERVICES ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<NMTDCmd>(full_export, true, false)); ! // Enhanced JMX Agent Support ! // These commands won't be exported via the DiagnosticCommandMBean until an ! // appropriate permission is created for them ! uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false)); ! DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); } #ifndef HAVE_EXTRA_DCMD void DCmdRegistrant::register_dcmds_ext(){
*** 69,101 **** "STRING", false) { _dcmdparser.add_dcmd_option(&_all); _dcmdparser.add_dcmd_argument(&_cmd); }; ! void HelpDCmd::execute(TRAPS) { if (_all.value()) { ! GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(); for (int i = 0; i < cmd_list->length(); i++) { ! DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i), strlen(cmd_list->at(i))); - if (!factory->is_hidden()) { output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); output()->print_cr("\t%s", factory->description()); output()->cr(); - } factory = factory->next(); } } else if (_cmd.has_value()) { DCmd* cmd = NULL; ! DCmdFactory* factory = DCmdFactory::factory(_cmd.value(), strlen(_cmd.value())); if (factory != NULL) { output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); output()->print_cr(factory->description()); output()->print_cr("\nImpact: %s", factory->impact()); output()->cr(); cmd = factory->create_resource_instance(output()); if (cmd != NULL) { DCmdMark mark(cmd); cmd->print_help(factory->name()); --- 77,117 ---- "STRING", false) { _dcmdparser.add_dcmd_option(&_all); _dcmdparser.add_dcmd_argument(&_cmd); }; ! void HelpDCmd::execute(DCmdSource source, TRAPS) { if (_all.value()) { ! GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source); for (int i = 0; i < cmd_list->length(); i++) { ! DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i), strlen(cmd_list->at(i))); output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); output()->print_cr("\t%s", factory->description()); output()->cr(); factory = factory->next(); } } else if (_cmd.has_value()) { DCmd* cmd = NULL; ! DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(), strlen(_cmd.value())); if (factory != NULL) { output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); output()->print_cr(factory->description()); output()->print_cr("\nImpact: %s", factory->impact()); + JavaPermission p = factory->permission(); + if(p._class != NULL) { + if(p._action != NULL) { + output()->print_cr("\nPermission: %s(%s, %s)", + p._class, p._name, p._action); + } else { + output()->print_cr("\nPermission: %s(%s)", + p._class, p._name); + } + } output()->cr(); cmd = factory->create_resource_instance(output()); if (cmd != NULL) { DCmdMark mark(cmd); cmd->print_help(factory->name());
*** 103,120 **** } else { output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value()); } } else { output()->print_cr("The following commands are available:"); ! GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(); for (int i = 0; i < cmd_list->length(); i++) { ! DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i), strlen(cmd_list->at(i))); - if (!factory->is_hidden()) { output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); - } factory = factory->_next; } output()->print_cr("\nFor more information about a specific command use 'help <command>'."); } } --- 119,134 ---- } else { output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value()); } } else { output()->print_cr("The following commands are available:"); ! GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source); for (int i = 0; i < cmd_list->length(); i++) { ! DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i), strlen(cmd_list->at(i))); output()->print_cr("%s%s", factory->name(), factory->is_enabled() ? "" : " [disabled]"); factory = factory->_next; } output()->print_cr("\nFor more information about a specific command use 'help <command>'."); } }
*** 128,138 **** } else { return 0; } } ! void VersionDCmd::execute(TRAPS) { output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(), Abstract_VM_Version::vm_release()); JDK_Version jdk_version = JDK_Version::current(); if (jdk_version.update_version() > 0) { output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(), --- 142,152 ---- } else { return 0; } } ! void VersionDCmd::execute(DCmdSource source, TRAPS) { output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(), Abstract_VM_Version::vm_release()); JDK_Version jdk_version = JDK_Version::current(); if (jdk_version.update_version() > 0) { output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
*** 147,157 **** DCmdWithParser(output, heap), _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); } ! void PrintVMFlagsDCmd::execute(TRAPS) { if (_all.value()) { CommandLineFlags::printFlags(output(), true); } else { CommandLineFlags::printSetFlags(output()); } --- 161,171 ---- DCmdWithParser(output, heap), _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); } ! void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) { if (_all.value()) { CommandLineFlags::printFlags(output(), true); } else { CommandLineFlags::printSetFlags(output()); }
*** 166,176 **** } else { return 0; } } ! void PrintSystemPropertiesDCmd::execute(TRAPS) { // load sun.misc.VMSupport Symbol* klass = vmSymbols::sun_misc_VMSupport(); Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK); instanceKlassHandle ik (THREAD, k); if (ik->should_be_initialized()) { --- 180,190 ---- } else { return 0; } } ! void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) { // load sun.misc.VMSupport Symbol* klass = vmSymbols::sun_misc_VMSupport(); Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK); instanceKlassHandle ik (THREAD, k); if (ik->should_be_initialized()) {
*** 216,226 **** DCmdWithParser(output, heap), _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_date); } ! void VMUptimeDCmd::execute(TRAPS) { if (_date.value()) { output()->date_stamp(true, "", ": "); } output()->time_stamp().update_to(tty->time_stamp().ticks()); output()->stamp(); --- 230,240 ---- DCmdWithParser(output, heap), _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_date); } ! void VMUptimeDCmd::execute(DCmdSource source, TRAPS) { if (_date.value()) { output()->date_stamp(true, "", ": "); } output()->time_stamp().update_to(tty->time_stamp().ticks()); output()->stamp();
*** 236,250 **** } else { return 0; } } ! void SystemGCDCmd::execute(TRAPS) { Universe::heap()->collect(GCCause::_java_lang_system_gc); } ! void RunFinalizationDCmd::execute(TRAPS) { Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); instanceKlassHandle klass(THREAD, k); JavaValue result(T_VOID); JavaCalls::call_static(&result, klass, --- 250,268 ---- } else { return 0; } } ! void SystemGCDCmd::execute(DCmdSource source, TRAPS) { ! if (!DisableExplicitGC) { Universe::heap()->collect(GCCause::_java_lang_system_gc); + } else { + output()->print_cr("Explicit GC are disabled, no GC has been performed."); + } } ! void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); instanceKlassHandle klass(THREAD, k); JavaValue result(T_VOID); JavaCalls::call_static(&result, klass,
*** 260,270 **** "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); _dcmdparser.add_dcmd_argument(&_filename); } ! void HeapDumpDCmd::execute(TRAPS) { // Request a full GC before heap dump if _all is false // This helps reduces the amount of unreachable objects in the dump // and makes it easier to browse. HeapDumper dumper(!_all.value() /* request GC if _all is false*/); int res = dumper.dump(_filename.value()); --- 278,288 ---- "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); _dcmdparser.add_dcmd_argument(&_filename); } ! void HeapDumpDCmd::execute(DCmdSource source, TRAPS) { // Request a full GC before heap dump if _all is false // This helps reduces the amount of unreachable objects in the dump // and makes it easier to browse. HeapDumper dumper(!_all.value() /* request GC if _all is false*/); int res = dumper.dump(_filename.value());
*** 299,309 **** _all("-all", "Inspect all objects, including unreachable objects", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); } ! void ClassHistogramDCmd::execute(TRAPS) { VM_GC_HeapInspection heapop(output(), !_all.value() /* request full gc if false */, true /* need_prologue */); VMThread::execute(&heapop); } --- 317,327 ---- _all("-all", "Inspect all objects, including unreachable objects", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_all); } ! void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) { VM_GC_HeapInspection heapop(output(), !_all.value() /* request full gc if false */, true /* need_prologue */); VMThread::execute(&heapop); }
*** 323,333 **** DCmdWithParser(output, heap), _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_locks); } ! void ThreadDumpDCmd::execute(TRAPS) { // thread stacks VM_PrintThreads op1(output(), _locks.value()); VMThread::execute(&op1); // JNI global handles --- 341,351 ---- DCmdWithParser(output, heap), _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") { _dcmdparser.add_dcmd_option(&_locks); } ! void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) { // thread stacks VM_PrintThreads op1(output(), _locks.value()); VMThread::execute(&op1); // JNI global handles
*** 435,445 **** return 0; } } ! void JMXStartRemoteDCmd::execute(TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke startRemoteManagementAgent(string) method to start --- 453,463 ---- return 0; } } ! void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke startRemoteManagementAgent(string) method to start
*** 494,504 **** DCmd(output, heap_allocated) { // do nothing } ! void JMXStartLocalDCmd::execute(TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke startLocalManagementAgent(void) method to start --- 512,522 ---- DCmd(output, heap_allocated) { // do nothing } ! void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke startLocalManagementAgent(void) method to start
*** 512,522 **** JavaValue result(T_VOID); JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK); } ! void JMXStopRemoteDCmd::execute(TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke stopRemoteManagementAgent method to stop the --- 530,540 ---- JavaValue result(T_VOID); JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK); } ! void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) { ResourceMark rm(THREAD); HandleMark hm(THREAD); // Load and initialize the sun.management.Agent class // invoke stopRemoteManagementAgent method to stop the