37 #include "utilities/macros.hpp" 38 39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 40 41 void DCmdRegistrant::register_dcmds(){ 42 // Registration of the diagnostic commands 43 // First argument specifies which interfaces will export the command 44 // Second argument specifies if the command is enabled 45 // Third argument specifies if the command is hidden 46 uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI 47 | DCmd_Source_MBean; 48 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); 49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); 50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); 51 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); 52 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); 53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false)); 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); 56 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); 57 #if INCLUDE_SERVICES // Heap dumping/inspection supported 58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false)); 59 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); 60 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false)); 61 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false)); 62 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false)); 63 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false)); 64 #endif // INCLUDE_SERVICES 65 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); 66 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false)); 67 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false)); 68 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false)); 69 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false)); 70 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false)); 71 72 // Enhanced JMX Agent Support 73 // These commands won't be exported via the DiagnosticCommandMBean until an 74 // appropriate permission is created for them 75 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; 76 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); 266 return 0; 267 } 268 } 269 270 void SystemGCDCmd::execute(DCmdSource source, TRAPS) { 271 if (!DisableExplicitGC) { 272 Universe::heap()->collect(GCCause::_java_lang_system_gc); 273 } else { 274 output()->print_cr("Explicit GC is disabled, no GC has been performed."); 275 } 276 } 277 278 void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { 279 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), 280 true, CHECK); 281 instanceKlassHandle klass(THREAD, k); 282 JavaValue result(T_VOID); 283 JavaCalls::call_static(&result, klass, 284 vmSymbols::run_finalization_name(), 285 vmSymbols::void_method_signature(), CHECK); 286 } 287 288 #if INCLUDE_SERVICES // Heap dumping/inspection supported 289 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) : 290 DCmdWithParser(output, heap), 291 _filename("filename","Name of the dump file", "STRING",true), 292 _all("-all", "Dump all objects, including unreachable objects", 293 "BOOLEAN", false, "false") { 294 _dcmdparser.add_dcmd_option(&_all); 295 _dcmdparser.add_dcmd_argument(&_filename); 296 } 297 298 void HeapDumpDCmd::execute(DCmdSource source, TRAPS) { 299 // Request a full GC before heap dump if _all is false 300 // This helps reduces the amount of unreachable objects in the dump 301 // and makes it easier to browse. 302 HeapDumper dumper(!_all.value() /* request GC if _all is false*/); 303 int res = dumper.dump(_filename.value()); 304 if (res == 0) { 305 output()->print_cr("Heap dump file created"); | 37 #include "utilities/macros.hpp" 38 39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 40 41 void DCmdRegistrant::register_dcmds(){ 42 // Registration of the diagnostic commands 43 // First argument specifies which interfaces will export the command 44 // Second argument specifies if the command is enabled 45 // Third argument specifies if the command is hidden 46 uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI 47 | DCmd_Source_MBean; 48 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false)); 49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false)); 50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false)); 51 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false)); 52 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false)); 53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false)); 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false)); 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false)); 56 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false)); 57 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false)); 58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false)); 59 #if INCLUDE_SERVICES // Heap dumping/inspection supported 60 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false)); 61 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false)); 62 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false)); 63 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false)); 64 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false)); 65 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false)); 66 #endif // INCLUDE_SERVICES 67 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false)); 68 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false)); 69 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false)); 70 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false)); 71 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false)); 72 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false)); 73 74 // Enhanced JMX Agent Support 75 // These commands won't be exported via the DiagnosticCommandMBean until an 76 // appropriate permission is created for them 77 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI; 78 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false)); 268 return 0; 269 } 270 } 271 272 void SystemGCDCmd::execute(DCmdSource source, TRAPS) { 273 if (!DisableExplicitGC) { 274 Universe::heap()->collect(GCCause::_java_lang_system_gc); 275 } else { 276 output()->print_cr("Explicit GC is disabled, no GC has been performed."); 277 } 278 } 279 280 void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { 281 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), 282 true, CHECK); 283 instanceKlassHandle klass(THREAD, k); 284 JavaValue result(T_VOID); 285 JavaCalls::call_static(&result, klass, 286 vmSymbols::run_finalization_name(), 287 vmSymbols::void_method_signature(), CHECK); 288 } 289 290 void HeapInfoDCmd::execute(DCmdSource source, TRAPS) { 291 Universe::heap()->print_on(output()); 292 } 293 294 void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) { 295 output()->print_cr("Unreachable instances awaiting finalization"); 296 297 Klass *k = SystemDictionary::Finalizer_klass(); 298 instanceKlassHandle klass(THREAD, k); 299 JavaValue result(T_OBJECT); 300 JavaCalls::call_static(&result, klass, 301 vmSymbols::print_finalization_queue_name(), 302 vmSymbols::void_string_signature(), CHECK); 303 304 oop result_oop = (oop) result.get_jobject(); 305 char *result_str = java_lang_String::as_utf8_string(result_oop); 306 output()->print_cr("%s", result_str); 307 } 308 309 #if INCLUDE_SERVICES // Heap dumping/inspection supported 310 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) : 311 DCmdWithParser(output, heap), 312 _filename("filename","Name of the dump file", "STRING",true), 313 _all("-all", "Dump all objects, including unreachable objects", 314 "BOOLEAN", false, "false") { 315 _dcmdparser.add_dcmd_option(&_all); 316 _dcmdparser.add_dcmd_argument(&_filename); 317 } 318 319 void HeapDumpDCmd::execute(DCmdSource source, TRAPS) { 320 // Request a full GC before heap dump if _all is false 321 // This helps reduces the amount of unreachable objects in the dump 322 // and makes it easier to browse. 323 HeapDumper dumper(!_all.value() /* request GC if _all is false*/); 324 int res = dumper.dump(_filename.value()); 325 if (res == 0) { 326 output()->print_cr("Heap dump file created"); |