Wed, 10 Apr 2013 08:55:50 -0400
8010151: nsk/regression/b6653214 fails "assert(snapshot != NULL) failed: Worker should not be started"
Summary: Fixed a racing condition when shutting down NMT while worker thread is being started, also fixed a few mis-declared volatile pointers.
Reviewed-by: dholmes, dlong
1 /*
2 * Copyright (c) 2011, 2013, 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 */
25 #ifndef SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
26 #define SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
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 #include "services/diagnosticCommand_ext.hpp"
38 #include "utilities/macros.hpp"
40 class HelpDCmd : public DCmdWithParser {
41 protected:
42 DCmdArgument<bool> _all;
43 DCmdArgument<char*> _cmd;
44 public:
45 HelpDCmd(outputStream* output, bool heap);
46 static const char* name() { return "help"; }
47 static const char* description() {
48 return "For more information about a specific command use 'help <command>'. "
49 "With no argument this will show a list of available commands. "
50 "'help all' will show help for all commands.";
51 }
52 static const char* impact() { return "Low"; }
53 static int num_arguments();
54 virtual void execute(TRAPS);
55 };
57 class VersionDCmd : public DCmd {
58 public:
59 VersionDCmd(outputStream* output, bool heap) : DCmd(output,heap) { }
60 static const char* name() { return "VM.version"; }
61 static const char* description() {
62 return "Print JVM version information.";
63 }
64 static const char* impact() { return "Low"; }
65 static int num_arguments() { return 0; }
66 virtual void execute(TRAPS);
67 };
69 class CommandLineDCmd : public DCmd {
70 public:
71 CommandLineDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
72 static const char* name() { return "VM.command_line"; }
73 static const char* description() {
74 return "Print the command line used to start this VM instance.";
75 }
76 static const char* impact() { return "Low"; }
77 static int num_arguments() { return 0; }
78 virtual void execute(TRAPS) {
79 Arguments::print_on(_output);
80 }
81 };
83 // See also: get_system_properties in attachListener.cpp
84 class PrintSystemPropertiesDCmd : public DCmd {
85 public:
86 PrintSystemPropertiesDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
87 static const char* name() { return "VM.system_properties"; }
88 static const char* description() {
89 return "Print system properties.";
90 }
91 static const char* impact() {
92 return "Low";
93 }
94 static int num_arguments() { return 0; }
95 virtual void execute(TRAPS);
96 };
98 // See also: print_flag in attachListener.cpp
99 class PrintVMFlagsDCmd : public DCmdWithParser {
100 protected:
101 DCmdArgument<bool> _all;
102 public:
103 PrintVMFlagsDCmd(outputStream* output, bool heap);
104 static const char* name() { return "VM.flags"; }
105 static const char* description() {
106 return "Print VM flag options and their current values.";
107 }
108 static const char* impact() {
109 return "Low";
110 }
111 static int num_arguments();
112 virtual void execute(TRAPS);
113 };
115 class VMUptimeDCmd : public DCmdWithParser {
116 protected:
117 DCmdArgument<bool> _date;
118 public:
119 VMUptimeDCmd(outputStream* output, bool heap);
120 static const char* name() { return "VM.uptime"; }
121 static const char* description() {
122 return "Print VM uptime.";
123 }
124 static const char* impact() {
125 return "Low";
126 }
127 static int num_arguments();
128 virtual void execute(TRAPS);
129 };
131 class SystemGCDCmd : public DCmd {
132 public:
133 SystemGCDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
134 static const char* name() { return "GC.run"; }
135 static const char* description() {
136 return "Call java.lang.System.gc().";
137 }
138 static const char* impact() {
139 return "Medium: Depends on Java heap size and content.";
140 }
141 static int num_arguments() { return 0; }
142 virtual void execute(TRAPS);
143 };
145 class RunFinalizationDCmd : public DCmd {
146 public:
147 RunFinalizationDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
148 static const char* name() { return "GC.run_finalization"; }
149 static const char* description() {
150 return "Call java.lang.System.runFinalization().";
151 }
152 static const char* impact() {
153 return "Medium: Depends on Java content.";
154 }
155 static int num_arguments() { return 0; }
156 virtual void execute(TRAPS);
157 };
159 #if INCLUDE_SERVICES // Heap dumping supported
160 // See also: dump_heap in attachListener.cpp
161 class HeapDumpDCmd : public DCmdWithParser {
162 protected:
163 DCmdArgument<char*> _filename;
164 DCmdArgument<bool> _all;
165 public:
166 HeapDumpDCmd(outputStream* output, bool heap);
167 static const char* name() {
168 return "GC.heap_dump";
169 }
170 static const char* description() {
171 return "Generate a HPROF format dump of the Java heap.";
172 }
173 static const char* impact() {
174 return "High: Depends on Java heap size and content. "
175 "Request a full GC unless the '-all' option is specified.";
176 }
177 static int num_arguments();
178 virtual void execute(TRAPS);
179 };
180 #endif // INCLUDE_SERVICES
182 // See also: inspectheap in attachListener.cpp
183 class ClassHistogramDCmd : public DCmdWithParser {
184 protected:
185 DCmdArgument<bool> _all;
186 public:
187 ClassHistogramDCmd(outputStream* output, bool heap);
188 static const char* name() {
189 return "GC.class_histogram";
190 }
191 static const char* description() {
192 return "Provide statistics about the Java heap usage.";
193 }
194 static const char* impact() {
195 return "High: Depends on Java heap size and content.";
196 }
197 static int num_arguments();
198 virtual void execute(TRAPS);
199 };
201 class ClassStatsDCmd : public DCmdWithParser {
202 protected:
203 DCmdArgument<bool> _all;
204 DCmdArgument<bool> _csv;
205 DCmdArgument<bool> _help;
206 DCmdArgument<char*> _columns;
207 public:
208 ClassStatsDCmd(outputStream* output, bool heap);
209 static const char* name() {
210 return "GC.class_stats";
211 }
212 static const char* description() {
213 return "Provide statistics about Java class meta data. Requires -XX:+UnlockDiagnosticVMOptions.";
214 }
215 static const char* impact() {
216 return "High: Depends on Java heap size and content.";
217 }
218 static int num_arguments();
219 virtual void execute(TRAPS);
220 };
222 // See also: thread_dump in attachListener.cpp
223 class ThreadDumpDCmd : public DCmdWithParser {
224 protected:
225 DCmdArgument<bool> _locks;
226 public:
227 ThreadDumpDCmd(outputStream* output, bool heap);
228 static const char* name() { return "Thread.print"; }
229 static const char* description() {
230 return "Print all threads with stacktraces.";
231 }
232 static const char* impact() {
233 return "Medium: Depends on the number of threads.";
234 }
235 static int num_arguments();
236 virtual void execute(TRAPS);
237 };
239 // Enhanced JMX Agent support
241 class JMXStartRemoteDCmd : public DCmdWithParser {
243 // Explicitly list all properties that could be
244 // passed to Agent.startRemoteManagementAgent()
245 // com.sun.management is omitted
247 DCmdArgument<char *> _config_file;
248 DCmdArgument<char *> _jmxremote_port;
249 DCmdArgument<char *> _jmxremote_rmi_port;
250 DCmdArgument<char *> _jmxremote_ssl;
251 DCmdArgument<char *> _jmxremote_registry_ssl;
252 DCmdArgument<char *> _jmxremote_authenticate;
253 DCmdArgument<char *> _jmxremote_password_file;
254 DCmdArgument<char *> _jmxremote_access_file;
255 DCmdArgument<char *> _jmxremote_login_config;
256 DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites;
257 DCmdArgument<char *> _jmxremote_ssl_enabled_protocols;
258 DCmdArgument<char *> _jmxremote_ssl_need_client_auth;
259 DCmdArgument<char *> _jmxremote_ssl_config_file;
261 // JDP support
262 // Keep autodiscovery char* not bool to pass true/false
263 // as property value to java level.
264 DCmdArgument<char *> _jmxremote_autodiscovery;
265 DCmdArgument<jlong> _jdp_port;
266 DCmdArgument<char *> _jdp_address;
267 DCmdArgument<char *> _jdp_source_addr;
268 DCmdArgument<jlong> _jdp_ttl;
269 DCmdArgument<jlong> _jdp_pause;
271 public:
272 JMXStartRemoteDCmd(outputStream *output, bool heap_allocated);
274 static const char *name() {
275 return "ManagementAgent.start";
276 }
278 static const char *description() {
279 return "Start remote management agent.";
280 }
282 static int num_arguments();
284 virtual void execute(TRAPS);
286 };
288 class JMXStartLocalDCmd : public DCmd {
290 // Explicitly request start of local agent,
291 // it will not be started by start dcmd
294 public:
295 JMXStartLocalDCmd(outputStream *output, bool heap_allocated);
297 static const char *name() {
298 return "ManagementAgent.start_local";
299 }
301 static const char *description() {
302 return "Start local management agent.";
303 }
305 virtual void execute(TRAPS);
307 };
309 class JMXStopRemoteDCmd : public DCmd {
310 public:
311 JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) :
312 DCmd(output, heap_allocated) {
313 // Do Nothing
314 }
316 static const char *name() {
317 return "ManagementAgent.stop";
318 }
320 static const char *description() {
321 return "Stop remote management agent.";
322 }
324 virtual void execute(TRAPS);
325 };
327 #endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP