src/share/vm/services/diagnosticCommand.hpp

Mon, 09 Jan 2012 10:27:24 +0100

author
fparain
date
Mon, 09 Jan 2012 10:27:24 +0100
changeset 3402
4f25538b54c9
parent 3329
3b688d6ff3d0
child 3478
a42c07c38c47
permissions
-rw-r--r--

7120511: Add diagnostic commands
Reviewed-by: acorn, phh, dcubed, sspitsyn

fparain@3329 1 /*
fparain@3329 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
fparain@3329 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fparain@3329 4 *
fparain@3329 5 * This code is free software; you can redistribute it and/or modify it
fparain@3329 6 * under the terms of the GNU General Public License version 2 only, as
fparain@3329 7 * published by the Free Software Foundation.
fparain@3329 8 *
fparain@3329 9 * This code is distributed in the hope that it will be useful, but WITHOUT
fparain@3329 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fparain@3329 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fparain@3329 12 * version 2 for more details (a copy is included in the LICENSE file that
fparain@3329 13 * accompanied this code).
fparain@3329 14 *
fparain@3329 15 * You should have received a copy of the GNU General Public License version
fparain@3329 16 * 2 along with this work; if not, write to the Free Software Foundation,
fparain@3329 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fparain@3329 18 *
fparain@3329 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fparain@3329 20 * or visit www.oracle.com if you need additional information or have any
fparain@3329 21 * questions.
fparain@3329 22 *
fparain@3329 23 */
fparain@3329 24
fparain@3329 25 #ifndef SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
fparain@3329 26 #define SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
fparain@3329 27
fparain@3329 28 #include "runtime/arguments.hpp"
fparain@3329 29 #include "classfile/vmSymbols.hpp"
fparain@3329 30 #include "utilities/ostream.hpp"
fparain@3329 31 #include "runtime/vm_version.hpp"
fparain@3329 32 #include "runtime/vmThread.hpp"
fparain@3329 33 #include "runtime/os.hpp"
fparain@3329 34 #include "services/diagnosticArgument.hpp"
fparain@3329 35 #include "services/diagnosticCommand.hpp"
fparain@3329 36 #include "services/diagnosticFramework.hpp"
fparain@3329 37
fparain@3402 38 class HelpDCmd : public DCmdWithParser {
fparain@3329 39 protected:
fparain@3329 40 DCmdArgument<bool> _all;
fparain@3329 41 DCmdArgument<char*> _cmd;
fparain@3329 42 public:
fparain@3329 43 HelpDCmd(outputStream* output, bool heap);
fparain@3329 44 static const char* name() { return "help"; }
fparain@3329 45 static const char* description() {
fparain@3329 46 return "For more information about a specific command use 'help <command>'. "
fparain@3329 47 "With no argument this will show a list of available commands. "
fparain@3329 48 "'help all' will show help for all commands.";
fparain@3329 49 }
fparain@3329 50 static const char* impact() { return "Low: "; }
fparain@3329 51 static int num_arguments();
fparain@3329 52 virtual void execute(TRAPS);
fparain@3329 53 };
fparain@3329 54
fparain@3329 55 class VersionDCmd : public DCmd {
fparain@3329 56 public:
fparain@3329 57 VersionDCmd(outputStream* output, bool heap) : DCmd(output,heap) { }
fparain@3329 58 static const char* name() { return "VM.version"; }
fparain@3329 59 static const char* description() {
fparain@3329 60 return "Print JVM version information.";
fparain@3329 61 }
fparain@3329 62 static const char* impact() { return "Low: "; }
fparain@3329 63 static int num_arguments() { return 0; }
fparain@3329 64 virtual void execute(TRAPS);
fparain@3402 65 };
fparain@3402 66
fparain@3402 67 class CommandLineDCmd : public DCmd {
fparain@3402 68 public:
fparain@3402 69 CommandLineDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
fparain@3402 70 static const char* name() { return "VM.command_line"; }
fparain@3402 71 static const char* description() {
fparain@3402 72 return "Print the command line used to start this VM instance.";
fparain@3402 73 }
fparain@3402 74 static const char* impact() { return "Low: "; }
fparain@3402 75 static int num_arguments() { return 0; }
fparain@3402 76 virtual void execute(TRAPS) {
fparain@3402 77 Arguments::print_on(_output);
fparain@3402 78 }
fparain@3402 79 };
fparain@3402 80
fparain@3402 81 // See also: get_system_properties in attachListener.cpp
fparain@3402 82 class PrintSystemPropertiesDCmd : public DCmd {
fparain@3402 83 public:
fparain@3402 84 PrintSystemPropertiesDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
fparain@3402 85 static const char* name() { return "VM.system_properties"; }
fparain@3402 86 static const char* description() {
fparain@3402 87 return "Print system properties.";
fparain@3402 88 }
fparain@3402 89 static const char* impact() {
fparain@3402 90 return "Low: ";
fparain@3402 91 }
fparain@3402 92 static int num_arguments() { return 0; }
fparain@3402 93 virtual void execute(TRAPS);
fparain@3402 94 };
fparain@3402 95
fparain@3402 96 // See also: print_flag in attachListener.cpp
fparain@3402 97 class PrintVMFlagsDCmd : public DCmdWithParser {
fparain@3402 98 protected:
fparain@3402 99 DCmdArgument<bool> _all;
fparain@3402 100 public:
fparain@3402 101 PrintVMFlagsDCmd(outputStream* output, bool heap);
fparain@3402 102 static const char* name() { return "VM.flags"; }
fparain@3402 103 static const char* description() {
fparain@3402 104 return "Print VM flag options and their current values.";
fparain@3402 105 }
fparain@3402 106 static const char* impact() {
fparain@3402 107 return "Low: ";
fparain@3402 108 }
fparain@3402 109 static int num_arguments();
fparain@3402 110 virtual void execute(TRAPS);
fparain@3402 111 };
fparain@3402 112
fparain@3402 113 class VMUptimeDCmd : public DCmdWithParser {
fparain@3402 114 protected:
fparain@3402 115 DCmdArgument<bool> _date;
fparain@3402 116 public:
fparain@3402 117 VMUptimeDCmd(outputStream* output, bool heap);
fparain@3402 118 static const char* name() { return "VM.uptime"; }
fparain@3402 119 static const char* description() {
fparain@3402 120 return "Print VM uptime.";
fparain@3402 121 }
fparain@3402 122 static const char* impact() {
fparain@3402 123 return "Low: ";
fparain@3402 124 }
fparain@3402 125 static int num_arguments();
fparain@3402 126 virtual void execute(TRAPS);
fparain@3402 127 };
fparain@3402 128
fparain@3402 129 class SystemGCDCmd : public DCmd {
fparain@3402 130 public:
fparain@3402 131 SystemGCDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
fparain@3402 132 static const char* name() { return "GC.run"; }
fparain@3402 133 static const char* description() {
fparain@3402 134 return "Call java.lang.System.gc().";
fparain@3402 135 }
fparain@3402 136 static const char* impact() {
fparain@3402 137 return "Medium: Depends on Java heap size and content.";
fparain@3402 138 }
fparain@3402 139 static int num_arguments() { return 0; }
fparain@3402 140 virtual void execute(TRAPS);
fparain@3402 141 };
fparain@3402 142
fparain@3402 143 class RunFinalizationDCmd : public DCmd {
fparain@3402 144 public:
fparain@3402 145 RunFinalizationDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
fparain@3402 146 static const char* name() { return "GC.run_finalization"; }
fparain@3402 147 static const char* description() {
fparain@3402 148 return "Call java.lang.System.runFinalization().";
fparain@3402 149 }
fparain@3402 150 static const char* impact() {
fparain@3402 151 return "Medium: Depends on Java content.";
fparain@3402 152 }
fparain@3402 153 static int num_arguments() { return 0; }
fparain@3402 154 virtual void execute(TRAPS);
fparain@3402 155 };
fparain@3402 156
fparain@3402 157 #ifndef SERVICES_KERNEL // Heap dumping not supported
fparain@3402 158 // See also: dump_heap in attachListener.cpp
fparain@3402 159 class HeapDumpDCmd : public DCmdWithParser {
fparain@3402 160 protected:
fparain@3402 161 DCmdArgument<char*> _filename;
fparain@3402 162 DCmdArgument<bool> _all;
fparain@3402 163 public:
fparain@3402 164 HeapDumpDCmd(outputStream* output, bool heap);
fparain@3402 165 static const char* name() {
fparain@3402 166 return "GC.heap_dump";
fparain@3402 167 }
fparain@3402 168 static const char* description() {
fparain@3402 169 return "Generate a HPROF format dump of the Java heap.";
fparain@3402 170 }
fparain@3402 171 static const char* impact() {
fparain@3402 172 return "High: Depends on Java heap size and content. "
fparain@3402 173 "Request a full GC unless the '-all' option is specified.";
fparain@3402 174 }
fparain@3402 175 static int num_arguments();
fparain@3402 176 virtual void execute(TRAPS);
fparain@3402 177 };
fparain@3402 178 #endif // SERVICES_KERNEL
fparain@3402 179
fparain@3402 180 // See also: inspeactheap in attachListener.cpp
fparain@3402 181 class ClassHistogramDCmd : public DCmdWithParser {
fparain@3402 182 protected:
fparain@3402 183 DCmdArgument<bool> _all;
fparain@3402 184 public:
fparain@3402 185 ClassHistogramDCmd(outputStream* output, bool heap);
fparain@3402 186 static const char* name() {
fparain@3402 187 return "GC.class_histogram";
fparain@3402 188 }
fparain@3402 189 static const char* description() {
fparain@3402 190 return "Provide statistics about the Java heap usage.";
fparain@3402 191 }
fparain@3402 192 static const char* impact() {
fparain@3402 193 return "High: Depends on Java heap size and content.";
fparain@3402 194 }
fparain@3402 195 static int num_arguments();
fparain@3402 196 virtual void execute(TRAPS);
fparain@3402 197 };
fparain@3402 198
fparain@3402 199 // See also: thread_dump in attachListener.cpp
fparain@3402 200 class ThreadDumpDCmd : public DCmdWithParser {
fparain@3402 201 protected:
fparain@3402 202 DCmdArgument<bool> _locks;
fparain@3402 203 public:
fparain@3402 204 ThreadDumpDCmd(outputStream* output, bool heap);
fparain@3402 205 static const char* name() { return "Thread.print"; }
fparain@3402 206 static const char* description() {
fparain@3402 207 return "Print all threads with stacktraces.";
fparain@3402 208 }
fparain@3402 209 static const char* impact() {
fparain@3402 210 return "Medium: Depends on the number of threads.";
fparain@3402 211 }
fparain@3402 212 static int num_arguments();
fparain@3402 213 virtual void execute(TRAPS);
fparain@3329 214 };
fparain@3329 215
fparain@3329 216 #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP

mercurial