Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/diagnosticCommand.cpp
32285 views
/*1* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "classfile/classLoaderStats.hpp"26#include "gc_implementation/shared/vmGCOperations.hpp"27#include "runtime/javaCalls.hpp"28#include "runtime/os.hpp"29#include "services/diagnosticArgument.hpp"30#include "services/diagnosticCommand.hpp"31#include "services/diagnosticFramework.hpp"32#include "services/heapDumper.hpp"33#include "services/management.hpp"34#include "utilities/macros.hpp"35#include "oops/objArrayOop.hpp"3637PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC3839void DCmdRegistrant::register_dcmds(){40// Registration of the diagnostic commands41// First argument specifies which interfaces will export the command42// Second argument specifies if the command is enabled43// Third argument specifies if the command is hidden44uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI45| DCmd_Source_MBean;46DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false));47DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false));48DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false));49DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));50DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));51DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));52DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));53DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));54DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));55DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));56DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));57#if INCLUDE_SERVICES // Heap dumping/inspection supported58DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));59DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));60DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));61#endif // INCLUDE_SERVICES62DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));63DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false));64DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));6566// Enhanced JMX Agent Support67// These commands won't be exported via the DiagnosticCommandMBean until an68// appropriate permission is created for them69uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;70DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));71DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));72DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));7374}7576#ifndef HAVE_EXTRA_DCMD77void DCmdRegistrant::register_dcmds_ext(){78// Do nothing here79}80#endif818283HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),84_all("-all", "Show help for all commands", "BOOLEAN", false, "false"),85_cmd("command name", "The name of the command for which we want help",86"STRING", false) {87_dcmdparser.add_dcmd_option(&_all);88_dcmdparser.add_dcmd_argument(&_cmd);89};9091void HelpDCmd::execute(DCmdSource source, TRAPS) {92if (_all.value()) {93GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);94for (int i = 0; i < cmd_list->length(); i++) {95DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),96strlen(cmd_list->at(i)));97output()->print_cr("%s%s", factory->name(),98factory->is_enabled() ? "" : " [disabled]");99output()->print_cr("\t%s", factory->description());100output()->cr();101factory = factory->next();102}103} else if (_cmd.has_value()) {104DCmd* cmd = NULL;105DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),106strlen(_cmd.value()));107if (factory != NULL) {108output()->print_cr("%s%s", factory->name(),109factory->is_enabled() ? "" : " [disabled]");110output()->print_cr("%s", factory->description());111output()->print_cr("\nImpact: %s", factory->impact());112JavaPermission p = factory->permission();113if(p._class != NULL) {114if(p._action != NULL) {115output()->print_cr("\nPermission: %s(%s, %s)",116p._class, p._name == NULL ? "null" : p._name, p._action);117} else {118output()->print_cr("\nPermission: %s(%s)",119p._class, p._name == NULL ? "null" : p._name);120}121}122output()->cr();123cmd = factory->create_resource_instance(output());124if (cmd != NULL) {125DCmdMark mark(cmd);126cmd->print_help(factory->name());127}128} else {129output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());130}131} else {132output()->print_cr("The following commands are available:");133GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);134for (int i = 0; i < cmd_list->length(); i++) {135DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),136strlen(cmd_list->at(i)));137output()->print_cr("%s%s", factory->name(),138factory->is_enabled() ? "" : " [disabled]");139factory = factory->_next;140}141output()->print_cr("\nFor more information about a specific command use 'help <command>'.");142}143}144145int HelpDCmd::num_arguments() {146ResourceMark rm;147HelpDCmd* dcmd = new HelpDCmd(NULL, false);148if (dcmd != NULL) {149DCmdMark mark(dcmd);150return dcmd->_dcmdparser.num_arguments();151} else {152return 0;153}154}155156void VersionDCmd::execute(DCmdSource source, TRAPS) {157output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),158Abstract_VM_Version::vm_release());159JDK_Version jdk_version = JDK_Version::current();160if (jdk_version.update_version() > 0) {161output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),162jdk_version.minor_version(), jdk_version.update_version());163} else {164output()->print_cr("JDK %d.%d", jdk_version.major_version(),165jdk_version.minor_version());166}167}168169PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :170DCmdWithParser(output, heap),171_all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {172_dcmdparser.add_dcmd_option(&_all);173}174175void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {176if (_all.value()) {177CommandLineFlags::printFlags(output(), true);178} else {179CommandLineFlags::printSetFlags(output());180}181}182183int PrintVMFlagsDCmd::num_arguments() {184ResourceMark rm;185PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);186if (dcmd != NULL) {187DCmdMark mark(dcmd);188return dcmd->_dcmdparser.num_arguments();189} else {190return 0;191}192}193194void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {195// load sun.misc.VMSupport196Symbol* klass = vmSymbols::sun_misc_VMSupport();197Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);198instanceKlassHandle ik (THREAD, k);199if (ik->should_be_initialized()) {200ik->initialize(THREAD);201}202if (HAS_PENDING_EXCEPTION) {203java_lang_Throwable::print(PENDING_EXCEPTION, output());204output()->cr();205CLEAR_PENDING_EXCEPTION;206return;207}208209// invoke the serializePropertiesToByteArray method210JavaValue result(T_OBJECT);211JavaCallArguments args;212213Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();214JavaCalls::call_static(&result,215ik,216vmSymbols::serializePropertiesToByteArray_name(),217signature,218&args,219THREAD);220if (HAS_PENDING_EXCEPTION) {221java_lang_Throwable::print(PENDING_EXCEPTION, output());222output()->cr();223CLEAR_PENDING_EXCEPTION;224return;225}226227// The result should be a [B228oop res = (oop)result.get_jobject();229assert(res->is_typeArray(), "just checking");230assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");231232// copy the bytes to the output stream233typeArrayOop ba = typeArrayOop(res);234jbyte* addr = typeArrayOop(res)->byte_at_addr(0);235output()->print_raw((const char*)addr, ba->length());236}237238VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :239DCmdWithParser(output, heap),240_date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {241_dcmdparser.add_dcmd_option(&_date);242}243244void VMUptimeDCmd::execute(DCmdSource source, TRAPS) {245if (_date.value()) {246output()->date_stamp(true, "", ": ");247}248output()->time_stamp().update_to(tty->time_stamp().ticks());249output()->stamp();250output()->print_cr(" s");251}252253int VMUptimeDCmd::num_arguments() {254ResourceMark rm;255VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);256if (dcmd != NULL) {257DCmdMark mark(dcmd);258return dcmd->_dcmdparser.num_arguments();259} else {260return 0;261}262}263264void SystemGCDCmd::execute(DCmdSource source, TRAPS) {265if (!DisableExplicitGC) {266Universe::heap()->collect(GCCause::_java_lang_system_gc);267} else {268output()->print_cr("Explicit GC is disabled, no GC has been performed.");269}270}271272void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) {273Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),274true, CHECK);275instanceKlassHandle klass(THREAD, k);276JavaValue result(T_VOID);277JavaCalls::call_static(&result, klass,278vmSymbols::run_finalization_name(),279vmSymbols::void_method_signature(), CHECK);280}281282void HeapInfoDCmd::execute(DCmdSource source, TRAPS) {283Universe::heap()->print_on(output());284}285286void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) {287ResourceMark rm;288289290Klass* k = SystemDictionary::resolve_or_null(291vmSymbols::finalizer_histogram_klass(), THREAD);292assert(k != NULL, "FinalizerHistogram class is not accessible");293294instanceKlassHandle klass(THREAD, k);295JavaValue result(T_ARRAY);296297// We are calling lang.ref.FinalizerHistogram.getFinalizerHistogram() method298// and expect it to return array of FinalizerHistogramEntry as Object[]299300JavaCalls::call_static(&result, klass,301vmSymbols::get_finalizer_histogram_name(),302vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK);303304objArrayOop result_oop = (objArrayOop) result.get_jobject();305if (result_oop->length() == 0) {306output()->print_cr("No instances waiting for finalization found");307return;308}309310oop foop = result_oop->obj_at(0);311InstanceKlass* ik = InstanceKlass::cast(foop->klass());312313fieldDescriptor count_fd, name_fd;314315Klass* count_res = ik->find_field(316vmSymbols::finalizer_histogram_entry_count_field(), vmSymbols::int_signature(), &count_fd);317318Klass* name_res = ik->find_field(319vmSymbols::finalizer_histogram_entry_name_field(), vmSymbols::string_signature(), &name_fd);320321assert(count_res != NULL && name_res != NULL, "Unexpected layout of FinalizerHistogramEntry");322323output()->print_cr("Unreachable instances waiting for finalization");324output()->print_cr("#instances class name");325output()->print_cr("-----------------------");326327for (int i = 0; i < result_oop->length(); ++i) {328oop element_oop = result_oop->obj_at(i);329oop str_oop = element_oop->obj_field(name_fd.offset());330char *name = java_lang_String::as_utf8_string(str_oop);331int count = element_oop->int_field(count_fd.offset());332output()->print_cr("%10d %s", count, name);333}334}335336#if INCLUDE_SERVICES // Heap dumping/inspection supported337HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :338DCmdWithParser(output, heap),339_filename("filename","Name of the dump file", "STRING",true),340_all("-all", "Dump all objects, including unreachable objects",341"BOOLEAN", false, "false") {342_dcmdparser.add_dcmd_option(&_all);343_dcmdparser.add_dcmd_argument(&_filename);344}345346void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {347// Request a full GC before heap dump if _all is false348// This helps reduces the amount of unreachable objects in the dump349// and makes it easier to browse.350HeapDumper dumper(!_all.value() /* request GC if _all is false*/);351int res = dumper.dump(_filename.value());352if (res == 0) {353output()->print_cr("Heap dump file created");354} else {355// heap dump failed356ResourceMark rm;357char* error = dumper.error_as_C_string();358if (error == NULL) {359output()->print_cr("Dump failed - reason unknown");360} else {361output()->print_cr("%s", error);362}363}364}365366int HeapDumpDCmd::num_arguments() {367ResourceMark rm;368HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);369if (dcmd != NULL) {370DCmdMark mark(dcmd);371return dcmd->_dcmdparser.num_arguments();372} else {373return 0;374}375}376377ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :378DCmdWithParser(output, heap),379_all("-all", "Inspect all objects, including unreachable objects",380"BOOLEAN", false, "false") {381_dcmdparser.add_dcmd_option(&_all);382}383384void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {385VM_GC_HeapInspection heapop(output(),386!_all.value() /* request full gc if false */);387VMThread::execute(&heapop);388}389390int ClassHistogramDCmd::num_arguments() {391ResourceMark rm;392ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);393if (dcmd != NULL) {394DCmdMark mark(dcmd);395return dcmd->_dcmdparser.num_arguments();396} else {397return 0;398}399}400401#define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"402ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :403DCmdWithParser(output, heap),404_csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",405"BOOLEAN", false, "false"),406_all("-all", "Show all columns",407"BOOLEAN", false, "false"),408_help("-help", "Show meaning of all the columns",409"BOOLEAN", false, "false"),410_columns("columns", "Comma-separated list of all the columns to show. "411"If not specified, the following columns are shown: " DEFAULT_COLUMNS,412"STRING", false) {413_dcmdparser.add_dcmd_option(&_all);414_dcmdparser.add_dcmd_option(&_csv);415_dcmdparser.add_dcmd_option(&_help);416_dcmdparser.add_dcmd_argument(&_columns);417}418419void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {420if (!UnlockDiagnosticVMOptions) {421output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions");422return;423}424425VM_GC_HeapInspection heapop(output(),426true /* request_full_gc */);427heapop.set_csv_format(_csv.value());428heapop.set_print_help(_help.value());429heapop.set_print_class_stats(true);430if (_all.value()) {431if (_columns.has_value()) {432output()->print_cr("Cannot specify -all and individual columns at the same time");433return;434} else {435heapop.set_columns(NULL);436}437} else {438if (_columns.has_value()) {439heapop.set_columns(_columns.value());440} else {441heapop.set_columns(DEFAULT_COLUMNS);442}443}444VMThread::execute(&heapop);445}446447int ClassStatsDCmd::num_arguments() {448ResourceMark rm;449ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);450if (dcmd != NULL) {451DCmdMark mark(dcmd);452return dcmd->_dcmdparser.num_arguments();453} else {454return 0;455}456}457#endif // INCLUDE_SERVICES458459ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :460DCmdWithParser(output, heap),461_locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {462_dcmdparser.add_dcmd_option(&_locks);463}464465void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) {466// thread stacks467VM_PrintThreads op1(output(), _locks.value());468VMThread::execute(&op1);469470// JNI global handles471VM_PrintJNI op2(output());472VMThread::execute(&op2);473474// Deadlock detection475VM_FindDeadlocks op3(output());476VMThread::execute(&op3);477}478479int ThreadDumpDCmd::num_arguments() {480ResourceMark rm;481ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);482if (dcmd != NULL) {483DCmdMark mark(dcmd);484return dcmd->_dcmdparser.num_arguments();485} else {486return 0;487}488}489490// Enhanced JMX Agent support491492JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :493494DCmdWithParser(output, heap_allocated),495496_config_file497("config.file",498"set com.sun.management.config.file", "STRING", false),499500_jmxremote_host501("jmxremote.host",502"set com.sun.management.jmxremote.host", "STRING", false),503504_jmxremote_port505("jmxremote.port",506"set com.sun.management.jmxremote.port", "STRING", false),507508_jmxremote_rmi_port509("jmxremote.rmi.port",510"set com.sun.management.jmxremote.rmi.port", "STRING", false),511512_jmxremote_ssl513("jmxremote.ssl",514"set com.sun.management.jmxremote.ssl", "STRING", false),515516_jmxremote_registry_ssl517("jmxremote.registry.ssl",518"set com.sun.management.jmxremote.registry.ssl", "STRING", false),519520_jmxremote_authenticate521("jmxremote.authenticate",522"set com.sun.management.jmxremote.authenticate", "STRING", false),523524_jmxremote_password_file525("jmxremote.password.file",526"set com.sun.management.jmxremote.password.file", "STRING", false),527528_jmxremote_access_file529("jmxremote.access.file",530"set com.sun.management.jmxremote.access.file", "STRING", false),531532_jmxremote_login_config533("jmxremote.login.config",534"set com.sun.management.jmxremote.login.config", "STRING", false),535536_jmxremote_ssl_enabled_cipher_suites537("jmxremote.ssl.enabled.cipher.suites",538"set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),539540_jmxremote_ssl_enabled_protocols541("jmxremote.ssl.enabled.protocols",542"set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),543544_jmxremote_ssl_need_client_auth545("jmxremote.ssl.need.client.auth",546"set com.sun.management.jmxremote.need.client.auth", "STRING", false),547548_jmxremote_ssl_config_file549("jmxremote.ssl.config.file",550"set com.sun.management.jmxremote.ssl_config_file", "STRING", false),551552// JDP Protocol support553_jmxremote_autodiscovery554("jmxremote.autodiscovery",555"set com.sun.management.jmxremote.autodiscovery", "STRING", false),556557_jdp_port558("jdp.port",559"set com.sun.management.jdp.port", "INT", false),560561_jdp_address562("jdp.address",563"set com.sun.management.jdp.address", "STRING", false),564565_jdp_source_addr566("jdp.source_addr",567"set com.sun.management.jdp.source_addr", "STRING", false),568569_jdp_ttl570("jdp.ttl",571"set com.sun.management.jdp.ttl", "INT", false),572573_jdp_pause574("jdp.pause",575"set com.sun.management.jdp.pause", "INT", false),576577_jdp_name578("jdp.name",579"set com.sun.management.jdp.name", "STRING", false)580581{582_dcmdparser.add_dcmd_option(&_config_file);583_dcmdparser.add_dcmd_option(&_jmxremote_host);584_dcmdparser.add_dcmd_option(&_jmxremote_port);585_dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);586_dcmdparser.add_dcmd_option(&_jmxremote_ssl);587_dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);588_dcmdparser.add_dcmd_option(&_jmxremote_authenticate);589_dcmdparser.add_dcmd_option(&_jmxremote_password_file);590_dcmdparser.add_dcmd_option(&_jmxremote_access_file);591_dcmdparser.add_dcmd_option(&_jmxremote_login_config);592_dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);593_dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);594_dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);595_dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);596_dcmdparser.add_dcmd_option(&_jmxremote_autodiscovery);597_dcmdparser.add_dcmd_option(&_jdp_port);598_dcmdparser.add_dcmd_option(&_jdp_address);599_dcmdparser.add_dcmd_option(&_jdp_source_addr);600_dcmdparser.add_dcmd_option(&_jdp_ttl);601_dcmdparser.add_dcmd_option(&_jdp_pause);602_dcmdparser.add_dcmd_option(&_jdp_name);603}604605606int JMXStartRemoteDCmd::num_arguments() {607ResourceMark rm;608JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);609if (dcmd != NULL) {610DCmdMark mark(dcmd);611return dcmd->_dcmdparser.num_arguments();612} else {613return 0;614}615}616617618void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) {619ResourceMark rm(THREAD);620HandleMark hm(THREAD);621622// Load and initialize the sun.management.Agent class623// invoke startRemoteManagementAgent(string) method to start624// the remote management server.625// throw java.lang.NoSuchMethodError if the method doesn't exist626627Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());628Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);629instanceKlassHandle ik (THREAD, k);630631JavaValue result(T_VOID);632633// Pass all command line arguments to java as key=value,...634// All checks are done on java side635636int len = 0;637stringStream options;638char comma[2] = {0,0};639640// Leave default values on Agent.class side and pass only641// agruments explicitly set by user. All arguments passed642// to jcmd override properties with the same name set by643// command line with -D or by managmenent.properties644// file.645#define PUT_OPTION(a) \646if ( (a).is_set() ){ \647options.print(\648( *((a).type()) == 'I' ) ? "%scom.sun.management.%s=%d" : "%scom.sun.management.%s=%s",\649comma, (a).name(), (a).value()); \650comma[0] = ','; \651}652653PUT_OPTION(_config_file);654PUT_OPTION(_jmxremote_host);655PUT_OPTION(_jmxremote_port);656PUT_OPTION(_jmxremote_rmi_port);657PUT_OPTION(_jmxremote_ssl);658PUT_OPTION(_jmxremote_registry_ssl);659PUT_OPTION(_jmxremote_authenticate);660PUT_OPTION(_jmxremote_password_file);661PUT_OPTION(_jmxremote_access_file);662PUT_OPTION(_jmxremote_login_config);663PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);664PUT_OPTION(_jmxremote_ssl_enabled_protocols);665PUT_OPTION(_jmxremote_ssl_need_client_auth);666PUT_OPTION(_jmxremote_ssl_config_file);667PUT_OPTION(_jmxremote_autodiscovery);668PUT_OPTION(_jdp_port);669PUT_OPTION(_jdp_address);670PUT_OPTION(_jdp_source_addr);671PUT_OPTION(_jdp_ttl);672PUT_OPTION(_jdp_pause);673PUT_OPTION(_jdp_name);674675#undef PUT_OPTION676677Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);678JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);679}680681JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :682DCmd(output, heap_allocated) {683// do nothing684}685686void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {687ResourceMark rm(THREAD);688HandleMark hm(THREAD);689690// Load and initialize the sun.management.Agent class691// invoke startLocalManagementAgent(void) method to start692// the local management server693// throw java.lang.NoSuchMethodError if method doesn't exist694695Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());696Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);697instanceKlassHandle ik (THREAD, k);698699JavaValue result(T_VOID);700JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);701}702703void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {704ResourceMark rm(THREAD);705HandleMark hm(THREAD);706707// Load and initialize the sun.management.Agent class708// invoke stopRemoteManagementAgent method to stop the709// management server710// throw java.lang.NoSuchMethodError if method doesn't exist711712Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());713Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);714instanceKlassHandle ik (THREAD, k);715716JavaValue result(T_VOID);717JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);718}719720VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :721DCmd(output, heap_allocated) {722// do nothing723}724725void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {726os::print_dll_info(output());727output()->cr();728}729730void RotateGCLogDCmd::execute(DCmdSource source, TRAPS) {731if (UseGCLogFileRotation) {732VM_RotateGCLog rotateop(output());733VMThread::execute(&rotateop);734} else {735output()->print_cr("Target VM does not support GC log file rotation.");736}737}738739740