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