4133
|
1 /*
|
|
2 * Copyright (c) 2011, 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_SERVICES_DIAGNOSTICCOMMAND_HPP
|
|
26 #define SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
|
|
27
|
|
28 #include "runtime/arguments.hpp"
|
|
29 #include "classfile/vmSymbols.hpp"
|
|
30 #include "utilities/ostream.hpp"
|
|
31 #include "runtime/vm_version.hpp"
|
|
32 #include "runtime/vmThread.hpp"
|
|
33 #include "runtime/os.hpp"
|
|
34 #include "services/diagnosticArgument.hpp"
|
|
35 #include "services/diagnosticCommand.hpp"
|
|
36 #include "services/diagnosticFramework.hpp"
|
|
37
|
4773
|
38 class HelpDCmd : public DCmdWithParser {
|
4133
|
39 protected:
|
|
40 DCmdArgument<bool> _all;
|
|
41 DCmdArgument<char*> _cmd;
|
|
42 public:
|
|
43 HelpDCmd(outputStream* output, bool heap);
|
|
44 static const char* name() { return "help"; }
|
|
45 static const char* description() {
|
|
46 return "For more information about a specific command use 'help <command>'. "
|
|
47 "With no argument this will show a list of available commands. "
|
|
48 "'help all' will show help for all commands.";
|
|
49 }
|
|
50 static const char* impact() { return "Low: "; }
|
|
51 static int num_arguments();
|
|
52 virtual void execute(TRAPS);
|
|
53 };
|
|
54
|
|
55 class VersionDCmd : public DCmd {
|
|
56 public:
|
|
57 VersionDCmd(outputStream* output, bool heap) : DCmd(output,heap) { }
|
|
58 static const char* name() { return "VM.version"; }
|
|
59 static const char* description() {
|
|
60 return "Print JVM version information.";
|
|
61 }
|
|
62 static const char* impact() { return "Low: "; }
|
|
63 static int num_arguments() { return 0; }
|
4773
|
64 virtual void execute(TRAPS);
|
|
65 };
|
|
66
|
|
67 class CommandLineDCmd : public DCmd {
|
|
68 public:
|
|
69 CommandLineDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
|
|
70 static const char* name() { return "VM.command_line"; }
|
|
71 static const char* description() {
|
|
72 return "Print the command line used to start this VM instance.";
|
|
73 }
|
|
74 static const char* impact() { return "Low: "; }
|
|
75 static int num_arguments() { return 0; }
|
|
76 virtual void execute(TRAPS) {
|
|
77 Arguments::print_on(_output);
|
|
78 }
|
|
79 };
|
|
80
|
|
81 // See also: get_system_properties in attachListener.cpp
|
|
82 class PrintSystemPropertiesDCmd : public DCmd {
|
|
83 public:
|
|
84 PrintSystemPropertiesDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
|
|
85 static const char* name() { return "VM.system_properties"; }
|
|
86 static const char* description() {
|
|
87 return "Print system properties.";
|
|
88 }
|
|
89 static const char* impact() {
|
|
90 return "Low: ";
|
|
91 }
|
|
92 static int num_arguments() { return 0; }
|
|
93 virtual void execute(TRAPS);
|
|
94 };
|
|
95
|
|
96 // See also: print_flag in attachListener.cpp
|
|
97 class PrintVMFlagsDCmd : public DCmdWithParser {
|
|
98 protected:
|
|
99 DCmdArgument<bool> _all;
|
|
100 public:
|
|
101 PrintVMFlagsDCmd(outputStream* output, bool heap);
|
|
102 static const char* name() { return "VM.flags"; }
|
|
103 static const char* description() {
|
|
104 return "Print VM flag options and their current values.";
|
|
105 }
|
|
106 static const char* impact() {
|
|
107 return "Low: ";
|
|
108 }
|
|
109 static int num_arguments();
|
|
110 virtual void execute(TRAPS);
|
|
111 };
|
|
112
|
|
113 class VMUptimeDCmd : public DCmdWithParser {
|
|
114 protected:
|
|
115 DCmdArgument<bool> _date;
|
|
116 public:
|
|
117 VMUptimeDCmd(outputStream* output, bool heap);
|
|
118 static const char* name() { return "VM.uptime"; }
|
|
119 static const char* description() {
|
|
120 return "Print VM uptime.";
|
|
121 }
|
|
122 static const char* impact() {
|
|
123 return "Low: ";
|
|
124 }
|
|
125 static int num_arguments();
|
4133
|
126 virtual void execute(TRAPS);
|
4773
|
127 };
|
|
128
|
|
129 class SystemGCDCmd : public DCmd {
|
|
130 public:
|
|
131 SystemGCDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
|
|
132 static const char* name() { return "GC.run"; }
|
|
133 static const char* description() {
|
|
134 return "Call java.lang.System.gc().";
|
|
135 }
|
|
136 static const char* impact() {
|
|
137 return "Medium: Depends on Java heap size and content.";
|
|
138 }
|
|
139 static int num_arguments() { return 0; }
|
|
140 virtual void execute(TRAPS);
|
|
141 };
|
|
142
|
|
143 class RunFinalizationDCmd : public DCmd {
|
|
144 public:
|
|
145 RunFinalizationDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
|
|
146 static const char* name() { return "GC.run_finalization"; }
|
|
147 static const char* description() {
|
|
148 return "Call java.lang.System.runFinalization().";
|
|
149 }
|
|
150 static const char* impact() {
|
|
151 return "Medium: Depends on Java content.";
|
|
152 }
|
|
153 static int num_arguments() { return 0; }
|
|
154 virtual void execute(TRAPS);
|
|
155 };
|
|
156
|
|
157 #ifndef SERVICES_KERNEL // Heap dumping not supported
|
|
158 // See also: dump_heap in attachListener.cpp
|
|
159 class HeapDumpDCmd : public DCmdWithParser {
|
|
160 protected:
|
|
161 DCmdArgument<char*> _filename;
|
|
162 DCmdArgument<bool> _all;
|
|
163 public:
|
|
164 HeapDumpDCmd(outputStream* output, bool heap);
|
|
165 static const char* name() {
|
|
166 return "GC.heap_dump";
|
|
167 }
|
|
168 static const char* description() {
|
|
169 return "Generate a HPROF format dump of the Java heap.";
|
|
170 }
|
|
171 static const char* impact() {
|
|
172 return "High: Depends on Java heap size and content. "
|
|
173 "Request a full GC unless the '-all' option is specified.";
|
|
174 }
|
|
175 static int num_arguments();
|
|
176 virtual void execute(TRAPS);
|
|
177 };
|
|
178 #endif // SERVICES_KERNEL
|
|
179
|
|
180 // See also: inspeactheap in attachListener.cpp
|
|
181 class ClassHistogramDCmd : public DCmdWithParser {
|
|
182 protected:
|
|
183 DCmdArgument<bool> _all;
|
|
184 public:
|
|
185 ClassHistogramDCmd(outputStream* output, bool heap);
|
|
186 static const char* name() {
|
|
187 return "GC.class_histogram";
|
|
188 }
|
|
189 static const char* description() {
|
|
190 return "Provide statistics about the Java heap usage.";
|
|
191 }
|
|
192 static const char* impact() {
|
|
193 return "High: Depends on Java heap size and content.";
|
|
194 }
|
|
195 static int num_arguments();
|
|
196 virtual void execute(TRAPS);
|
|
197 };
|
|
198
|
|
199 // See also: thread_dump in attachListener.cpp
|
|
200 class ThreadDumpDCmd : public DCmdWithParser {
|
|
201 protected:
|
|
202 DCmdArgument<bool> _locks;
|
|
203 public:
|
|
204 ThreadDumpDCmd(outputStream* output, bool heap);
|
|
205 static const char* name() { return "Thread.print"; }
|
|
206 static const char* description() {
|
|
207 return "Print all threads with stacktraces.";
|
|
208 }
|
|
209 static const char* impact() {
|
|
210 return "Medium: Depends on the number of threads.";
|
|
211 }
|
|
212 static int num_arguments();
|
|
213 virtual void execute(TRAPS);
|
4133
|
214 };
|
|
215
|
|
216 #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
|