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_VM_JFR_JFRDCMDS_HPP
  26 #define SHARE_VM_JFR_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<bool>  _path_to_gc_roots;
  35 
  36  public:
  37   JfrDumpFlightRecordingDCmd(outputStream* output, bool heap);
  38   static const char* name() {
  39     return "JFR.dump";
  40   }
  41   static const char* description() {
  42     return "Copies contents of a JFR recording to file. Either the name or the recording id must be specified.";
  43   }
  44   static const char* impact() {
  45     return "Low";
  46   }
  47   static const JavaPermission permission() {
  48     JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
  49     return p;
  50   }
  51   static int num_arguments();
  52   virtual void execute(DCmdSource source, TRAPS);
  53 };
  54 
  55 class JfrCheckFlightRecordingDCmd : public DCmdWithParser {
  56  protected:
  57   DCmdArgument<char*> _name;
  58   DCmdArgument<bool>  _verbose;
  59 
  60  public:
  61   JfrCheckFlightRecordingDCmd(outputStream* output, bool heap);
  62   static const char* name() {
  63     return "JFR.check";
  64   }
  65   static const char* description() {
  66     return "Checks running JFR recording(s)";
  67   }
  68   static const char* impact() {
  69     return "Low";
  70   }
  71   static const JavaPermission permission() {
  72     JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
  73     return p;
  74   }
  75   static int num_arguments();
  76   virtual void execute(DCmdSource source, TRAPS);
  77 };
  78 
  79 class JfrStartFlightRecordingDCmd : public DCmdWithParser {
  80  protected:
  81   DCmdArgument<char*> _name;
  82   DCmdArgument<StringArrayArgument*> _settings;
  83   DCmdArgument<NanoTimeArgument> _delay;
  84   DCmdArgument<NanoTimeArgument> _duration;
  85   DCmdArgument<bool> _disk;
  86   DCmdArgument<char*> _filename;
  87   DCmdArgument<NanoTimeArgument> _maxage;
  88   DCmdArgument<MemorySizeArgument> _maxsize;
  89   DCmdArgument<bool> _dump_on_exit;
  90   DCmdArgument<bool> _path_to_gc_roots;
  91 
  92  public:
  93   JfrStartFlightRecordingDCmd(outputStream* output, bool heap);
  94   static const char* name() {
  95     return "JFR.start";
  96   }
  97   static const char* description() {
  98     return "Starts a new JFR recording";
  99   }
 100   static const char* impact() {
 101     return "Medium: Depending on the settings for a recording, the impact can range from low to high.";
 102   }
 103   static const JavaPermission permission() {
 104     JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
 105     return p;
 106   }
 107   static int num_arguments();
 108   virtual void execute(DCmdSource source, TRAPS);
 109 };
 110 
 111 class JfrStopFlightRecordingDCmd : public DCmdWithParser {
 112  protected:
 113   DCmdArgument<char*> _name;
 114   DCmdArgument<char*> _filename;
 115 
 116  public:
 117   JfrStopFlightRecordingDCmd(outputStream* output, bool heap);
 118   static const char* name() {
 119     return "JFR.stop";
 120   }
 121   static const char* description() {
 122     return "Stops a JFR recording";
 123   }
 124   static const char* impact() {
 125     return "Low";
 126   }
 127   static const JavaPermission permission() {
 128     JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
 129     return p;
 130   }
 131   static int num_arguments();
 132   virtual void execute(DCmdSource source, TRAPS);
 133 };
 134 
 135 class JfrRuntimeOptions;
 136 
 137 class JfrConfigureFlightRecorderDCmd : public DCmdWithParser {
 138   friend class JfrOptionSet;
 139  protected:
 140   DCmdArgument<char*> _repository_path;
 141   DCmdArgument<char*> _dump_path;
 142   DCmdArgument<jlong> _stack_depth;
 143   DCmdArgument<jlong> _global_buffer_count;
 144   DCmdArgument<jlong> _global_buffer_size;
 145   DCmdArgument<jlong> _thread_buffer_size;
 146   DCmdArgument<jlong> _memory_size;
 147   DCmdArgument<jlong> _max_chunk_size;
 148   DCmdArgument<bool>  _sample_threads;
 149 
 150  public:
 151   JfrConfigureFlightRecorderDCmd(outputStream* output, bool heap);
 152   static const char* name() {
 153     return "JFR.configure";
 154   }
 155   static const char* description() {
 156     return "Configure JFR";
 157   }
 158   static const char* impact() {
 159     return "Low";
 160   }
 161   static const JavaPermission permission() {
 162     JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
 163     return p;
 164   }
 165   static int num_arguments();
 166   virtual void execute(DCmdSource source, TRAPS);
 167 };
 168 
 169 bool register_jfr_dcmds();
 170 
 171 #endif // SHARE_VM_JFR_JFRDCMDS_HPP