src/share/vm/services/diagnosticCommand.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/services

src/share/vm/services/diagnosticCommand.cpp

Print this page
rev 9030 : 8137167: JEP165: Compiler Control: Implementation task
Summary:
Reviewed-by:


   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 "classfile/classLoaderStats.hpp"
  27 #include "classfile/compactHashtable.hpp"


  28 #include "gc/shared/vmGCOperations.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "runtime/javaCalls.hpp"
  32 #include "runtime/os.hpp"
  33 #include "services/diagnosticArgument.hpp"
  34 #include "services/diagnosticCommand.hpp"
  35 #include "services/diagnosticFramework.hpp"
  36 #include "services/heapDumper.hpp"
  37 #include "services/management.hpp"
  38 #include "services/writeableFlags.hpp"
  39 #include "utilities/macros.hpp"
  40 #include "oops/objArrayOop.inline.hpp"
  41 
  42 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  43 
  44 void DCmdRegistrant::register_dcmds(){
  45   // Registration of the diagnostic commands
  46   // First argument specifies which interfaces will export the command
  47   // Second argument specifies if the command is enabled


  62   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  63 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  64   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  65   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  66   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  67   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
  68   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
  70 #endif // INCLUDE_SERVICES
  71 #if INCLUDE_JVMTI
  72   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
  73 #endif // INCLUDE_JVMTI
  74   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
  75   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(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   // Enhanced JMX Agent Support
  83   // These commands won't be exported via the DiagnosticCommandMBean until an
  84   // appropriate permission is created for them
  85   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  86   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  87   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  88   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
  89   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
  90 
  91 }
  92 
  93 #ifndef HAVE_EXTRA_DCMD
  94 void DCmdRegistrant::register_dcmds_ext(){
  95    // Do nothing here
  96 }
  97 #endif
  98 
  99 
 100 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
 101   _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),


 817   } else {
 818     output()->print_cr("Target VM does not support GC log file rotation.");
 819   }
 820 }
 821 
 822 void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
 823   VM_PrintCompileQueue printCompileQueueOp(output());
 824   VMThread::execute(&printCompileQueueOp);
 825 }
 826 
 827 void CodeListDCmd::execute(DCmdSource source, TRAPS) {
 828   VM_PrintCodeList printCodeListOp(output());
 829   VMThread::execute(&printCodeListOp);
 830 }
 831 
 832 void CodeCacheDCmd::execute(DCmdSource source, TRAPS) {
 833   VM_PrintCodeCache printCodeCacheOp(output());
 834   VMThread::execute(&printCodeCacheOp);
 835 }
 836 


































 837 #if INCLUDE_SERVICES
 838 ClassHierarchyDCmd::ClassHierarchyDCmd(outputStream* output, bool heap) :
 839                                        DCmdWithParser(output, heap),
 840   _print_interfaces("-i", "Inherited interfaces should be printed.", "BOOLEAN", false, "false"),
 841   _print_subclasses("-s", "If a classname is specified, print its subclasses. "
 842                     "Otherwise only its superclasses are printed.", "BOOLEAN", false, "false"),
 843   _classname("classname", "Name of class whose hierarchy should be printed. "
 844              "If not specified, all class hierarchies are printed.",
 845              "STRING", false) {
 846   _dcmdparser.add_dcmd_option(&_print_interfaces);
 847   _dcmdparser.add_dcmd_option(&_print_subclasses);
 848   _dcmdparser.add_dcmd_argument(&_classname);
 849 }
 850 
 851 void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
 852   VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
 853                                                _print_subclasses.value(), _classname.value());
 854   VMThread::execute(&printClassHierarchyOp);
 855 }
 856 




   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 "classfile/classLoaderStats.hpp"
  27 #include "classfile/compactHashtable.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "compiler/directivesParser.hpp"
  30 #include "gc/shared/vmGCOperations.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/globals.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/os.hpp"
  35 #include "services/diagnosticArgument.hpp"
  36 #include "services/diagnosticCommand.hpp"
  37 #include "services/diagnosticFramework.hpp"
  38 #include "services/heapDumper.hpp"
  39 #include "services/management.hpp"
  40 #include "services/writeableFlags.hpp"
  41 #include "utilities/macros.hpp"
  42 #include "oops/objArrayOop.inline.hpp"
  43 
  44 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  45 
  46 void DCmdRegistrant::register_dcmds(){
  47   // Registration of the diagnostic commands
  48   // First argument specifies which interfaces will export the command
  49   // Second argument specifies if the command is enabled


  64   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  65 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  66   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  67   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  68   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  69   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
  70   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
  71   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
  72 #endif // INCLUDE_SERVICES
  73 #if INCLUDE_JVMTI
  74   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(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<RotateGCLogDCmd>(full_export, true, false));
  78   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
  79   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
  80   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
  81   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
  82   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
  83 
  84   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
  85   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
  86   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
  87   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
  88 
  89   // Enhanced JMX Agent Support
  90   // These commands won't be exported via the DiagnosticCommandMBean until an
  91   // appropriate permission is created for them
  92   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
  93   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
  94   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
  95   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
  96   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
  97 
  98 }
  99 
 100 #ifndef HAVE_EXTRA_DCMD
 101 void DCmdRegistrant::register_dcmds_ext(){
 102    // Do nothing here
 103 }
 104 #endif
 105 
 106 
 107 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
 108   _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),


 824   } else {
 825     output()->print_cr("Target VM does not support GC log file rotation.");
 826   }
 827 }
 828 
 829 void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
 830   VM_PrintCompileQueue printCompileQueueOp(output());
 831   VMThread::execute(&printCompileQueueOp);
 832 }
 833 
 834 void CodeListDCmd::execute(DCmdSource source, TRAPS) {
 835   VM_PrintCodeList printCodeListOp(output());
 836   VMThread::execute(&printCodeListOp);
 837 }
 838 
 839 void CodeCacheDCmd::execute(DCmdSource source, TRAPS) {
 840   VM_PrintCodeCache printCodeCacheOp(output());
 841   VMThread::execute(&printCodeCacheOp);
 842 }
 843 
 844 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) {
 845   DirectivesStack::print(output());
 846 }
 847 
 848 CompilerDirectivesAddDCmd::CompilerDirectivesAddDCmd(outputStream* output, bool heap) :
 849                            DCmdWithParser(output, heap),
 850   _filename("filename","Name of the directives file", "STRING",true) {
 851   _dcmdparser.add_dcmd_argument(&_filename);
 852 }
 853 
 854 void CompilerDirectivesAddDCmd::execute(DCmdSource source, TRAPS) {
 855   if (!DirectivesParser::parse_from_file(_filename.value())) {
 856     output()->print_cr("Could not load compiler directives file.");
 857   }
 858 }
 859 
 860 int CompilerDirectivesAddDCmd::num_arguments() {
 861   ResourceMark rm;
 862   CompilerDirectivesAddDCmd* dcmd = new CompilerDirectivesAddDCmd(NULL, false);
 863   if (dcmd != NULL) {
 864     DCmdMark mark(dcmd);
 865     return dcmd->_dcmdparser.num_arguments();
 866   } else {
 867     return 0;
 868   }
 869 }
 870 
 871 void CompilerDirectivesRemoveDCmd::execute(DCmdSource source, TRAPS) {
 872   DirectivesStack::pop();
 873 }
 874 
 875 void CompilerDirectivesClearDCmd::execute(DCmdSource source, TRAPS) {
 876   DirectivesStack::clear();
 877 }
 878 #if INCLUDE_SERVICES
 879 ClassHierarchyDCmd::ClassHierarchyDCmd(outputStream* output, bool heap) :
 880                                        DCmdWithParser(output, heap),
 881   _print_interfaces("-i", "Inherited interfaces should be printed.", "BOOLEAN", false, "false"),
 882   _print_subclasses("-s", "If a classname is specified, print its subclasses. "
 883                     "Otherwise only its superclasses are printed.", "BOOLEAN", false, "false"),
 884   _classname("classname", "Name of class whose hierarchy should be printed. "
 885              "If not specified, all class hierarchies are printed.",
 886              "STRING", false) {
 887   _dcmdparser.add_dcmd_option(&_print_interfaces);
 888   _dcmdparser.add_dcmd_option(&_print_subclasses);
 889   _dcmdparser.add_dcmd_argument(&_classname);
 890 }
 891 
 892 void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
 893   VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
 894                                                _print_subclasses.value(), _classname.value());
 895   VMThread::execute(&printClassHierarchyOp);
 896 }
 897 


src/share/vm/services/diagnosticCommand.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File