1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/services/diagnosticCommand.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,380 @@ 1.4 +/* 1.5 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP 1.29 +#define SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP 1.30 + 1.31 +#include "runtime/arguments.hpp" 1.32 +#include "classfile/vmSymbols.hpp" 1.33 +#include "utilities/ostream.hpp" 1.34 +#include "runtime/vm_version.hpp" 1.35 +#include "runtime/vmThread.hpp" 1.36 +#include "runtime/os.hpp" 1.37 +#include "services/diagnosticArgument.hpp" 1.38 +#include "services/diagnosticCommand.hpp" 1.39 +#include "services/diagnosticFramework.hpp" 1.40 +#include "services/diagnosticCommand_ext.hpp" 1.41 +#include "utilities/macros.hpp" 1.42 + 1.43 +class HelpDCmd : public DCmdWithParser { 1.44 +protected: 1.45 + DCmdArgument<bool> _all; 1.46 + DCmdArgument<char*> _cmd; 1.47 +public: 1.48 + HelpDCmd(outputStream* output, bool heap); 1.49 + static const char* name() { return "help"; } 1.50 + static const char* description() { 1.51 + return "For more information about a specific command use 'help <command>'. " 1.52 + "With no argument this will show a list of available commands. " 1.53 + "'help all' will show help for all commands."; 1.54 + } 1.55 + static const char* impact() { return "Low"; } 1.56 + static int num_arguments(); 1.57 + virtual void execute(DCmdSource source, TRAPS); 1.58 +}; 1.59 + 1.60 +class VersionDCmd : public DCmd { 1.61 +public: 1.62 + VersionDCmd(outputStream* output, bool heap) : DCmd(output,heap) { } 1.63 + static const char* name() { return "VM.version"; } 1.64 + static const char* description() { 1.65 + return "Print JVM version information."; 1.66 + } 1.67 + static const char* impact() { return "Low"; } 1.68 + static const JavaPermission permission() { 1.69 + JavaPermission p = {"java.util.PropertyPermission", 1.70 + "java.vm.version", "read"}; 1.71 + return p; 1.72 + } 1.73 + static int num_arguments() { return 0; } 1.74 + virtual void execute(DCmdSource source, TRAPS); 1.75 +}; 1.76 + 1.77 +class CommandLineDCmd : public DCmd { 1.78 +public: 1.79 + CommandLineDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } 1.80 + static const char* name() { return "VM.command_line"; } 1.81 + static const char* description() { 1.82 + return "Print the command line used to start this VM instance."; 1.83 + } 1.84 + static const char* impact() { return "Low"; } 1.85 + static const JavaPermission permission() { 1.86 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.87 + "monitor", NULL}; 1.88 + return p; 1.89 + } 1.90 + static int num_arguments() { return 0; } 1.91 + virtual void execute(DCmdSource source, TRAPS) { 1.92 + Arguments::print_on(_output); 1.93 + } 1.94 +}; 1.95 + 1.96 +// See also: get_system_properties in attachListener.cpp 1.97 +class PrintSystemPropertiesDCmd : public DCmd { 1.98 +public: 1.99 + PrintSystemPropertiesDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } 1.100 + static const char* name() { return "VM.system_properties"; } 1.101 + static const char* description() { 1.102 + return "Print system properties."; 1.103 + } 1.104 + static const char* impact() { 1.105 + return "Low"; 1.106 + } 1.107 + static const JavaPermission permission() { 1.108 + JavaPermission p = {"java.util.PropertyPermission", 1.109 + "*", "read"}; 1.110 + return p; 1.111 + } 1.112 + static int num_arguments() { return 0; } 1.113 + virtual void execute(DCmdSource source, TRAPS); 1.114 +}; 1.115 + 1.116 +// See also: print_flag in attachListener.cpp 1.117 +class PrintVMFlagsDCmd : public DCmdWithParser { 1.118 +protected: 1.119 + DCmdArgument<bool> _all; 1.120 +public: 1.121 + PrintVMFlagsDCmd(outputStream* output, bool heap); 1.122 + static const char* name() { return "VM.flags"; } 1.123 + static const char* description() { 1.124 + return "Print VM flag options and their current values."; 1.125 + } 1.126 + static const char* impact() { 1.127 + return "Low"; 1.128 + } 1.129 + static const JavaPermission permission() { 1.130 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.131 + "monitor", NULL}; 1.132 + return p; 1.133 + } 1.134 + static int num_arguments(); 1.135 + virtual void execute(DCmdSource source, TRAPS); 1.136 +}; 1.137 + 1.138 +class VMUptimeDCmd : public DCmdWithParser { 1.139 +protected: 1.140 + DCmdArgument<bool> _date; 1.141 +public: 1.142 + VMUptimeDCmd(outputStream* output, bool heap); 1.143 + static const char* name() { return "VM.uptime"; } 1.144 + static const char* description() { 1.145 + return "Print VM uptime."; 1.146 + } 1.147 + static const char* impact() { 1.148 + return "Low"; 1.149 + } 1.150 + static int num_arguments(); 1.151 + virtual void execute(DCmdSource source, TRAPS); 1.152 +}; 1.153 + 1.154 +class SystemGCDCmd : public DCmd { 1.155 +public: 1.156 + SystemGCDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } 1.157 + static const char* name() { return "GC.run"; } 1.158 + static const char* description() { 1.159 + return "Call java.lang.System.gc()."; 1.160 + } 1.161 + static const char* impact() { 1.162 + return "Medium: Depends on Java heap size and content."; 1.163 + } 1.164 + static int num_arguments() { return 0; } 1.165 + virtual void execute(DCmdSource source, TRAPS); 1.166 +}; 1.167 + 1.168 +class RunFinalizationDCmd : public DCmd { 1.169 +public: 1.170 + RunFinalizationDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } 1.171 + static const char* name() { return "GC.run_finalization"; } 1.172 + static const char* description() { 1.173 + return "Call java.lang.System.runFinalization()."; 1.174 + } 1.175 + static const char* impact() { 1.176 + return "Medium: Depends on Java content."; 1.177 + } 1.178 + static int num_arguments() { return 0; } 1.179 + virtual void execute(DCmdSource source, TRAPS); 1.180 +}; 1.181 + 1.182 +#if INCLUDE_SERVICES // Heap dumping supported 1.183 +// See also: dump_heap in attachListener.cpp 1.184 +class HeapDumpDCmd : public DCmdWithParser { 1.185 +protected: 1.186 + DCmdArgument<char*> _filename; 1.187 + DCmdArgument<bool> _all; 1.188 +public: 1.189 + HeapDumpDCmd(outputStream* output, bool heap); 1.190 + static const char* name() { 1.191 + return "GC.heap_dump"; 1.192 + } 1.193 + static const char* description() { 1.194 + return "Generate a HPROF format dump of the Java heap."; 1.195 + } 1.196 + static const char* impact() { 1.197 + return "High: Depends on Java heap size and content. " 1.198 + "Request a full GC unless the '-all' option is specified."; 1.199 + } 1.200 + static const JavaPermission permission() { 1.201 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.202 + "monitor", NULL}; 1.203 + return p; 1.204 + } 1.205 + static int num_arguments(); 1.206 + virtual void execute(DCmdSource source, TRAPS); 1.207 +}; 1.208 +#endif // INCLUDE_SERVICES 1.209 + 1.210 +// See also: inspectheap in attachListener.cpp 1.211 +class ClassHistogramDCmd : public DCmdWithParser { 1.212 +protected: 1.213 + DCmdArgument<bool> _all; 1.214 +public: 1.215 + ClassHistogramDCmd(outputStream* output, bool heap); 1.216 + static const char* name() { 1.217 + return "GC.class_histogram"; 1.218 + } 1.219 + static const char* description() { 1.220 + return "Provide statistics about the Java heap usage."; 1.221 + } 1.222 + static const char* impact() { 1.223 + return "High: Depends on Java heap size and content."; 1.224 + } 1.225 + static const JavaPermission permission() { 1.226 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.227 + "monitor", NULL}; 1.228 + return p; 1.229 + } 1.230 + static int num_arguments(); 1.231 + virtual void execute(DCmdSource source, TRAPS); 1.232 +}; 1.233 + 1.234 +class ClassStatsDCmd : public DCmdWithParser { 1.235 +protected: 1.236 + DCmdArgument<bool> _all; 1.237 + DCmdArgument<bool> _csv; 1.238 + DCmdArgument<bool> _help; 1.239 + DCmdArgument<char*> _columns; 1.240 +public: 1.241 + ClassStatsDCmd(outputStream* output, bool heap); 1.242 + static const char* name() { 1.243 + return "GC.class_stats"; 1.244 + } 1.245 + static const char* description() { 1.246 + return "Provide statistics about Java class meta data. Requires -XX:+UnlockDiagnosticVMOptions."; 1.247 + } 1.248 + static const char* impact() { 1.249 + return "High: Depends on Java heap size and content."; 1.250 + } 1.251 + static int num_arguments(); 1.252 + virtual void execute(DCmdSource source, TRAPS); 1.253 +}; 1.254 + 1.255 +// See also: thread_dump in attachListener.cpp 1.256 +class ThreadDumpDCmd : public DCmdWithParser { 1.257 +protected: 1.258 + DCmdArgument<bool> _locks; 1.259 +public: 1.260 + ThreadDumpDCmd(outputStream* output, bool heap); 1.261 + static const char* name() { return "Thread.print"; } 1.262 + static const char* description() { 1.263 + return "Print all threads with stacktraces."; 1.264 + } 1.265 + static const char* impact() { 1.266 + return "Medium: Depends on the number of threads."; 1.267 + } 1.268 + static const JavaPermission permission() { 1.269 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.270 + "monitor", NULL}; 1.271 + return p; 1.272 + } 1.273 + static int num_arguments(); 1.274 + virtual void execute(DCmdSource source, TRAPS); 1.275 +}; 1.276 + 1.277 +// Enhanced JMX Agent support 1.278 + 1.279 +class JMXStartRemoteDCmd : public DCmdWithParser { 1.280 + 1.281 + // Explicitly list all properties that could be 1.282 + // passed to Agent.startRemoteManagementAgent() 1.283 + // com.sun.management is omitted 1.284 + 1.285 + DCmdArgument<char *> _config_file; 1.286 + DCmdArgument<char *> _jmxremote_port; 1.287 + DCmdArgument<char *> _jmxremote_rmi_port; 1.288 + DCmdArgument<char *> _jmxremote_ssl; 1.289 + DCmdArgument<char *> _jmxremote_registry_ssl; 1.290 + DCmdArgument<char *> _jmxremote_authenticate; 1.291 + DCmdArgument<char *> _jmxremote_password_file; 1.292 + DCmdArgument<char *> _jmxremote_access_file; 1.293 + DCmdArgument<char *> _jmxremote_login_config; 1.294 + DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites; 1.295 + DCmdArgument<char *> _jmxremote_ssl_enabled_protocols; 1.296 + DCmdArgument<char *> _jmxremote_ssl_need_client_auth; 1.297 + DCmdArgument<char *> _jmxremote_ssl_config_file; 1.298 + 1.299 + // JDP support 1.300 + // Keep autodiscovery char* not bool to pass true/false 1.301 + // as property value to java level. 1.302 + DCmdArgument<char *> _jmxremote_autodiscovery; 1.303 + DCmdArgument<jlong> _jdp_port; 1.304 + DCmdArgument<char *> _jdp_address; 1.305 + DCmdArgument<char *> _jdp_source_addr; 1.306 + DCmdArgument<jlong> _jdp_ttl; 1.307 + DCmdArgument<jlong> _jdp_pause; 1.308 + DCmdArgument<char *> _jdp_name; 1.309 + 1.310 +public: 1.311 + JMXStartRemoteDCmd(outputStream *output, bool heap_allocated); 1.312 + 1.313 + static const char *name() { 1.314 + return "ManagementAgent.start"; 1.315 + } 1.316 + 1.317 + static const char *description() { 1.318 + return "Start remote management agent."; 1.319 + } 1.320 + 1.321 + static int num_arguments(); 1.322 + 1.323 + virtual void execute(DCmdSource source, TRAPS); 1.324 + 1.325 +}; 1.326 + 1.327 +class JMXStartLocalDCmd : public DCmd { 1.328 + 1.329 + // Explicitly request start of local agent, 1.330 + // it will not be started by start dcmd 1.331 + 1.332 + 1.333 +public: 1.334 + JMXStartLocalDCmd(outputStream *output, bool heap_allocated); 1.335 + 1.336 + static const char *name() { 1.337 + return "ManagementAgent.start_local"; 1.338 + } 1.339 + 1.340 + static const char *description() { 1.341 + return "Start local management agent."; 1.342 + } 1.343 + 1.344 + virtual void execute(DCmdSource source, TRAPS); 1.345 + 1.346 +}; 1.347 + 1.348 +class JMXStopRemoteDCmd : public DCmd { 1.349 +public: 1.350 + JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) : 1.351 + DCmd(output, heap_allocated) { 1.352 + // Do Nothing 1.353 + } 1.354 + 1.355 + static const char *name() { 1.356 + return "ManagementAgent.stop"; 1.357 + } 1.358 + 1.359 + static const char *description() { 1.360 + return "Stop remote management agent."; 1.361 + } 1.362 + 1.363 + virtual void execute(DCmdSource source, TRAPS); 1.364 +}; 1.365 + 1.366 +class RotateGCLogDCmd : public DCmd { 1.367 +public: 1.368 + RotateGCLogDCmd(outputStream* output, bool heap) : DCmd(output, heap) {} 1.369 + static const char* name() { return "GC.rotate_log"; } 1.370 + static const char* description() { 1.371 + return "Force the GC log file to be rotated."; 1.372 + } 1.373 + static const char* impact() { return "Low"; } 1.374 + virtual void execute(DCmdSource source, TRAPS); 1.375 + static int num_arguments() { return 0; } 1.376 + static const JavaPermission permission() { 1.377 + JavaPermission p = {"java.lang.management.ManagementPermission", 1.378 + "control", NULL}; 1.379 + return p; 1.380 + } 1.381 +}; 1.382 + 1.383 +#endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP