1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/classLoaderStats.hpp"
  28 #include "classfile/compactHashtable.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/directivesParser.hpp"
  31 #include "gc/shared/vmGCOperations.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "oops/objArrayOop.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/typeArrayOop.inline.hpp"
  36 #include "runtime/flags/jvmFlag.hpp"
  37 #include "runtime/handles.inline.hpp"
  38 #include "runtime/javaCalls.hpp"
  39 #include "runtime/os.hpp"
  40 #include "services/diagnosticArgument.hpp"
  41 #include "services/diagnosticCommand.hpp"
  42 #include "services/diagnosticFramework.hpp"
  43 #include "services/heapDumper.hpp"
  44 #include "services/management.hpp"
  45 #include "services/writeableFlags.hpp"
  46 #include "utilities/debug.hpp"
  47 #include "utilities/formatBuffer.hpp"
  48 #include "utilities/macros.hpp"
  49 
  50 
  51 static void loadAgentModule(TRAPS) {
  52   ResourceMark rm(THREAD);
  53   HandleMark hm(THREAD);
  54 
  55   JavaValue result(T_OBJECT);
  56   Handle h_module_name = java_lang_String::create_from_str("jdk.management.agent", CHECK);
  57   JavaCalls::call_static(&result,
  58                          SystemDictionary::module_Modules_klass(),
  59                          vmSymbols::loadModule_name(),
  60                          vmSymbols::loadModule_signature(),
  61                          h_module_name,
  62                          THREAD);
  63 }
  64 
  65 void DCmdRegistrant::register_dcmds(){
  66   // Registration of the diagnostic commands
  67   // First argument specifies which interfaces will export the command
  68   // Second argument specifies if the command is enabled
  69   // Third  argument specifies if the command is hidden
  70   uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI
  71                          | DCmd_Source_MBean;
  72   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false));
  73   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false));
  74   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false));
  75   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
  76   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
  77   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
  78   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
  79   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
  80   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
  81   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
  82   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
  83   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
  84   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
  85 #if INCLUDE_SERVICES
  86   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
  87   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
  88   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
  89   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
  90   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
  91   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
  92   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
  93   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<MetaspaceDCmd>(full_export, true, false));
  94 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
  95   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
  96 #endif // INCLUDE_JVMTI
  97 #endif // INCLUDE_SERVICES
  98 #if INCLUDE_JVMTI
  99   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
 100 #endif // INCLUDE_JVMTI
 101   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
 102   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
 103   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
 104   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
 105   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
 106   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
 107   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
 108 
 109   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
 110   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
 111   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
 112   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
 113 
 114   // Enhanced JMX Agent Support
 115   // These commands won't be exported via the DiagnosticCommandMBean until an
 116   // appropriate permission is created for them
 117   uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
 118   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
 119   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
 120   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
 121   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
 122 
 123 }
 124 
 125 #ifndef HAVE_EXTRA_DCMD
 126 void DCmdRegistrant::register_dcmds_ext(){
 127    // Do nothing here
 128 }
 129 #endif
 130 
 131 
 132 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
 133   _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
 134   _cmd("command name", "The name of the command for which we want help",
 135         "STRING", false) {
 136   _dcmdparser.add_dcmd_option(&_all);
 137   _dcmdparser.add_dcmd_argument(&_cmd);
 138 };
 139 
 140 
 141 static int compare_strings(const char** s1, const char** s2) {
 142   return ::strcmp(*s1, *s2);
 143 }
 144 
 145 void HelpDCmd::execute(DCmdSource source, TRAPS) {
 146   if (_all.value()) {
 147     GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
 148     cmd_list->sort(compare_strings);
 149     for (int i = 0; i < cmd_list->length(); i++) {
 150       DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
 151                                                   strlen(cmd_list->at(i)));
 152       output()->print_cr("%s%s", factory->name(),
 153                          factory->is_enabled() ? "" : " [disabled]");
 154       output()->print_cr("\t%s", factory->description());
 155       output()->cr();
 156       factory = factory->next();
 157     }
 158   } else if (_cmd.has_value()) {
 159     DCmd* cmd = NULL;
 160     DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),
 161                                                 strlen(_cmd.value()));
 162     if (factory != NULL) {
 163       output()->print_cr("%s%s", factory->name(),
 164                          factory->is_enabled() ? "" : " [disabled]");
 165       output()->print_cr("%s", factory->description());
 166       output()->print_cr("\nImpact: %s", factory->impact());
 167       JavaPermission p = factory->permission();
 168       if(p._class != NULL) {
 169         if(p._action != NULL) {
 170           output()->print_cr("\nPermission: %s(%s, %s)",
 171                   p._class, p._name == NULL ? "null" : p._name, p._action);
 172         } else {
 173           output()->print_cr("\nPermission: %s(%s)",
 174                   p._class, p._name == NULL ? "null" : p._name);
 175         }
 176       }
 177       output()->cr();
 178       cmd = factory->create_resource_instance(output());
 179       if (cmd != NULL) {
 180         DCmdMark mark(cmd);
 181         cmd->print_help(factory->name());
 182       }
 183     } else {
 184       output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
 185     }
 186   } else {
 187     output()->print_cr("The following commands are available:");
 188     GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
 189     cmd_list->sort(compare_strings);
 190     for (int i = 0; i < cmd_list->length(); i++) {
 191       DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
 192                                                   strlen(cmd_list->at(i)));
 193       output()->print_cr("%s%s", factory->name(),
 194                          factory->is_enabled() ? "" : " [disabled]");
 195       factory = factory->_next;
 196     }
 197     output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
 198   }
 199 }
 200 
 201 int HelpDCmd::num_arguments() {
 202   ResourceMark rm;
 203   HelpDCmd* dcmd = new HelpDCmd(NULL, false);
 204   if (dcmd != NULL) {
 205     DCmdMark mark(dcmd);
 206     return dcmd->_dcmdparser.num_arguments();
 207   } else {
 208     return 0;
 209   }
 210 }
 211 
 212 void VersionDCmd::execute(DCmdSource source, TRAPS) {
 213   output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
 214           Abstract_VM_Version::vm_release());
 215   JDK_Version jdk_version = JDK_Version::current();
 216   if (jdk_version.patch_version() > 0) {
 217     output()->print_cr("JDK %d.%d.%d.%d", jdk_version.major_version(),
 218             jdk_version.minor_version(), jdk_version.security_version(),
 219             jdk_version.patch_version());
 220   } else {
 221     output()->print_cr("JDK %d.%d.%d", jdk_version.major_version(),
 222             jdk_version.minor_version(), jdk_version.security_version());
 223   }
 224 }
 225 
 226 PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
 227                                    DCmdWithParser(output, heap),
 228   _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
 229   _dcmdparser.add_dcmd_option(&_all);
 230 }
 231 
 232 void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {
 233   if (_all.value()) {
 234     JVMFlag::printFlags(output(), true);
 235   } else {
 236     JVMFlag::printSetFlags(output());
 237   }
 238 }
 239 
 240 int PrintVMFlagsDCmd::num_arguments() {
 241     ResourceMark rm;
 242     PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
 243     if (dcmd != NULL) {
 244       DCmdMark mark(dcmd);
 245       return dcmd->_dcmdparser.num_arguments();
 246     } else {
 247       return 0;
 248     }
 249 }
 250 
 251 SetVMFlagDCmd::SetVMFlagDCmd(outputStream* output, bool heap) :
 252                                    DCmdWithParser(output, heap),
 253   _flag("flag name", "The name of the flag we want to set",
 254         "STRING", true),
 255   _value("string value", "The value we want to set", "STRING", false) {
 256   _dcmdparser.add_dcmd_argument(&_flag);
 257   _dcmdparser.add_dcmd_argument(&_value);
 258 }
 259 
 260 void SetVMFlagDCmd::execute(DCmdSource source, TRAPS) {
 261   const char* val = NULL;
 262   if (_value.value() != NULL) {
 263     val = _value.value();
 264   }
 265 
 266   FormatBuffer<80> err_msg("%s", "");
 267   int ret = WriteableFlags::set_flag(_flag.value(), val, JVMFlag::MANAGEMENT, err_msg);
 268 
 269   if (ret != JVMFlag::SUCCESS) {
 270     output()->print_cr("%s", err_msg.buffer());
 271   }
 272 }
 273 
 274 int SetVMFlagDCmd::num_arguments() {
 275   ResourceMark rm;
 276   SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
 277   if (dcmd != NULL) {
 278     DCmdMark mark(dcmd);
 279     return dcmd->_dcmdparser.num_arguments();
 280   } else {
 281     return 0;
 282   }
 283 }
 284 
 285 void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
 286   if (JvmtiExport::should_post_data_dump()) {
 287     JvmtiExport::post_data_dump();
 288   }
 289 }
 290 
 291 #if INCLUDE_SERVICES
 292 JVMTIAgentLoadDCmd::JVMTIAgentLoadDCmd(outputStream* output, bool heap) :
 293                                        DCmdWithParser(output, heap),
 294   _libpath("library path", "Absolute path of the JVMTI agent to load.",
 295            "STRING", true),
 296   _option("agent option", "Option string to pass the agent.", "STRING", false) {
 297   _dcmdparser.add_dcmd_argument(&_libpath);
 298   _dcmdparser.add_dcmd_argument(&_option);
 299 }
 300 
 301 void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) {
 302 
 303   if (_libpath.value() == NULL) {
 304     output()->print_cr("JVMTI.agent_load dcmd needs library path.");
 305     return;
 306   }
 307 
 308   char *suffix = strrchr(_libpath.value(), '.');
 309   bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
 310 
 311   if (is_java_agent) {
 312     if (_option.value() == NULL) {
 313       JvmtiExport::load_agent_library("instrument", "false",
 314                                       _libpath.value(), output());
 315     } else {
 316       size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
 317       if (opt_len > 4096) {
 318         output()->print_cr("JVMTI agent attach failed: Options is too long.");
 319         return;
 320       }
 321 
 322       char *opt = (char *)os::malloc(opt_len, mtInternal);
 323       if (opt == NULL) {
 324         output()->print_cr("JVMTI agent attach failed: "
 325                            "Could not allocate " SIZE_FORMAT " bytes for argument.",
 326                            opt_len);
 327         return;
 328       }
 329 
 330       jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
 331       JvmtiExport::load_agent_library("instrument", "false", opt, output());
 332 
 333       os::free(opt);
 334     }
 335   } else {
 336     JvmtiExport::load_agent_library(_libpath.value(), "true",
 337                                     _option.value(), output());
 338   }
 339 }
 340 
 341 int JVMTIAgentLoadDCmd::num_arguments() {
 342   ResourceMark rm;
 343   JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
 344   if (dcmd != NULL) {
 345     DCmdMark mark(dcmd);
 346     return dcmd->_dcmdparser.num_arguments();
 347   } else {
 348     return 0;
 349   }
 350 }
 351 #endif // INCLUDE_SERVICES
 352 
 353 void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
 354   // load VMSupport
 355   Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport();
 356   Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
 357   InstanceKlass* ik = InstanceKlass::cast(k);
 358   if (ik->should_be_initialized()) {
 359     ik->initialize(THREAD);
 360   }
 361   if (HAS_PENDING_EXCEPTION) {
 362     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 363     output()->cr();
 364     CLEAR_PENDING_EXCEPTION;
 365     return;
 366   }
 367 
 368   // invoke the serializePropertiesToByteArray method
 369   JavaValue result(T_OBJECT);
 370   JavaCallArguments args;
 371 
 372   Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
 373   JavaCalls::call_static(&result,
 374                          ik,
 375                          vmSymbols::serializePropertiesToByteArray_name(),
 376                          signature,
 377                          &args,
 378                          THREAD);
 379   if (HAS_PENDING_EXCEPTION) {
 380     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 381     output()->cr();
 382     CLEAR_PENDING_EXCEPTION;
 383     return;
 384   }
 385 
 386   // The result should be a [B
 387   oop res = (oop)result.get_jobject();
 388   assert(res->is_typeArray(), "just checking");
 389   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
 390 
 391   // copy the bytes to the output stream
 392   typeArrayOop ba = typeArrayOop(res);
 393   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
 394   output()->print_raw((const char*)addr, ba->length());
 395 }
 396 
 397 VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
 398                            DCmdWithParser(output, heap),
 399   _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
 400   _dcmdparser.add_dcmd_option(&_date);
 401 }
 402 
 403 void VMUptimeDCmd::execute(DCmdSource source, TRAPS) {
 404   if (_date.value()) {
 405     output()->date_stamp(true, "", ": ");
 406   }
 407   output()->time_stamp().update_to(tty->time_stamp().ticks());
 408   output()->stamp();
 409   output()->print_cr(" s");
 410 }
 411 
 412 int VMUptimeDCmd::num_arguments() {
 413   ResourceMark rm;
 414   VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
 415   if (dcmd != NULL) {
 416     DCmdMark mark(dcmd);
 417     return dcmd->_dcmdparser.num_arguments();
 418   } else {
 419     return 0;
 420   }
 421 }
 422 
 423 void VMInfoDCmd::execute(DCmdSource source, TRAPS) {
 424   VMError::print_vm_info(_output);
 425 }
 426 
 427 void SystemGCDCmd::execute(DCmdSource source, TRAPS) {
 428   Universe::heap()->collect(GCCause::_dcmd_gc_run);
 429 }
 430 
 431 void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) {
 432   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
 433                                                  true, CHECK);
 434   JavaValue result(T_VOID);
 435   JavaCalls::call_static(&result, k,
 436                          vmSymbols::run_finalization_name(),
 437                          vmSymbols::void_method_signature(), CHECK);
 438 }
 439 
 440 void HeapInfoDCmd::execute(DCmdSource source, TRAPS) {
 441   MutexLocker hl(Heap_lock);
 442   Universe::heap()->print_on(output());
 443 }
 444 
 445 void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) {
 446   ResourceMark rm;
 447 
 448   Klass* k = SystemDictionary::resolve_or_fail(
 449     vmSymbols::finalizer_histogram_klass(), true, CHECK);
 450 
 451   JavaValue result(T_ARRAY);
 452 
 453   // We are calling lang.ref.FinalizerHistogram.getFinalizerHistogram() method
 454   // and expect it to return array of FinalizerHistogramEntry as Object[]
 455 
 456   JavaCalls::call_static(&result, k,
 457                          vmSymbols::get_finalizer_histogram_name(),
 458                          vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK);
 459 
 460   objArrayOop result_oop = (objArrayOop) result.get_jobject();
 461   if (result_oop->length() == 0) {
 462     output()->print_cr("No instances waiting for finalization found");
 463     return;
 464   }
 465 
 466   oop foop = result_oop->obj_at(0);
 467   InstanceKlass* ik = InstanceKlass::cast(foop->klass());
 468 
 469   fieldDescriptor count_fd, name_fd;
 470 
 471   Klass* count_res = ik->find_field(
 472     vmSymbols::finalizer_histogram_entry_count_field(), vmSymbols::int_signature(), &count_fd);
 473 
 474   Klass* name_res = ik->find_field(
 475     vmSymbols::finalizer_histogram_entry_name_field(), vmSymbols::string_signature(), &name_fd);
 476 
 477   assert(count_res != NULL && name_res != NULL, "Unexpected layout of FinalizerHistogramEntry");
 478 
 479   output()->print_cr("Unreachable instances waiting for finalization");
 480   output()->print_cr("#instances  class name");
 481   output()->print_cr("-----------------------");
 482 
 483   for (int i = 0; i < result_oop->length(); ++i) {
 484     oop element_oop = result_oop->obj_at(i);
 485     oop str_oop = element_oop->obj_field(name_fd.offset());
 486     char *name = java_lang_String::as_utf8_string(str_oop);
 487     int count = element_oop->int_field(count_fd.offset());
 488     output()->print_cr("%10d  %s", count, name);
 489   }
 490 }
 491 
 492 #if INCLUDE_SERVICES // Heap dumping/inspection supported
 493 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
 494                            DCmdWithParser(output, heap),
 495   _filename("filename","Name of the dump file", "STRING",true),
 496   _all("-all", "Dump all objects, including unreachable objects",
 497        "BOOLEAN", false, "false") {
 498   _dcmdparser.add_dcmd_option(&_all);
 499   _dcmdparser.add_dcmd_argument(&_filename);
 500 }
 501 
 502 void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {
 503   // Request a full GC before heap dump if _all is false
 504   // This helps reduces the amount of unreachable objects in the dump
 505   // and makes it easier to browse.
 506   HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
 507   int res = dumper.dump(_filename.value());
 508   if (res == 0) {
 509     output()->print_cr("Heap dump file created");
 510   } else {
 511     // heap dump failed
 512     ResourceMark rm;
 513     char* error = dumper.error_as_C_string();
 514     if (error == NULL) {
 515       output()->print_cr("Dump failed - reason unknown");
 516     } else {
 517       output()->print_cr("%s", error);
 518     }
 519   }
 520 }
 521 
 522 int HeapDumpDCmd::num_arguments() {
 523   ResourceMark rm;
 524   HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
 525   if (dcmd != NULL) {
 526     DCmdMark mark(dcmd);
 527     return dcmd->_dcmdparser.num_arguments();
 528   } else {
 529     return 0;
 530   }
 531 }
 532 
 533 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
 534                                        DCmdWithParser(output, heap),
 535   _all("-all", "Inspect all objects, including unreachable objects",
 536        "BOOLEAN", false, "false") {
 537   _dcmdparser.add_dcmd_option(&_all);
 538 }
 539 
 540 void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
 541   VM_GC_HeapInspection heapop(output(),
 542                               !_all.value() /* request full gc if false */);
 543   VMThread::execute(&heapop);
 544 }
 545 
 546 int ClassHistogramDCmd::num_arguments() {
 547   ResourceMark rm;
 548   ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
 549   if (dcmd != NULL) {
 550     DCmdMark mark(dcmd);
 551     return dcmd->_dcmdparser.num_arguments();
 552   } else {
 553     return 0;
 554   }
 555 }
 556 
 557 #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
 558 ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
 559                                        DCmdWithParser(output, heap),
 560   _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
 561        "BOOLEAN", false, "false"),
 562   _all("-all", "Show all columns",
 563        "BOOLEAN", false, "false"),
 564   _help("-help", "Show meaning of all the columns",
 565        "BOOLEAN", false, "false"),
 566   _columns("columns", "Comma-separated list of all the columns to show. "
 567            "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
 568            "STRING", false) {
 569   _dcmdparser.add_dcmd_option(&_all);
 570   _dcmdparser.add_dcmd_option(&_csv);
 571   _dcmdparser.add_dcmd_option(&_help);
 572   _dcmdparser.add_dcmd_argument(&_columns);
 573 }
 574 
 575 void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
 576   VM_GC_HeapInspection heapop(output(),
 577                               true /* request_full_gc */);
 578   heapop.set_csv_format(_csv.value());
 579   heapop.set_print_help(_help.value());
 580   heapop.set_print_class_stats(true);
 581   if (_all.value()) {
 582     if (_columns.has_value()) {
 583       output()->print_cr("Cannot specify -all and individual columns at the same time");
 584       return;
 585     } else {
 586       heapop.set_columns(NULL);
 587     }
 588   } else {
 589     if (_columns.has_value()) {
 590       heapop.set_columns(_columns.value());
 591     } else {
 592       heapop.set_columns(DEFAULT_COLUMNS);
 593     }
 594   }
 595   VMThread::execute(&heapop);
 596 }
 597 
 598 int ClassStatsDCmd::num_arguments() {
 599   ResourceMark rm;
 600   ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);
 601   if (dcmd != NULL) {
 602     DCmdMark mark(dcmd);
 603     return dcmd->_dcmdparser.num_arguments();
 604   } else {
 605     return 0;
 606   }
 607 }
 608 #endif // INCLUDE_SERVICES
 609 
 610 ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
 611                                DCmdWithParser(output, heap),
 612   _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
 613   _dcmdparser.add_dcmd_option(&_locks);
 614 }
 615 
 616 void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) {
 617   // thread stacks
 618   VM_PrintThreads op1(output(), _locks.value());
 619   VMThread::execute(&op1);
 620 
 621   // JNI global handles
 622   VM_PrintJNI op2(output());
 623   VMThread::execute(&op2);
 624 
 625   // Deadlock detection
 626   VM_FindDeadlocks op3(output());
 627   VMThread::execute(&op3);
 628 }
 629 
 630 int ThreadDumpDCmd::num_arguments() {
 631   ResourceMark rm;
 632   ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
 633   if (dcmd != NULL) {
 634     DCmdMark mark(dcmd);
 635     return dcmd->_dcmdparser.num_arguments();
 636   } else {
 637     return 0;
 638   }
 639 }
 640 
 641 // Enhanced JMX Agent support
 642 
 643 JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
 644 
 645   DCmdWithParser(output, heap_allocated),
 646 
 647   _config_file
 648   ("config.file",
 649    "set com.sun.management.config.file", "STRING", false),
 650 
 651   _jmxremote_host
 652   ("jmxremote.host",
 653    "set com.sun.management.jmxremote.host", "STRING", false),
 654 
 655   _jmxremote_port
 656   ("jmxremote.port",
 657    "set com.sun.management.jmxremote.port", "STRING", false),
 658 
 659   _jmxremote_rmi_port
 660   ("jmxremote.rmi.port",
 661    "set com.sun.management.jmxremote.rmi.port", "STRING", false),
 662 
 663   _jmxremote_ssl
 664   ("jmxremote.ssl",
 665    "set com.sun.management.jmxremote.ssl", "STRING", false),
 666 
 667   _jmxremote_registry_ssl
 668   ("jmxremote.registry.ssl",
 669    "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
 670 
 671   _jmxremote_authenticate
 672   ("jmxremote.authenticate",
 673    "set com.sun.management.jmxremote.authenticate", "STRING", false),
 674 
 675   _jmxremote_password_file
 676   ("jmxremote.password.file",
 677    "set com.sun.management.jmxremote.password.file", "STRING", false),
 678 
 679   _jmxremote_access_file
 680   ("jmxremote.access.file",
 681    "set com.sun.management.jmxremote.access.file", "STRING", false),
 682 
 683   _jmxremote_login_config
 684   ("jmxremote.login.config",
 685    "set com.sun.management.jmxremote.login.config", "STRING", false),
 686 
 687   _jmxremote_ssl_enabled_cipher_suites
 688   ("jmxremote.ssl.enabled.cipher.suites",
 689    "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
 690 
 691   _jmxremote_ssl_enabled_protocols
 692   ("jmxremote.ssl.enabled.protocols",
 693    "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
 694 
 695   _jmxremote_ssl_need_client_auth
 696   ("jmxremote.ssl.need.client.auth",
 697    "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
 698 
 699   _jmxremote_ssl_config_file
 700   ("jmxremote.ssl.config.file",
 701    "set com.sun.management.jmxremote.ssl_config_file", "STRING", false),
 702 
 703 // JDP Protocol support
 704   _jmxremote_autodiscovery
 705   ("jmxremote.autodiscovery",
 706    "set com.sun.management.jmxremote.autodiscovery", "STRING", false),
 707 
 708    _jdp_port
 709   ("jdp.port",
 710    "set com.sun.management.jdp.port", "INT", false),
 711 
 712    _jdp_address
 713   ("jdp.address",
 714    "set com.sun.management.jdp.address", "STRING", false),
 715 
 716    _jdp_source_addr
 717   ("jdp.source_addr",
 718    "set com.sun.management.jdp.source_addr", "STRING", false),
 719 
 720    _jdp_ttl
 721   ("jdp.ttl",
 722    "set com.sun.management.jdp.ttl", "INT", false),
 723 
 724    _jdp_pause
 725   ("jdp.pause",
 726    "set com.sun.management.jdp.pause", "INT", false),
 727 
 728    _jdp_name
 729   ("jdp.name",
 730    "set com.sun.management.jdp.name", "STRING", false)
 731 
 732   {
 733     _dcmdparser.add_dcmd_option(&_config_file);
 734     _dcmdparser.add_dcmd_option(&_jmxremote_host);
 735     _dcmdparser.add_dcmd_option(&_jmxremote_port);
 736     _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
 737     _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
 738     _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
 739     _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
 740     _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
 741     _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
 742     _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
 743     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
 744     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
 745     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
 746     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
 747     _dcmdparser.add_dcmd_option(&_jmxremote_autodiscovery);
 748     _dcmdparser.add_dcmd_option(&_jdp_port);
 749     _dcmdparser.add_dcmd_option(&_jdp_address);
 750     _dcmdparser.add_dcmd_option(&_jdp_source_addr);
 751     _dcmdparser.add_dcmd_option(&_jdp_ttl);
 752     _dcmdparser.add_dcmd_option(&_jdp_pause);
 753     _dcmdparser.add_dcmd_option(&_jdp_name);
 754 }
 755 
 756 
 757 int JMXStartRemoteDCmd::num_arguments() {
 758   ResourceMark rm;
 759   JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
 760   if (dcmd != NULL) {
 761     DCmdMark mark(dcmd);
 762     return dcmd->_dcmdparser.num_arguments();
 763   } else {
 764     return 0;
 765   }
 766 }
 767 
 768 
 769 void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) {
 770     ResourceMark rm(THREAD);
 771     HandleMark hm(THREAD);
 772 
 773     // Load and initialize the jdk.internal.agent.Agent class
 774     // invoke startRemoteManagementAgent(string) method to start
 775     // the remote management server.
 776     // throw java.lang.NoSuchMethodError if the method doesn't exist
 777 
 778     loadAgentModule(CHECK);
 779     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 780     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
 781 
 782     JavaValue result(T_VOID);
 783 
 784     // Pass all command line arguments to java as key=value,...
 785     // All checks are done on java side
 786 
 787     int len = 0;
 788     stringStream options;
 789     char comma[2] = {0,0};
 790 
 791     // Leave default values on Agent.class side and pass only
 792     // agruments explicitly set by user. All arguments passed
 793     // to jcmd override properties with the same name set by
 794     // command line with -D or by managmenent.properties
 795     // file.
 796 #define PUT_OPTION(a) \
 797     do { \
 798         if ( (a).is_set() ){ \
 799             if ( *((a).type()) == 'I' ) { \
 800                 options.print("%scom.sun.management.%s=" JLONG_FORMAT, comma, (a).name(), (jlong)((a).value())); \
 801             } else { \
 802                 options.print("%scom.sun.management.%s=%s", comma, (a).name(), (char*)((a).value())); \
 803             } \
 804             comma[0] = ','; \
 805         }\
 806     } while(0);
 807 
 808 
 809     PUT_OPTION(_config_file);
 810     PUT_OPTION(_jmxremote_host);
 811     PUT_OPTION(_jmxremote_port);
 812     PUT_OPTION(_jmxremote_rmi_port);
 813     PUT_OPTION(_jmxremote_ssl);
 814     PUT_OPTION(_jmxremote_registry_ssl);
 815     PUT_OPTION(_jmxremote_authenticate);
 816     PUT_OPTION(_jmxremote_password_file);
 817     PUT_OPTION(_jmxremote_access_file);
 818     PUT_OPTION(_jmxremote_login_config);
 819     PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
 820     PUT_OPTION(_jmxremote_ssl_enabled_protocols);
 821     PUT_OPTION(_jmxremote_ssl_need_client_auth);
 822     PUT_OPTION(_jmxremote_ssl_config_file);
 823     PUT_OPTION(_jmxremote_autodiscovery);
 824     PUT_OPTION(_jdp_port);
 825     PUT_OPTION(_jdp_address);
 826     PUT_OPTION(_jdp_source_addr);
 827     PUT_OPTION(_jdp_ttl);
 828     PUT_OPTION(_jdp_pause);
 829     PUT_OPTION(_jdp_name);
 830 
 831 #undef PUT_OPTION
 832 
 833     Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
 834     JavaCalls::call_static(&result, k, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
 835 }
 836 
 837 JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
 838   DCmd(output, heap_allocated) {
 839   // do nothing
 840 }
 841 
 842 void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {
 843     ResourceMark rm(THREAD);
 844     HandleMark hm(THREAD);
 845 
 846     // Load and initialize the jdk.internal.agent.Agent class
 847     // invoke startLocalManagementAgent(void) method to start
 848     // the local management server
 849     // throw java.lang.NoSuchMethodError if method doesn't exist
 850 
 851     loadAgentModule(CHECK);
 852     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 853     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
 854 
 855     JavaValue result(T_VOID);
 856     JavaCalls::call_static(&result, k, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
 857 }
 858 
 859 void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {
 860     ResourceMark rm(THREAD);
 861     HandleMark hm(THREAD);
 862 
 863     // Load and initialize the jdk.internal.agent.Agent class
 864     // invoke stopRemoteManagementAgent method to stop the
 865     // management server
 866     // throw java.lang.NoSuchMethodError if method doesn't exist
 867 
 868     loadAgentModule(CHECK);
 869     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 870     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
 871 
 872     JavaValue result(T_VOID);
 873     JavaCalls::call_static(&result, k, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
 874 }
 875 
 876 JMXStatusDCmd::JMXStatusDCmd(outputStream *output, bool heap_allocated) :
 877   DCmd(output, heap_allocated) {
 878   // do nothing
 879 }
 880 
 881 void JMXStatusDCmd::execute(DCmdSource source, TRAPS) {
 882   ResourceMark rm(THREAD);
 883   HandleMark hm(THREAD);
 884 
 885   // Load and initialize the jdk.internal.agent.Agent class
 886   // invoke getManagementAgentStatus() method to generate the status info
 887   // throw java.lang.NoSuchMethodError if method doesn't exist
 888 
 889   loadAgentModule(CHECK);
 890   Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 891   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
 892 
 893   JavaValue result(T_OBJECT);
 894   JavaCalls::call_static(&result, k, vmSymbols::getAgentStatus_name(), vmSymbols::void_string_signature(), CHECK);
 895 
 896   jvalue* jv = (jvalue*) result.get_value_addr();
 897   oop str = (oop) jv->l;
 898   if (str != NULL) {
 899       char* out = java_lang_String::as_utf8_string(str);
 900       if (out) {
 901           output()->print_cr("%s", out);
 902           return;
 903       }
 904   }
 905   output()->print_cr("Error obtaining management agent status");
 906 }
 907 
 908 VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :
 909   DCmd(output, heap_allocated) {
 910   // do nothing
 911 }
 912 
 913 void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {
 914   os::print_dll_info(output());
 915   output()->cr();
 916 }
 917 
 918 void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
 919   VM_PrintCompileQueue printCompileQueueOp(output());
 920   VMThread::execute(&printCompileQueueOp);
 921 }
 922 
 923 void CodeListDCmd::execute(DCmdSource source, TRAPS) {
 924   CodeCache::print_codelist(output());
 925 }
 926 
 927 void CodeCacheDCmd::execute(DCmdSource source, TRAPS) {
 928   CodeCache::print_layout(output());
 929 }
 930 
 931 //---<  BEGIN  >--- CodeHeap State Analytics.
 932 CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) :
 933                                              DCmdWithParser(output, heap),
 934   _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"),
 935   _granularity("granularity", "Detail level - smaller value -> more detail", "STRING", false, "4096") {
 936   _dcmdparser.add_dcmd_argument(&_function);
 937   _dcmdparser.add_dcmd_argument(&_granularity);
 938 }
 939 
 940 void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) {
 941   CompileBroker::print_heapinfo(output(), _function.value(), _granularity.value());
 942 }
 943 
 944 int CodeHeapAnalyticsDCmd::num_arguments() {
 945   ResourceMark rm;
 946   CodeHeapAnalyticsDCmd* dcmd = new CodeHeapAnalyticsDCmd(NULL, false);
 947   if (dcmd != NULL) {
 948     DCmdMark mark(dcmd);
 949     return dcmd->_dcmdparser.num_arguments();
 950   } else {
 951     return 0;
 952   }
 953 }
 954 //---<  END  >--- CodeHeap State Analytics.
 955 
 956 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) {
 957   DirectivesStack::print(output());
 958 }
 959 
 960 CompilerDirectivesAddDCmd::CompilerDirectivesAddDCmd(outputStream* output, bool heap) :
 961                            DCmdWithParser(output, heap),
 962   _filename("filename","Name of the directives file", "STRING",true) {
 963   _dcmdparser.add_dcmd_argument(&_filename);
 964 }
 965 
 966 void CompilerDirectivesAddDCmd::execute(DCmdSource source, TRAPS) {
 967   DirectivesParser::parse_from_file(_filename.value(), output());
 968 }
 969 
 970 int CompilerDirectivesAddDCmd::num_arguments() {
 971   ResourceMark rm;
 972   CompilerDirectivesAddDCmd* dcmd = new CompilerDirectivesAddDCmd(NULL, false);
 973   if (dcmd != NULL) {
 974     DCmdMark mark(dcmd);
 975     return dcmd->_dcmdparser.num_arguments();
 976   } else {
 977     return 0;
 978   }
 979 }
 980 
 981 void CompilerDirectivesRemoveDCmd::execute(DCmdSource source, TRAPS) {
 982   DirectivesStack::pop(1);
 983 }
 984 
 985 void CompilerDirectivesClearDCmd::execute(DCmdSource source, TRAPS) {
 986   DirectivesStack::clear();
 987 }
 988 #if INCLUDE_SERVICES
 989 ClassHierarchyDCmd::ClassHierarchyDCmd(outputStream* output, bool heap) :
 990                                        DCmdWithParser(output, heap),
 991   _print_interfaces("-i", "Inherited interfaces should be printed.", "BOOLEAN", false, "false"),
 992   _print_subclasses("-s", "If a classname is specified, print its subclasses. "
 993                     "Otherwise only its superclasses are printed.", "BOOLEAN", false, "false"),
 994   _classname("classname", "Name of class whose hierarchy should be printed. "
 995              "If not specified, all class hierarchies are printed.",
 996              "STRING", false) {
 997   _dcmdparser.add_dcmd_option(&_print_interfaces);
 998   _dcmdparser.add_dcmd_option(&_print_subclasses);
 999   _dcmdparser.add_dcmd_argument(&_classname);
1000 }
1001 
1002 void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
1003   VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
1004                                                _print_subclasses.value(), _classname.value());
1005   VMThread::execute(&printClassHierarchyOp);
1006 }
1007 
1008 int ClassHierarchyDCmd::num_arguments() {
1009   ResourceMark rm;
1010   ClassHierarchyDCmd* dcmd = new ClassHierarchyDCmd(NULL, false);
1011   if (dcmd != NULL) {
1012     DCmdMark mark(dcmd);
1013     return dcmd->_dcmdparser.num_arguments();
1014   } else {
1015     return 0;
1016   }
1017 }
1018 
1019 #endif
1020 
1021 class VM_DumpTouchedMethods : public VM_Operation {
1022 private:
1023   outputStream* _out;
1024 public:
1025   VM_DumpTouchedMethods(outputStream* out) {
1026     _out = out;
1027   }
1028 
1029   virtual VMOp_Type type() const { return VMOp_DumpTouchedMethods; }
1030 
1031   virtual void doit() {
1032     Method::print_touched_methods(_out);
1033   }
1034 };
1035 
1036 TouchedMethodsDCmd::TouchedMethodsDCmd(outputStream* output, bool heap) :
1037                                        DCmdWithParser(output, heap)
1038 {}
1039 
1040 void TouchedMethodsDCmd::execute(DCmdSource source, TRAPS) {
1041   if (!LogTouchedMethods) {
1042     output()->print_cr("VM.print_touched_methods command requires -XX:+LogTouchedMethods");
1043     return;
1044   }
1045   VM_DumpTouchedMethods dumper(output());
1046   VMThread::execute(&dumper);
1047 }
1048 
1049 int TouchedMethodsDCmd::num_arguments() {
1050   return 0;
1051 }