| 1 | /* | 
| 2 |  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. | 
| 3 |  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 
| 4 |  * | 
| 5 |  * This code is free software; you can redistribute it and/or modify it | 
| 6 |  * under the terms of the GNU General Public License version 2 only, as | 
| 7 |  * published by the Free Software Foundation. | 
| 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 | #ifndef SHARE_JFR_DCMD_JFRDCMDS_HPP | 
| 26 | #define SHARE_JFR_DCMD_JFRDCMDS_HPP | 
| 27 |  | 
| 28 | #include "services/diagnosticCommand.hpp" | 
| 29 |  | 
| 30 | class JfrDumpFlightRecordingDCmd : public DCmdWithParser { | 
| 31 |  protected: | 
| 32 |   DCmdArgument<char*> _name; | 
| 33 |   DCmdArgument<char*> _filename; | 
| 34 |   DCmdArgument<NanoTimeArgument> _maxage; | 
| 35 |   DCmdArgument<MemorySizeArgument> _maxsize; | 
| 36 |   DCmdArgument<char*> _begin; | 
| 37 |   DCmdArgument<char*> _end; | 
| 38 |   DCmdArgument<bool>  _path_to_gc_roots; | 
| 39 |  | 
| 40 |  public: | 
| 41 |   JfrDumpFlightRecordingDCmd(outputStream* output, bool heap); | 
| 42 |   static const char* name() { | 
| 43 |     return "JFR.dump" ; | 
| 44 |   } | 
| 45 |   static const char* description() { | 
| 46 |     return "Copies contents of a JFR recording to file. Either the name or the recording id must be specified." ; | 
| 47 |   } | 
| 48 |   static const char* impact() { | 
| 49 |     return "Low" ; | 
| 50 |   } | 
| 51 |   static const JavaPermission permission() { | 
| 52 |     JavaPermission p = {"java.lang.management.ManagementPermission" , "monitor" , NULL}; | 
| 53 |     return p; | 
| 54 |   } | 
| 55 |   static int num_arguments(); | 
| 56 |   virtual void execute(DCmdSource source, TRAPS); | 
| 57 | }; | 
| 58 |  | 
| 59 | class JfrCheckFlightRecordingDCmd : public DCmdWithParser { | 
| 60 |  protected: | 
| 61 |   DCmdArgument<char*> _name; | 
| 62 |   DCmdArgument<bool>  _verbose; | 
| 63 |  | 
| 64 |  public: | 
| 65 |   JfrCheckFlightRecordingDCmd(outputStream* output, bool heap); | 
| 66 |   static const char* name() { | 
| 67 |     return "JFR.check" ; | 
| 68 |   } | 
| 69 |   static const char* description() { | 
| 70 |     return "Checks running JFR recording(s)" ; | 
| 71 |   } | 
| 72 |   static const char* impact() { | 
| 73 |     return "Low" ; | 
| 74 |   } | 
| 75 |   static const JavaPermission permission() { | 
| 76 |     JavaPermission p = {"java.lang.management.ManagementPermission" , "monitor" , NULL}; | 
| 77 |     return p; | 
| 78 |   } | 
| 79 |   static int num_arguments(); | 
| 80 |   virtual void execute(DCmdSource source, TRAPS); | 
| 81 | }; | 
| 82 |  | 
| 83 | class JfrStartFlightRecordingDCmd : public DCmdWithParser { | 
| 84 |  protected: | 
| 85 |   DCmdArgument<char*> _name; | 
| 86 |   DCmdArgument<StringArrayArgument*> _settings; | 
| 87 |   DCmdArgument<NanoTimeArgument> _delay; | 
| 88 |   DCmdArgument<NanoTimeArgument> _duration; | 
| 89 |   DCmdArgument<bool> _disk; | 
| 90 |   DCmdArgument<char*> _filename; | 
| 91 |   DCmdArgument<NanoTimeArgument> _maxage; | 
| 92 |   DCmdArgument<MemorySizeArgument> _maxsize; | 
| 93 |   DCmdArgument<bool> _dump_on_exit; | 
| 94 |   DCmdArgument<bool> _path_to_gc_roots; | 
| 95 |  | 
| 96 |  public: | 
| 97 |   JfrStartFlightRecordingDCmd(outputStream* output, bool heap); | 
| 98 |   static const char* name() { | 
| 99 |     return "JFR.start" ; | 
| 100 |   } | 
| 101 |   static const char* description() { | 
| 102 |     return "Starts a new JFR recording" ; | 
| 103 |   } | 
| 104 |   static const char* impact() { | 
| 105 |     return "Medium: Depending on the settings for a recording, the impact can range from low to high." ; | 
| 106 |   } | 
| 107 |   static const JavaPermission permission() { | 
| 108 |     JavaPermission p = {"java.lang.management.ManagementPermission" , "monitor" , NULL}; | 
| 109 |     return p; | 
| 110 |   } | 
| 111 |   static int num_arguments(); | 
| 112 |   virtual void execute(DCmdSource source, TRAPS); | 
| 113 | }; | 
| 114 |  | 
| 115 | class JfrStopFlightRecordingDCmd : public DCmdWithParser { | 
| 116 |  protected: | 
| 117 |   DCmdArgument<char*> _name; | 
| 118 |   DCmdArgument<char*> _filename; | 
| 119 |  | 
| 120 |  public: | 
| 121 |   JfrStopFlightRecordingDCmd(outputStream* output, bool heap); | 
| 122 |   static const char* name() { | 
| 123 |     return "JFR.stop" ; | 
| 124 |   } | 
| 125 |   static const char* description() { | 
| 126 |     return "Stops a JFR recording" ; | 
| 127 |   } | 
| 128 |   static const char* impact() { | 
| 129 |     return "Low" ; | 
| 130 |   } | 
| 131 |   static const JavaPermission permission() { | 
| 132 |     JavaPermission p = {"java.lang.management.ManagementPermission" , "monitor" , NULL}; | 
| 133 |     return p; | 
| 134 |   } | 
| 135 |   static int num_arguments(); | 
| 136 |   virtual void execute(DCmdSource source, TRAPS); | 
| 137 | }; | 
| 138 |  | 
| 139 | class JfrRuntimeOptions; | 
| 140 |  | 
| 141 | class JfrConfigureFlightRecorderDCmd : public DCmdWithParser { | 
| 142 |   friend class JfrOptionSet; | 
| 143 |  protected: | 
| 144 |   DCmdArgument<char*> _repository_path; | 
| 145 |   DCmdArgument<char*> _dump_path; | 
| 146 |   DCmdArgument<jlong> _stack_depth; | 
| 147 |   DCmdArgument<jlong> _global_buffer_count; | 
| 148 |   DCmdArgument<MemorySizeArgument> _global_buffer_size; | 
| 149 |   DCmdArgument<MemorySizeArgument> _thread_buffer_size; | 
| 150 |   DCmdArgument<MemorySizeArgument> _memory_size; | 
| 151 |   DCmdArgument<MemorySizeArgument> _max_chunk_size; | 
| 152 |   DCmdArgument<bool>  _sample_threads; | 
| 153 |  | 
| 154 |  public: | 
| 155 |   JfrConfigureFlightRecorderDCmd(outputStream* output, bool heap); | 
| 156 |   static const char* name() { | 
| 157 |     return "JFR.configure" ; | 
| 158 |   } | 
| 159 |   static const char* description() { | 
| 160 |     return "Configure JFR" ; | 
| 161 |   } | 
| 162 |   static const char* impact() { | 
| 163 |     return "Low" ; | 
| 164 |   } | 
| 165 |   static const JavaPermission permission() { | 
| 166 |     JavaPermission p = {"java.lang.management.ManagementPermission" , "monitor" , NULL}; | 
| 167 |     return p; | 
| 168 |   } | 
| 169 |   static int num_arguments(); | 
| 170 |   virtual void execute(DCmdSource source, TRAPS); | 
| 171 | }; | 
| 172 |  | 
| 173 | bool register_jfr_dcmds(); | 
| 174 |  | 
| 175 | #endif // SHARE_JFR_DCMD_JFRDCMDS_HPP | 
| 176 |  |