diff -r d5a7407108b4 -r 24ec8a039c90 hotspot/src/share/vm/classfile/systemDictionary.cpp --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Aug 02 08:19:09 2017 -0400 +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Wed Aug 02 10:52:50 2017 -0400 @@ -74,6 +74,7 @@ #include "runtime/orderAccess.inline.hpp" #include "runtime/signature.hpp" #include "services/classLoadingService.hpp" +#include "services/diagnosticCommand.hpp" #include "services/threadService.hpp" #include "trace/traceMacros.hpp" #include "utilities/macros.hpp" @@ -2808,33 +2809,32 @@ } // ---------------------------------------------------------------------------- -void SystemDictionary::print_shared(bool details) { - shared_dictionary()->print(details); +void SystemDictionary::print_shared(outputStream *st) { + shared_dictionary()->print_on(st); } -void SystemDictionary::print(bool details) { +void SystemDictionary::print_on(outputStream *st) { if (shared_dictionary() != NULL) { tty->print_cr("Shared Dictionary"); - shared_dictionary()->print(details); + shared_dictionary()->print_on(st); } GCMutexLocker mu(SystemDictionary_lock); - ClassLoaderDataGraph::print_dictionary(details); + ClassLoaderDataGraph::print_dictionary(st); // Placeholders - placeholders()->print(); - tty->cr(); + placeholders()->print_on(st); + st->cr(); // loader constraints - print under SD_lock - constraints()->print(); - tty->cr(); - - _pd_cache_table->print(); - tty->cr(); + constraints()->print_on(st); + st->cr(); + + _pd_cache_table->print_on(st); + st->cr(); } - void SystemDictionary::verify() { guarantee(constraints() != NULL, "Verify of loader constraints failed"); @@ -2855,6 +2855,44 @@ _pd_cache_table->verify(); } +void SystemDictionary::dump(outputStream *st, bool verbose) { + assert_locked_or_safepoint(SystemDictionary_lock); + if (verbose) { + print_on(st); + } else { + ClassLoaderDataGraph::print_dictionary_statistics(st); + placeholders()->print_table_statistics(st, "Placeholder Table"); + constraints()->print_table_statistics(st, "LoaderConstraints Table"); + _pd_cache_table->print_table_statistics(st, "ProtectionDomainCache Table"); + } +} + +// Utility for dumping dictionaries. +SystemDictionaryDCmd::SystemDictionaryDCmd(outputStream* output, bool heap) : + DCmdWithParser(output, heap), + _verbose("-verbose", "Dump the content of each dictionary entry for all class loaders", + "BOOLEAN", false, "false") { + _dcmdparser.add_dcmd_option(&_verbose); +} + +void SystemDictionaryDCmd::execute(DCmdSource source, TRAPS) { + VM_DumpHashtable dumper(output(), VM_DumpHashtable::DumpSysDict, + _verbose.value()); + VMThread::execute(&dumper); +} + +int SystemDictionaryDCmd::num_arguments() { + ResourceMark rm; + SystemDictionaryDCmd* dcmd = new SystemDictionaryDCmd(NULL, false); + if (dcmd != NULL) { + DCmdMark mark(dcmd); + return dcmd->_dcmdparser.num_arguments(); + } else { + return 0; + } +} + + // caller needs ResourceMark const char* SystemDictionary::loader_name(const oop loader) { return ((loader) == NULL ? "" :