Mon, 19 Aug 2013 18:17:58 +0200
8023219: NPG: MetaspaceMemoryPool should report statistics for all of metaspace
Reviewed-by: stefank, sjohanss
fparain@3329 | 1 | /* |
acorn@4497 | 2 | * Copyright (c) 2011, 2013, 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 | #include "precompiled.hpp" |
fparain@3402 | 26 | #include "gc_implementation/shared/vmGCOperations.hpp" |
fparain@3402 | 27 | #include "runtime/javaCalls.hpp" |
fparain@3329 | 28 | #include "services/diagnosticArgument.hpp" |
fparain@3329 | 29 | #include "services/diagnosticCommand.hpp" |
fparain@3329 | 30 | #include "services/diagnosticFramework.hpp" |
fparain@3402 | 31 | #include "services/heapDumper.hpp" |
fparain@3402 | 32 | #include "services/management.hpp" |
jprovino@4542 | 33 | #include "utilities/macros.hpp" |
fparain@3329 | 34 | |
dsamersoff@3478 | 35 | void DCmdRegistrant::register_dcmds(){ |
dsamersoff@3478 | 36 | // Registration of the diagnostic commands |
fparain@5047 | 37 | // First argument specifies which interfaces will export the command |
fparain@5047 | 38 | // Second argument specifies if the command is enabled |
fparain@5047 | 39 | // Third argument specifies if the command is hidden |
fparain@5047 | 40 | uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI |
fparain@5047 | 41 | | DCmd_Source_MBean; |
fparain@5047 | 42 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); |
fparain@5047 | 43 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); |
fparain@5047 | 44 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); |
fparain@5047 | 45 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); |
fparain@5047 | 46 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); |
fparain@5047 | 47 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); |
fparain@5047 | 48 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); |
fparain@5047 | 49 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); |
acorn@4497 | 50 | #if INCLUDE_SERVICES // Heap dumping/inspection supported |
fparain@5047 | 51 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(full_export, true, false)); |
fparain@5047 | 52 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); |
fparain@5047 | 53 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false)); |
jprovino@4165 | 54 | #endif // INCLUDE_SERVICES |
fparain@5047 | 55 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); |
fparain@5047 | 56 | |
fparain@5047 | 57 | // Enhanced JMX Agent Support |
fparain@5047 | 58 | // These commands won't be exported via the DiagnosticCommandMBean until an |
fparain@5047 | 59 | // appropriate permission is created for them |
fparain@5047 | 60 | uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; |
fparain@5047 | 61 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); |
fparain@5047 | 62 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false)); |
fparain@5047 | 63 | DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); |
dsamersoff@3598 | 64 | |
dsamersoff@3478 | 65 | } |
dsamersoff@3478 | 66 | |
dsamersoff@3478 | 67 | #ifndef HAVE_EXTRA_DCMD |
dsamersoff@3478 | 68 | void DCmdRegistrant::register_dcmds_ext(){ |
dsamersoff@3478 | 69 | // Do nothing here |
dsamersoff@3478 | 70 | } |
dsamersoff@3478 | 71 | #endif |
dsamersoff@3478 | 72 | |
dsamersoff@3478 | 73 | |
fparain@3402 | 74 | HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), |
fparain@3329 | 75 | _all("-all", "Show help for all commands", "BOOLEAN", false, "false"), |
fparain@3329 | 76 | _cmd("command name", "The name of the command for which we want help", |
fparain@3329 | 77 | "STRING", false) { |
fparain@3329 | 78 | _dcmdparser.add_dcmd_option(&_all); |
fparain@3329 | 79 | _dcmdparser.add_dcmd_argument(&_cmd); |
fparain@3329 | 80 | }; |
fparain@3329 | 81 | |
fparain@5047 | 82 | void HelpDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3329 | 83 | if (_all.value()) { |
fparain@5047 | 84 | GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source); |
fparain@3329 | 85 | for (int i = 0; i < cmd_list->length(); i++) { |
fparain@5047 | 86 | DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i), |
fparain@3329 | 87 | strlen(cmd_list->at(i))); |
fparain@5047 | 88 | output()->print_cr("%s%s", factory->name(), |
fparain@5047 | 89 | factory->is_enabled() ? "" : " [disabled]"); |
fparain@5047 | 90 | output()->print_cr("\t%s", factory->description()); |
fparain@5047 | 91 | output()->cr(); |
fparain@3329 | 92 | factory = factory->next(); |
fparain@3329 | 93 | } |
fparain@3329 | 94 | } else if (_cmd.has_value()) { |
fparain@3329 | 95 | DCmd* cmd = NULL; |
fparain@5047 | 96 | DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(), |
fparain@3329 | 97 | strlen(_cmd.value())); |
fparain@3329 | 98 | if (factory != NULL) { |
fparain@3329 | 99 | output()->print_cr("%s%s", factory->name(), |
fparain@3329 | 100 | factory->is_enabled() ? "" : " [disabled]"); |
fparain@3329 | 101 | output()->print_cr(factory->description()); |
fparain@3329 | 102 | output()->print_cr("\nImpact: %s", factory->impact()); |
fparain@5047 | 103 | JavaPermission p = factory->permission(); |
fparain@5047 | 104 | if(p._class != NULL) { |
fparain@5047 | 105 | if(p._action != NULL) { |
fparain@5047 | 106 | output()->print_cr("\nPermission: %s(%s, %s)", |
fparain@5047 | 107 | p._class, p._name == NULL ? "null" : p._name, p._action); |
fparain@5047 | 108 | } else { |
fparain@5047 | 109 | output()->print_cr("\nPermission: %s(%s)", |
fparain@5047 | 110 | p._class, p._name == NULL ? "null" : p._name); |
fparain@5047 | 111 | } |
fparain@5047 | 112 | } |
fparain@3402 | 113 | output()->cr(); |
fparain@3329 | 114 | cmd = factory->create_resource_instance(output()); |
fparain@3329 | 115 | if (cmd != NULL) { |
fparain@3329 | 116 | DCmdMark mark(cmd); |
fparain@3402 | 117 | cmd->print_help(factory->name()); |
fparain@3329 | 118 | } |
fparain@3329 | 119 | } else { |
fparain@3329 | 120 | output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value()); |
fparain@3329 | 121 | } |
fparain@3329 | 122 | } else { |
fparain@3329 | 123 | output()->print_cr("The following commands are available:"); |
fparain@5047 | 124 | GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source); |
fparain@3329 | 125 | for (int i = 0; i < cmd_list->length(); i++) { |
fparain@5047 | 126 | DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i), |
fparain@3329 | 127 | strlen(cmd_list->at(i))); |
fparain@5047 | 128 | output()->print_cr("%s%s", factory->name(), |
fparain@5047 | 129 | factory->is_enabled() ? "" : " [disabled]"); |
fparain@3329 | 130 | factory = factory->_next; |
fparain@3329 | 131 | } |
fparain@3329 | 132 | output()->print_cr("\nFor more information about a specific command use 'help <command>'."); |
fparain@3329 | 133 | } |
fparain@3329 | 134 | } |
fparain@3329 | 135 | |
fparain@3329 | 136 | int HelpDCmd::num_arguments() { |
fparain@3329 | 137 | ResourceMark rm; |
fparain@3329 | 138 | HelpDCmd* dcmd = new HelpDCmd(NULL, false); |
fparain@3329 | 139 | if (dcmd != NULL) { |
fparain@3329 | 140 | DCmdMark mark(dcmd); |
fparain@3329 | 141 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3329 | 142 | } else { |
fparain@3329 | 143 | return 0; |
fparain@3329 | 144 | } |
fparain@3329 | 145 | } |
fparain@3329 | 146 | |
fparain@5047 | 147 | void VersionDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3329 | 148 | output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(), |
fparain@3329 | 149 | Abstract_VM_Version::vm_release()); |
fparain@3329 | 150 | JDK_Version jdk_version = JDK_Version::current(); |
fparain@3329 | 151 | if (jdk_version.update_version() > 0) { |
fparain@3329 | 152 | output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(), |
fparain@3329 | 153 | jdk_version.minor_version(), jdk_version.update_version()); |
fparain@3329 | 154 | } else { |
fparain@3329 | 155 | output()->print_cr("JDK %d.%d", jdk_version.major_version(), |
fparain@3329 | 156 | jdk_version.minor_version()); |
fparain@3329 | 157 | } |
fparain@3329 | 158 | } |
fparain@3402 | 159 | |
fparain@3402 | 160 | PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) : |
fparain@3402 | 161 | DCmdWithParser(output, heap), |
fparain@3402 | 162 | _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") { |
fparain@3402 | 163 | _dcmdparser.add_dcmd_option(&_all); |
fparain@3402 | 164 | } |
fparain@3402 | 165 | |
fparain@5047 | 166 | void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 167 | if (_all.value()) { |
fparain@3402 | 168 | CommandLineFlags::printFlags(output(), true); |
fparain@3402 | 169 | } else { |
fparain@3402 | 170 | CommandLineFlags::printSetFlags(output()); |
fparain@3402 | 171 | } |
fparain@3402 | 172 | } |
fparain@3402 | 173 | |
fparain@3402 | 174 | int PrintVMFlagsDCmd::num_arguments() { |
fparain@3402 | 175 | ResourceMark rm; |
fparain@3402 | 176 | PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false); |
fparain@3402 | 177 | if (dcmd != NULL) { |
fparain@3402 | 178 | DCmdMark mark(dcmd); |
fparain@3402 | 179 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3402 | 180 | } else { |
fparain@3402 | 181 | return 0; |
fparain@3402 | 182 | } |
fparain@3402 | 183 | } |
fparain@3402 | 184 | |
fparain@5047 | 185 | void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 186 | // load sun.misc.VMSupport |
fparain@3402 | 187 | Symbol* klass = vmSymbols::sun_misc_VMSupport(); |
coleenp@4037 | 188 | Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK); |
fparain@3402 | 189 | instanceKlassHandle ik (THREAD, k); |
fparain@3402 | 190 | if (ik->should_be_initialized()) { |
fparain@3402 | 191 | ik->initialize(THREAD); |
fparain@3402 | 192 | } |
fparain@3402 | 193 | if (HAS_PENDING_EXCEPTION) { |
fparain@3402 | 194 | java_lang_Throwable::print(PENDING_EXCEPTION, output()); |
fparain@3402 | 195 | output()->cr(); |
fparain@3402 | 196 | CLEAR_PENDING_EXCEPTION; |
fparain@3402 | 197 | return; |
fparain@3402 | 198 | } |
fparain@3402 | 199 | |
fparain@3402 | 200 | // invoke the serializePropertiesToByteArray method |
fparain@3402 | 201 | JavaValue result(T_OBJECT); |
fparain@3402 | 202 | JavaCallArguments args; |
fparain@3402 | 203 | |
fparain@3402 | 204 | Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature(); |
fparain@3402 | 205 | JavaCalls::call_static(&result, |
fparain@3402 | 206 | ik, |
fparain@3402 | 207 | vmSymbols::serializePropertiesToByteArray_name(), |
fparain@3402 | 208 | signature, |
fparain@3402 | 209 | &args, |
fparain@3402 | 210 | THREAD); |
fparain@3402 | 211 | if (HAS_PENDING_EXCEPTION) { |
fparain@3402 | 212 | java_lang_Throwable::print(PENDING_EXCEPTION, output()); |
fparain@3402 | 213 | output()->cr(); |
fparain@3402 | 214 | CLEAR_PENDING_EXCEPTION; |
fparain@3402 | 215 | return; |
fparain@3402 | 216 | } |
fparain@3402 | 217 | |
fparain@3402 | 218 | // The result should be a [B |
fparain@3402 | 219 | oop res = (oop)result.get_jobject(); |
fparain@3402 | 220 | assert(res->is_typeArray(), "just checking"); |
coleenp@4142 | 221 | assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking"); |
fparain@3402 | 222 | |
fparain@3402 | 223 | // copy the bytes to the output stream |
fparain@3402 | 224 | typeArrayOop ba = typeArrayOop(res); |
fparain@3402 | 225 | jbyte* addr = typeArrayOop(res)->byte_at_addr(0); |
fparain@3402 | 226 | output()->print_raw((const char*)addr, ba->length()); |
fparain@3402 | 227 | } |
fparain@3402 | 228 | |
fparain@3402 | 229 | VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) : |
fparain@3402 | 230 | DCmdWithParser(output, heap), |
fparain@3402 | 231 | _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") { |
fparain@3402 | 232 | _dcmdparser.add_dcmd_option(&_date); |
fparain@3402 | 233 | } |
fparain@3402 | 234 | |
fparain@5047 | 235 | void VMUptimeDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 236 | if (_date.value()) { |
fparain@3402 | 237 | output()->date_stamp(true, "", ": "); |
fparain@3402 | 238 | } |
fparain@3402 | 239 | output()->time_stamp().update_to(tty->time_stamp().ticks()); |
fparain@3402 | 240 | output()->stamp(); |
fparain@3402 | 241 | output()->print_cr(" s"); |
fparain@3402 | 242 | } |
fparain@3402 | 243 | |
fparain@3402 | 244 | int VMUptimeDCmd::num_arguments() { |
fparain@3402 | 245 | ResourceMark rm; |
fparain@3402 | 246 | VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false); |
fparain@3402 | 247 | if (dcmd != NULL) { |
fparain@3402 | 248 | DCmdMark mark(dcmd); |
fparain@3402 | 249 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3402 | 250 | } else { |
fparain@3402 | 251 | return 0; |
fparain@3402 | 252 | } |
fparain@3402 | 253 | } |
fparain@3402 | 254 | |
fparain@5047 | 255 | void SystemGCDCmd::execute(DCmdSource source, TRAPS) { |
fparain@5047 | 256 | if (!DisableExplicitGC) { |
fparain@5047 | 257 | Universe::heap()->collect(GCCause::_java_lang_system_gc); |
fparain@5047 | 258 | } else { |
fparain@5047 | 259 | output()->print_cr("Explicit GC is disabled, no GC has been performed."); |
fparain@5047 | 260 | } |
fparain@3402 | 261 | } |
fparain@3402 | 262 | |
fparain@5047 | 263 | void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { |
coleenp@4037 | 264 | Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), |
fparain@3402 | 265 | true, CHECK); |
fparain@3402 | 266 | instanceKlassHandle klass(THREAD, k); |
fparain@3402 | 267 | JavaValue result(T_VOID); |
fparain@3402 | 268 | JavaCalls::call_static(&result, klass, |
fparain@3402 | 269 | vmSymbols::run_finalization_name(), |
fparain@3402 | 270 | vmSymbols::void_method_signature(), CHECK); |
fparain@3402 | 271 | } |
fparain@3402 | 272 | |
acorn@4497 | 273 | #if INCLUDE_SERVICES // Heap dumping/inspection supported |
fparain@3402 | 274 | HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) : |
fparain@3402 | 275 | DCmdWithParser(output, heap), |
fparain@3402 | 276 | _filename("filename","Name of the dump file", "STRING",true), |
fparain@3402 | 277 | _all("-all", "Dump all objects, including unreachable objects", |
fparain@3402 | 278 | "BOOLEAN", false, "false") { |
fparain@3402 | 279 | _dcmdparser.add_dcmd_option(&_all); |
fparain@3402 | 280 | _dcmdparser.add_dcmd_argument(&_filename); |
fparain@3402 | 281 | } |
fparain@3402 | 282 | |
fparain@5047 | 283 | void HeapDumpDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 284 | // Request a full GC before heap dump if _all is false |
fparain@3402 | 285 | // This helps reduces the amount of unreachable objects in the dump |
fparain@3402 | 286 | // and makes it easier to browse. |
fparain@3402 | 287 | HeapDumper dumper(!_all.value() /* request GC if _all is false*/); |
fparain@3402 | 288 | int res = dumper.dump(_filename.value()); |
fparain@3402 | 289 | if (res == 0) { |
fparain@3402 | 290 | output()->print_cr("Heap dump file created"); |
fparain@3402 | 291 | } else { |
fparain@3402 | 292 | // heap dump failed |
fparain@3402 | 293 | ResourceMark rm; |
fparain@3402 | 294 | char* error = dumper.error_as_C_string(); |
fparain@3402 | 295 | if (error == NULL) { |
fparain@3402 | 296 | output()->print_cr("Dump failed - reason unknown"); |
fparain@3402 | 297 | } else { |
fparain@3402 | 298 | output()->print_cr("%s", error); |
fparain@3402 | 299 | } |
fparain@3402 | 300 | } |
fparain@3402 | 301 | } |
fparain@3402 | 302 | |
fparain@3402 | 303 | int HeapDumpDCmd::num_arguments() { |
fparain@3402 | 304 | ResourceMark rm; |
fparain@3402 | 305 | HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false); |
fparain@3402 | 306 | if (dcmd != NULL) { |
fparain@3402 | 307 | DCmdMark mark(dcmd); |
fparain@3402 | 308 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3402 | 309 | } else { |
fparain@3402 | 310 | return 0; |
fparain@3402 | 311 | } |
fparain@3402 | 312 | } |
fparain@3402 | 313 | |
fparain@3402 | 314 | ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) : |
fparain@3402 | 315 | DCmdWithParser(output, heap), |
fparain@3402 | 316 | _all("-all", "Inspect all objects, including unreachable objects", |
fparain@3402 | 317 | "BOOLEAN", false, "false") { |
fparain@3402 | 318 | _dcmdparser.add_dcmd_option(&_all); |
fparain@3402 | 319 | } |
fparain@3402 | 320 | |
fparain@5047 | 321 | void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 322 | VM_GC_HeapInspection heapop(output(), |
sla@5237 | 323 | !_all.value() /* request full gc if false */); |
fparain@3402 | 324 | VMThread::execute(&heapop); |
fparain@3402 | 325 | } |
fparain@3402 | 326 | |
fparain@3402 | 327 | int ClassHistogramDCmd::num_arguments() { |
fparain@3402 | 328 | ResourceMark rm; |
fparain@3402 | 329 | ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false); |
fparain@3402 | 330 | if (dcmd != NULL) { |
fparain@3402 | 331 | DCmdMark mark(dcmd); |
fparain@3402 | 332 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3402 | 333 | } else { |
fparain@3402 | 334 | return 0; |
fparain@3402 | 335 | } |
fparain@3402 | 336 | } |
fparain@3402 | 337 | |
acorn@4497 | 338 | #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total" |
acorn@4497 | 339 | ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) : |
acorn@4497 | 340 | DCmdWithParser(output, heap), |
acorn@4497 | 341 | _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets", |
acorn@4497 | 342 | "BOOLEAN", false, "false"), |
acorn@4497 | 343 | _all("-all", "Show all columns", |
acorn@4497 | 344 | "BOOLEAN", false, "false"), |
acorn@4497 | 345 | _help("-help", "Show meaning of all the columns", |
acorn@4497 | 346 | "BOOLEAN", false, "false"), |
acorn@4497 | 347 | _columns("columns", "Comma-separated list of all the columns to show. " |
acorn@4497 | 348 | "If not specified, the following columns are shown: " DEFAULT_COLUMNS, |
acorn@4497 | 349 | "STRING", false) { |
acorn@4497 | 350 | _dcmdparser.add_dcmd_option(&_all); |
acorn@4497 | 351 | _dcmdparser.add_dcmd_option(&_csv); |
acorn@4497 | 352 | _dcmdparser.add_dcmd_option(&_help); |
acorn@4497 | 353 | _dcmdparser.add_dcmd_argument(&_columns); |
acorn@4497 | 354 | } |
acorn@4497 | 355 | |
fparain@5047 | 356 | void ClassStatsDCmd::execute(DCmdSource source, TRAPS) { |
acorn@4497 | 357 | if (!UnlockDiagnosticVMOptions) { |
acorn@4497 | 358 | output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions"); |
acorn@4497 | 359 | return; |
acorn@4497 | 360 | } |
acorn@4497 | 361 | |
acorn@4497 | 362 | VM_GC_HeapInspection heapop(output(), |
sla@5237 | 363 | true /* request_full_gc */); |
acorn@4497 | 364 | heapop.set_csv_format(_csv.value()); |
acorn@4497 | 365 | heapop.set_print_help(_help.value()); |
acorn@4497 | 366 | heapop.set_print_class_stats(true); |
acorn@4497 | 367 | if (_all.value()) { |
acorn@4497 | 368 | if (_columns.has_value()) { |
acorn@4497 | 369 | output()->print_cr("Cannot specify -all and individual columns at the same time"); |
acorn@4497 | 370 | return; |
acorn@4497 | 371 | } else { |
acorn@4497 | 372 | heapop.set_columns(NULL); |
acorn@4497 | 373 | } |
acorn@4497 | 374 | } else { |
acorn@4497 | 375 | if (_columns.has_value()) { |
acorn@4497 | 376 | heapop.set_columns(_columns.value()); |
acorn@4497 | 377 | } else { |
acorn@4497 | 378 | heapop.set_columns(DEFAULT_COLUMNS); |
acorn@4497 | 379 | } |
acorn@4497 | 380 | } |
acorn@4497 | 381 | VMThread::execute(&heapop); |
acorn@4497 | 382 | } |
acorn@4497 | 383 | |
acorn@4497 | 384 | int ClassStatsDCmd::num_arguments() { |
acorn@4497 | 385 | ResourceMark rm; |
acorn@4497 | 386 | ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false); |
acorn@4497 | 387 | if (dcmd != NULL) { |
acorn@4497 | 388 | DCmdMark mark(dcmd); |
acorn@4497 | 389 | return dcmd->_dcmdparser.num_arguments(); |
acorn@4497 | 390 | } else { |
acorn@4497 | 391 | return 0; |
acorn@4497 | 392 | } |
acorn@4497 | 393 | } |
acorn@4497 | 394 | #endif // INCLUDE_SERVICES |
acorn@4497 | 395 | |
fparain@3402 | 396 | ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) : |
fparain@3402 | 397 | DCmdWithParser(output, heap), |
fparain@3402 | 398 | _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") { |
fparain@3402 | 399 | _dcmdparser.add_dcmd_option(&_locks); |
fparain@3402 | 400 | } |
fparain@3402 | 401 | |
fparain@5047 | 402 | void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) { |
fparain@3402 | 403 | // thread stacks |
fparain@3402 | 404 | VM_PrintThreads op1(output(), _locks.value()); |
fparain@3402 | 405 | VMThread::execute(&op1); |
fparain@3402 | 406 | |
fparain@3402 | 407 | // JNI global handles |
fparain@3402 | 408 | VM_PrintJNI op2(output()); |
fparain@3402 | 409 | VMThread::execute(&op2); |
fparain@3402 | 410 | |
fparain@3402 | 411 | // Deadlock detection |
fparain@3402 | 412 | VM_FindDeadlocks op3(output()); |
fparain@3402 | 413 | VMThread::execute(&op3); |
fparain@3402 | 414 | } |
fparain@3402 | 415 | |
fparain@3402 | 416 | int ThreadDumpDCmd::num_arguments() { |
fparain@3402 | 417 | ResourceMark rm; |
fparain@3402 | 418 | ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false); |
fparain@3402 | 419 | if (dcmd != NULL) { |
fparain@3402 | 420 | DCmdMark mark(dcmd); |
fparain@3402 | 421 | return dcmd->_dcmdparser.num_arguments(); |
fparain@3402 | 422 | } else { |
fparain@3402 | 423 | return 0; |
fparain@3402 | 424 | } |
fparain@3402 | 425 | } |
dsamersoff@3598 | 426 | |
dsamersoff@3598 | 427 | // Enhanced JMX Agent support |
dsamersoff@3598 | 428 | |
dsamersoff@3598 | 429 | JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) : |
dsamersoff@3598 | 430 | |
dsamersoff@3598 | 431 | DCmdWithParser(output, heap_allocated), |
dsamersoff@3598 | 432 | |
dsamersoff@3598 | 433 | _config_file |
dsamersoff@3598 | 434 | ("config.file", |
dsamersoff@3598 | 435 | "set com.sun.management.config.file", "STRING", false), |
dsamersoff@3598 | 436 | |
dsamersoff@3598 | 437 | _jmxremote_port |
dsamersoff@3598 | 438 | ("jmxremote.port", |
dsamersoff@3598 | 439 | "set com.sun.management.jmxremote.port", "STRING", false), |
dsamersoff@3598 | 440 | |
dsamersoff@3598 | 441 | _jmxremote_rmi_port |
dsamersoff@3598 | 442 | ("jmxremote.rmi.port", |
dsamersoff@3598 | 443 | "set com.sun.management.jmxremote.rmi.port", "STRING", false), |
dsamersoff@3598 | 444 | |
dsamersoff@3598 | 445 | _jmxremote_ssl |
dsamersoff@3598 | 446 | ("jmxremote.ssl", |
dsamersoff@3598 | 447 | "set com.sun.management.jmxremote.ssl", "STRING", false), |
dsamersoff@3598 | 448 | |
dsamersoff@3598 | 449 | _jmxremote_registry_ssl |
dsamersoff@3598 | 450 | ("jmxremote.registry.ssl", |
dsamersoff@3598 | 451 | "set com.sun.management.jmxremote.registry.ssl", "STRING", false), |
dsamersoff@3598 | 452 | |
dsamersoff@3598 | 453 | _jmxremote_authenticate |
dsamersoff@3598 | 454 | ("jmxremote.authenticate", |
dsamersoff@3598 | 455 | "set com.sun.management.jmxremote.authenticate", "STRING", false), |
dsamersoff@3598 | 456 | |
dsamersoff@3598 | 457 | _jmxremote_password_file |
dsamersoff@3598 | 458 | ("jmxremote.password.file", |
dsamersoff@3598 | 459 | "set com.sun.management.jmxremote.password.file", "STRING", false), |
dsamersoff@3598 | 460 | |
dsamersoff@3598 | 461 | _jmxremote_access_file |
dsamersoff@3598 | 462 | ("jmxremote.access.file", |
dsamersoff@3598 | 463 | "set com.sun.management.jmxremote.access.file", "STRING", false), |
dsamersoff@3598 | 464 | |
dsamersoff@3598 | 465 | _jmxremote_login_config |
dsamersoff@3598 | 466 | ("jmxremote.login.config", |
dsamersoff@3598 | 467 | "set com.sun.management.jmxremote.login.config", "STRING", false), |
dsamersoff@3598 | 468 | |
dsamersoff@3598 | 469 | _jmxremote_ssl_enabled_cipher_suites |
dsamersoff@3598 | 470 | ("jmxremote.ssl.enabled.cipher.suites", |
dsamersoff@3598 | 471 | "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false), |
dsamersoff@3598 | 472 | |
dsamersoff@3598 | 473 | _jmxremote_ssl_enabled_protocols |
dsamersoff@3598 | 474 | ("jmxremote.ssl.enabled.protocols", |
dsamersoff@3598 | 475 | "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false), |
dsamersoff@3598 | 476 | |
dsamersoff@3598 | 477 | _jmxremote_ssl_need_client_auth |
dsamersoff@3598 | 478 | ("jmxremote.ssl.need.client.auth", |
dsamersoff@3598 | 479 | "set com.sun.management.jmxremote.need.client.auth", "STRING", false), |
dsamersoff@3598 | 480 | |
dsamersoff@3598 | 481 | _jmxremote_ssl_config_file |
dsamersoff@3598 | 482 | ("jmxremote.ssl.config.file", |
dsamersoff@4520 | 483 | "set com.sun.management.jmxremote.ssl_config_file", "STRING", false), |
dsamersoff@4520 | 484 | |
dsamersoff@4520 | 485 | // JDP Protocol support |
dsamersoff@4520 | 486 | _jmxremote_autodiscovery |
dsamersoff@4520 | 487 | ("jmxremote.autodiscovery", |
dsamersoff@4520 | 488 | "set com.sun.management.jmxremote.autodiscovery", "STRING", false), |
dsamersoff@4520 | 489 | |
dsamersoff@4520 | 490 | _jdp_port |
dsamersoff@4520 | 491 | ("jdp.port", |
dsamersoff@4520 | 492 | "set com.sun.management.jdp.port", "INT", false), |
dsamersoff@4520 | 493 | |
dsamersoff@4520 | 494 | _jdp_address |
dsamersoff@4520 | 495 | ("jdp.address", |
dsamersoff@4520 | 496 | "set com.sun.management.jdp.address", "STRING", false), |
dsamersoff@4520 | 497 | |
dsamersoff@4520 | 498 | _jdp_source_addr |
dsamersoff@4520 | 499 | ("jdp.source_addr", |
dsamersoff@4520 | 500 | "set com.sun.management.jdp.source_addr", "STRING", false), |
dsamersoff@4520 | 501 | |
dsamersoff@4520 | 502 | _jdp_ttl |
dsamersoff@4520 | 503 | ("jdp.ttl", |
dsamersoff@4520 | 504 | "set com.sun.management.jdp.ttl", "INT", false), |
dsamersoff@4520 | 505 | |
dsamersoff@4520 | 506 | _jdp_pause |
dsamersoff@4520 | 507 | ("jdp.pause", |
dsamersoff@4520 | 508 | "set com.sun.management.jdp.pause", "INT", false) |
dsamersoff@3598 | 509 | |
dsamersoff@3598 | 510 | { |
dsamersoff@3598 | 511 | _dcmdparser.add_dcmd_option(&_config_file); |
dsamersoff@3598 | 512 | _dcmdparser.add_dcmd_option(&_jmxremote_port); |
dsamersoff@3598 | 513 | _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port); |
dsamersoff@3598 | 514 | _dcmdparser.add_dcmd_option(&_jmxremote_ssl); |
dsamersoff@3598 | 515 | _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl); |
dsamersoff@3598 | 516 | _dcmdparser.add_dcmd_option(&_jmxremote_authenticate); |
dsamersoff@3598 | 517 | _dcmdparser.add_dcmd_option(&_jmxremote_password_file); |
dsamersoff@3598 | 518 | _dcmdparser.add_dcmd_option(&_jmxremote_access_file); |
dsamersoff@3598 | 519 | _dcmdparser.add_dcmd_option(&_jmxremote_login_config); |
dsamersoff@3598 | 520 | _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites); |
dsamersoff@3598 | 521 | _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols); |
dsamersoff@3598 | 522 | _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth); |
dsamersoff@3598 | 523 | _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file); |
dsamersoff@4520 | 524 | _dcmdparser.add_dcmd_option(&_jmxremote_autodiscovery); |
dsamersoff@4520 | 525 | _dcmdparser.add_dcmd_option(&_jdp_port); |
dsamersoff@4520 | 526 | _dcmdparser.add_dcmd_option(&_jdp_address); |
dsamersoff@4520 | 527 | _dcmdparser.add_dcmd_option(&_jdp_source_addr); |
dsamersoff@4520 | 528 | _dcmdparser.add_dcmd_option(&_jdp_ttl); |
dsamersoff@4520 | 529 | _dcmdparser.add_dcmd_option(&_jdp_pause); |
dsamersoff@3598 | 530 | } |
dsamersoff@3598 | 531 | |
dsamersoff@3598 | 532 | |
dsamersoff@3598 | 533 | int JMXStartRemoteDCmd::num_arguments() { |
dsamersoff@3598 | 534 | ResourceMark rm; |
dsamersoff@3598 | 535 | JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false); |
dsamersoff@3598 | 536 | if (dcmd != NULL) { |
dsamersoff@3598 | 537 | DCmdMark mark(dcmd); |
dsamersoff@3598 | 538 | return dcmd->_dcmdparser.num_arguments(); |
dsamersoff@3598 | 539 | } else { |
dsamersoff@3598 | 540 | return 0; |
dsamersoff@3598 | 541 | } |
dsamersoff@3598 | 542 | } |
dsamersoff@3598 | 543 | |
fparain@5047 | 544 | |
fparain@5047 | 545 | void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) { |
dsamersoff@3598 | 546 | ResourceMark rm(THREAD); |
dsamersoff@3598 | 547 | HandleMark hm(THREAD); |
dsamersoff@3598 | 548 | |
dsamersoff@3598 | 549 | // Load and initialize the sun.management.Agent class |
dsamersoff@3598 | 550 | // invoke startRemoteManagementAgent(string) method to start |
dsamersoff@3598 | 551 | // the remote management server. |
dsamersoff@3598 | 552 | // throw java.lang.NoSuchMethodError if the method doesn't exist |
dsamersoff@3598 | 553 | |
dsamersoff@3598 | 554 | Handle loader = Handle(THREAD, SystemDictionary::java_system_loader()); |
coleenp@4037 | 555 | Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK); |
dsamersoff@3598 | 556 | instanceKlassHandle ik (THREAD, k); |
dsamersoff@3598 | 557 | |
dsamersoff@3598 | 558 | JavaValue result(T_VOID); |
dsamersoff@3598 | 559 | |
dsamersoff@3598 | 560 | // Pass all command line arguments to java as key=value,... |
dsamersoff@3598 | 561 | // All checks are done on java side |
dsamersoff@3598 | 562 | |
dsamersoff@3598 | 563 | int len = 0; |
dsamersoff@3598 | 564 | stringStream options; |
dsamersoff@3598 | 565 | char comma[2] = {0,0}; |
dsamersoff@3598 | 566 | |
dsamersoff@3598 | 567 | // Leave default values on Agent.class side and pass only |
dsamersoff@3598 | 568 | // agruments explicitly set by user. All arguments passed |
dsamersoff@3598 | 569 | // to jcmd override properties with the same name set by |
dsamersoff@3598 | 570 | // command line with -D or by managmenent.properties |
dsamersoff@3598 | 571 | // file. |
dsamersoff@3598 | 572 | #define PUT_OPTION(a) \ |
dsamersoff@3598 | 573 | if ( (a).is_set() ){ \ |
dsamersoff@4520 | 574 | options.print(\ |
dsamersoff@4520 | 575 | ( *((a).type()) == 'I' ) ? "%scom.sun.management.%s=%d" : "%scom.sun.management.%s=%s",\ |
dsamersoff@4520 | 576 | comma, (a).name(), (a).value()); \ |
dsamersoff@3598 | 577 | comma[0] = ','; \ |
dsamersoff@3598 | 578 | } |
dsamersoff@3598 | 579 | |
dsamersoff@3598 | 580 | PUT_OPTION(_config_file); |
dsamersoff@3598 | 581 | PUT_OPTION(_jmxremote_port); |
dsamersoff@3598 | 582 | PUT_OPTION(_jmxremote_rmi_port); |
dsamersoff@3598 | 583 | PUT_OPTION(_jmxremote_ssl); |
dsamersoff@3598 | 584 | PUT_OPTION(_jmxremote_registry_ssl); |
dsamersoff@3598 | 585 | PUT_OPTION(_jmxremote_authenticate); |
dsamersoff@3598 | 586 | PUT_OPTION(_jmxremote_password_file); |
dsamersoff@3598 | 587 | PUT_OPTION(_jmxremote_access_file); |
dsamersoff@3598 | 588 | PUT_OPTION(_jmxremote_login_config); |
dsamersoff@3598 | 589 | PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites); |
dsamersoff@3598 | 590 | PUT_OPTION(_jmxremote_ssl_enabled_protocols); |
dsamersoff@3598 | 591 | PUT_OPTION(_jmxremote_ssl_need_client_auth); |
dsamersoff@3598 | 592 | PUT_OPTION(_jmxremote_ssl_config_file); |
dsamersoff@4520 | 593 | PUT_OPTION(_jmxremote_autodiscovery); |
dsamersoff@4520 | 594 | PUT_OPTION(_jdp_port); |
dsamersoff@4520 | 595 | PUT_OPTION(_jdp_address); |
dsamersoff@4520 | 596 | PUT_OPTION(_jdp_source_addr); |
dsamersoff@4520 | 597 | PUT_OPTION(_jdp_ttl); |
dsamersoff@4520 | 598 | PUT_OPTION(_jdp_pause); |
dsamersoff@3598 | 599 | |
dsamersoff@3598 | 600 | #undef PUT_OPTION |
dsamersoff@3598 | 601 | |
dsamersoff@3598 | 602 | Handle str = java_lang_String::create_from_str(options.as_string(), CHECK); |
dsamersoff@3598 | 603 | JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK); |
dsamersoff@3598 | 604 | } |
dsamersoff@3598 | 605 | |
dsamersoff@3598 | 606 | JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) : |
dsamersoff@3598 | 607 | DCmd(output, heap_allocated) |
dsamersoff@3598 | 608 | { |
dsamersoff@3598 | 609 | // do nothing |
dsamersoff@3598 | 610 | } |
dsamersoff@3598 | 611 | |
fparain@5047 | 612 | void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) { |
dsamersoff@3598 | 613 | ResourceMark rm(THREAD); |
dsamersoff@3598 | 614 | HandleMark hm(THREAD); |
dsamersoff@3598 | 615 | |
dsamersoff@3598 | 616 | // Load and initialize the sun.management.Agent class |
dsamersoff@3598 | 617 | // invoke startLocalManagementAgent(void) method to start |
dsamersoff@3598 | 618 | // the local management server |
dsamersoff@3598 | 619 | // throw java.lang.NoSuchMethodError if method doesn't exist |
dsamersoff@3598 | 620 | |
dsamersoff@3598 | 621 | Handle loader = Handle(THREAD, SystemDictionary::java_system_loader()); |
coleenp@4037 | 622 | Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK); |
dsamersoff@3598 | 623 | instanceKlassHandle ik (THREAD, k); |
dsamersoff@3598 | 624 | |
dsamersoff@3598 | 625 | JavaValue result(T_VOID); |
dsamersoff@3598 | 626 | JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK); |
dsamersoff@3598 | 627 | } |
dsamersoff@3598 | 628 | |
dsamersoff@3598 | 629 | |
fparain@5047 | 630 | void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) { |
dsamersoff@3598 | 631 | ResourceMark rm(THREAD); |
dsamersoff@3598 | 632 | HandleMark hm(THREAD); |
dsamersoff@3598 | 633 | |
dsamersoff@3598 | 634 | // Load and initialize the sun.management.Agent class |
dsamersoff@3598 | 635 | // invoke stopRemoteManagementAgent method to stop the |
dsamersoff@3598 | 636 | // management server |
dsamersoff@3598 | 637 | // throw java.lang.NoSuchMethodError if method doesn't exist |
dsamersoff@3598 | 638 | |
dsamersoff@3598 | 639 | Handle loader = Handle(THREAD, SystemDictionary::java_system_loader()); |
coleenp@4037 | 640 | Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK); |
dsamersoff@3598 | 641 | instanceKlassHandle ik (THREAD, k); |
dsamersoff@3598 | 642 | |
dsamersoff@3598 | 643 | JavaValue result(T_VOID); |
dsamersoff@3598 | 644 | JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK); |
dsamersoff@3598 | 645 | } |
dsamersoff@3598 | 646 |