< prev index next >

src/share/vm/services/diagnosticCommand.cpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 "oops/objArrayOop.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   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
  54   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  55 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  56   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  57   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  58   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  59 #endif // INCLUDE_SERVICES
  60   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
  61   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false));
  62 
  63   // Enhanced JMX Agent Support
  64   // These commands won't be exported via the DiagnosticCommandMBean until an
  65   // appropriate permission is created for them
  66   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  67   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  68   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));


 659     PUT_OPTION(_jmxremote_login_config);
 660     PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
 661     PUT_OPTION(_jmxremote_ssl_enabled_protocols);
 662     PUT_OPTION(_jmxremote_ssl_need_client_auth);
 663     PUT_OPTION(_jmxremote_ssl_config_file);
 664     PUT_OPTION(_jmxremote_autodiscovery);
 665     PUT_OPTION(_jdp_port);
 666     PUT_OPTION(_jdp_address);
 667     PUT_OPTION(_jdp_source_addr);
 668     PUT_OPTION(_jdp_ttl);
 669     PUT_OPTION(_jdp_pause);
 670     PUT_OPTION(_jdp_name);
 671 
 672 #undef PUT_OPTION
 673 
 674     Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
 675     JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
 676 }
 677 
 678 JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
 679   DCmd(output, heap_allocated)
 680 {
 681   // do nothing
 682 }
 683 
 684 void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {
 685     ResourceMark rm(THREAD);
 686     HandleMark hm(THREAD);
 687 
 688     // Load and initialize the sun.management.Agent class
 689     // invoke startLocalManagementAgent(void) method to start
 690     // the local management server
 691     // throw java.lang.NoSuchMethodError if method doesn't exist
 692 
 693     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 694     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 695     instanceKlassHandle ik (THREAD, k);
 696 
 697     JavaValue result(T_VOID);
 698     JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
 699 }
 700 
 701 
 702 void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {
 703     ResourceMark rm(THREAD);
 704     HandleMark hm(THREAD);
 705 
 706     // Load and initialize the sun.management.Agent class
 707     // invoke stopRemoteManagementAgent method to stop the
 708     // management server
 709     // throw java.lang.NoSuchMethodError if method doesn't exist
 710 
 711     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 712     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 713     instanceKlassHandle ik (THREAD, k);
 714 
 715     JavaValue result(T_VOID);
 716     JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);










 717 }
 718 
 719 void RotateGCLogDCmd::execute(DCmdSource source, TRAPS) {
 720   if (UseGCLogFileRotation) {
 721     VM_RotateGCLog rotateop(output());
 722     VMThread::execute(&rotateop);
 723   } else {
 724     output()->print_cr("Target VM does not support GC log file rotation.");
 725   }
 726 }


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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 "runtime/os.hpp"
  29 #include "services/diagnosticArgument.hpp"
  30 #include "services/diagnosticCommand.hpp"
  31 #include "services/diagnosticFramework.hpp"
  32 #include "services/heapDumper.hpp"
  33 #include "services/management.hpp"
  34 #include "utilities/macros.hpp"
  35 #include "oops/objArrayOop.hpp"
  36 
  37 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  38 
  39 void DCmdRegistrant::register_dcmds(){
  40   // Registration of the diagnostic commands
  41   // First argument specifies which interfaces will export the command
  42   // Second argument specifies if the command is enabled
  43   // Third  argument specifies if the command is hidden
  44   uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI
  45                          | DCmd_Source_MBean;
  46   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false));
  47   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false));
  48   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false));
  49   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
  50   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
  51   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
  52   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
  53   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
  54   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
  55   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
  56   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  57 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  58   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  59   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  60   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  61 #endif // INCLUDE_SERVICES
  62   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
  63   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false));
  64 
  65   // Enhanced JMX Agent Support
  66   // These commands won't be exported via the DiagnosticCommandMBean until an
  67   // appropriate permission is created for them
  68   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  70   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  71   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));


 661     PUT_OPTION(_jmxremote_login_config);
 662     PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
 663     PUT_OPTION(_jmxremote_ssl_enabled_protocols);
 664     PUT_OPTION(_jmxremote_ssl_need_client_auth);
 665     PUT_OPTION(_jmxremote_ssl_config_file);
 666     PUT_OPTION(_jmxremote_autodiscovery);
 667     PUT_OPTION(_jdp_port);
 668     PUT_OPTION(_jdp_address);
 669     PUT_OPTION(_jdp_source_addr);
 670     PUT_OPTION(_jdp_ttl);
 671     PUT_OPTION(_jdp_pause);
 672     PUT_OPTION(_jdp_name);
 673 
 674 #undef PUT_OPTION
 675 
 676     Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
 677     JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
 678 }
 679 
 680 JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
 681   DCmd(output, heap_allocated) {

 682   // do nothing
 683 }
 684 
 685 void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {
 686     ResourceMark rm(THREAD);
 687     HandleMark hm(THREAD);
 688 
 689     // Load and initialize the sun.management.Agent class
 690     // invoke startLocalManagementAgent(void) method to start
 691     // the local management server
 692     // throw java.lang.NoSuchMethodError if method doesn't exist
 693 
 694     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 695     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 696     instanceKlassHandle ik (THREAD, k);
 697 
 698     JavaValue result(T_VOID);
 699     JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
 700 }
 701 

 702 void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {
 703     ResourceMark rm(THREAD);
 704     HandleMark hm(THREAD);
 705 
 706     // Load and initialize the sun.management.Agent class
 707     // invoke stopRemoteManagementAgent method to stop the
 708     // management server
 709     // throw java.lang.NoSuchMethodError if method doesn't exist
 710 
 711     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 712     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 713     instanceKlassHandle ik (THREAD, k);
 714 
 715     JavaValue result(T_VOID);
 716     JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
 717 }
 718 
 719 VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :
 720   DCmd(output, heap_allocated) {
 721   // do nothing
 722 }
 723 
 724 void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {
 725   os::print_dll_info(output());
 726   output()->cr();
 727 }
 728 
 729 void RotateGCLogDCmd::execute(DCmdSource source, TRAPS) {
 730   if (UseGCLogFileRotation) {
 731     VM_RotateGCLog rotateop(output());
 732     VMThread::execute(&rotateop);
 733   } else {
 734     output()->print_cr("Target VM does not support GC log file rotation.");
 735   }
 736 }
< prev index next >