1 /*
2 * Copyright (c) 2011, 2025, 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 #ifndef SHARE_SERVICES_DIAGNOSTICCOMMAND_HPP
26 #define SHARE_SERVICES_DIAGNOSTICCOMMAND_HPP
27
28 #include "classfile/stringTable.hpp"
29 #include "classfile/symbolTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "oops/method.hpp"
33 #include "runtime/arguments.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/vmThread.hpp"
36 #include "services/diagnosticArgument.hpp"
37 #include "services/diagnosticCommand.hpp"
38 #include "services/diagnosticFramework.hpp"
39 #include "utilities/macros.hpp"
40 #include "utilities/ostream.hpp"
41
42 class HelpDCmd : public DCmdWithParser {
43 protected:
44 DCmdArgument<bool> _all;
45 DCmdArgument<char*> _cmd;
46 public:
47 static int num_arguments() { return 2; }
48 HelpDCmd(outputStream* output, bool heap);
49 static const char* name() { return "help"; }
50 static const char* description() {
51 return "For more information about a specific command use 'help <command>'. "
52 "With no argument this will show a list of available commands. "
53 "'help all' will show help for all commands.";
54 }
55 static const char* impact() { return "Low"; }
56 virtual void execute(DCmdSource source, TRAPS);
57 };
58
59 class VersionDCmd : public DCmd {
60 public:
61 VersionDCmd(outputStream* output, bool heap) : DCmd(output,heap) { }
62 static const char* name() { return "VM.version"; }
63 static const char* description() {
64 return "Print JVM version information.";
65 }
66 static const char* impact() { return "Low"; }
67 virtual void execute(DCmdSource source, TRAPS);
68 };
69
70 class CommandLineDCmd : public DCmd {
71 public:
72 CommandLineDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
73 static const char* name() { return "VM.command_line"; }
74 static const char* description() {
75 return "Print the command line used to start this VM instance.";
76 }
77 static const char* impact() { return "Low"; }
78 virtual void execute(DCmdSource source, TRAPS) {
79 Arguments::print_on(_output);
80 }
81 };
82
83 // See also: get_system_properties in attachListener.cpp
84 class PrintSystemPropertiesDCmd : public DCmd {
85 public:
86 PrintSystemPropertiesDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
87 static const char* name() { return "VM.system_properties"; }
88 static const char* description() {
89 return "Print system properties.";
90 }
91 static const char* impact() {
92 return "Low";
93 }
94 virtual void execute(DCmdSource source, TRAPS);
95 };
96
97 // See also: print_flag in attachListener.cpp
98 class PrintVMFlagsDCmd : public DCmdWithParser {
99 protected:
100 DCmdArgument<bool> _all;
101 public:
102 static int num_arguments() { return 1; }
103 PrintVMFlagsDCmd(outputStream* output, bool heap);
104 static const char* name() { return "VM.flags"; }
105 static const char* description() {
106 return "Print VM flag options and their current values.";
107 }
108 static const char* impact() {
109 return "Low";
110 }
111 virtual void execute(DCmdSource source, TRAPS);
112 };
113
114 class SetVMFlagDCmd : public DCmdWithParser {
115 protected:
116 DCmdArgument<char*> _flag;
117 DCmdArgument<char*> _value;
118
119 public:
120 static int num_arguments() { return 2; }
121 SetVMFlagDCmd(outputStream* output, bool heap);
122 static const char* name() { return "VM.set_flag"; }
123 static const char* description() {
124 return "Sets VM flag option using the provided value.";
125 }
126 static const char* impact() {
127 return "Low";
128 }
129 virtual void execute(DCmdSource source, TRAPS);
130 };
131
132 class JVMTIDataDumpDCmd : public DCmd {
133 public:
134 JVMTIDataDumpDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
135 static const char* name() { return "JVMTI.data_dump"; }
136 static const char* description() {
137 return "Signal the JVM to do a data-dump request for JVMTI.";
138 }
139 static const char* impact() {
140 return "High";
141 }
142 virtual void execute(DCmdSource source, TRAPS);
143 };
144
145 #if INCLUDE_SERVICES
146 #if INCLUDE_JVMTI
147 class JVMTIAgentLoadDCmd : public DCmdWithParser {
148 protected:
149 DCmdArgument<char*> _libpath;
150 DCmdArgument<char*> _option;
151 public:
152 static int num_arguments() { return 2; }
153 JVMTIAgentLoadDCmd(outputStream* output, bool heap);
154 static const char* name() { return "JVMTI.agent_load"; }
155 static const char* description() {
156 return "Load JVMTI native agent.";
157 }
158 static const char* impact() { return "Low"; }
159 virtual void execute(DCmdSource source, TRAPS);
160 };
161 #endif // INCLUDE_JVMTI
162 #endif // INCLUDE_SERVICES
163
164 class VMDynamicLibrariesDCmd : public DCmd {
165 public:
166 VMDynamicLibrariesDCmd(outputStream* output, bool heap);
167 static const char* name() {
168 return "VM.dynlibs";
169 }
170 static const char* description() {
171 return "Print loaded dynamic libraries.";
172 }
173 static const char* impact() {
174 return "Low";
175 }
176 virtual void execute(DCmdSource source, TRAPS);
177 };
178
179 class VMUptimeDCmd : public DCmdWithParser {
180 protected:
181 DCmdArgument<bool> _date;
182 public:
183 static int num_arguments() { return 1; }
184 VMUptimeDCmd(outputStream* output, bool heap);
185 static const char* name() { return "VM.uptime"; }
186 static const char* description() {
187 return "Print VM uptime.";
188 }
189 static const char* impact() {
190 return "Low";
191 }
192 virtual void execute(DCmdSource source, TRAPS);
193 };
194
195 class VMInfoDCmd : public DCmd {
196 public:
197 VMInfoDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
198 static const char* name() { return "VM.info"; }
199 static const char* description() {
200 return "Print information about JVM environment and status.";
201 }
202 static const char* impact() { return "Low"; }
203 virtual void execute(DCmdSource source, TRAPS);
204 };
205
206 class SystemGCDCmd : public DCmd {
207 public:
208 SystemGCDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
209 static const char* name() { return "GC.run"; }
210 static const char* description() {
211 return "Call java.lang.System.gc().";
212 }
213 static const char* impact() {
214 return "Medium: Depends on Java heap size and content.";
215 }
216 virtual void execute(DCmdSource source, TRAPS);
217 };
218
219 class RunFinalizationDCmd : public DCmd {
220 public:
221 RunFinalizationDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
222 static const char* name() { return "GC.run_finalization"; }
223 static const char* description() {
224 return "Call java.lang.System.runFinalization().";
225 }
226 static const char* impact() {
227 return "Medium: Depends on Java content.";
228 }
229 virtual void execute(DCmdSource source, TRAPS);
230 };
231
232 class HeapInfoDCmd : public DCmd {
233 public:
234 HeapInfoDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
235 static const char* name() { return "GC.heap_info"; }
236 static const char* description() {
237 return "Provide generic Java heap information.";
238 }
239 static const char* impact() {
240 return "Medium";
241 }
242
243 virtual void execute(DCmdSource source, TRAPS);
244 };
245
246 class FinalizerInfoDCmd : public DCmd {
247 public:
248 FinalizerInfoDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
249 static const char* name() { return "GC.finalizer_info"; }
250 static const char* description() {
251 return "Provide information about Java finalization queue.";
252 }
253 static const char* impact() {
254 return "Medium";
255 }
256
257 virtual void execute(DCmdSource source, TRAPS);
258 };
259
260 #if INCLUDE_SERVICES // Heap dumping supported
261 // See also: dump_heap in attachListener.cpp
262 class HeapDumpDCmd : public DCmdWithParser {
263 protected:
264 DCmdArgument<char*> _filename;
265 DCmdArgument<bool> _all;
266 DCmdArgument<jlong> _gzip;
267 DCmdArgument<bool> _overwrite;
268 DCmdArgument<jlong> _parallel;
269 public:
270 static int num_arguments() { return 5; }
271 HeapDumpDCmd(outputStream* output, bool heap);
272 static const char* name() {
273 return "GC.heap_dump";
274 }
275 static const char* description() {
276 return "Generate a HPROF format dump of the Java heap.";
277 }
278 static const char* impact() {
279 return "High: Depends on Java heap size and content. "
280 "Request a full GC unless the '-all' option is specified.";
281 }
282 virtual void execute(DCmdSource source, TRAPS);
283 };
284 #endif // INCLUDE_SERVICES
285
286 // See also: inspectheap in attachListener.cpp
287 class ClassHistogramDCmd : public DCmdWithParser {
288 protected:
289 DCmdArgument<bool> _all;
290 DCmdArgument<jlong> _parallel_thread_num;
291 public:
292 static int num_arguments() { return 2; }
293 ClassHistogramDCmd(outputStream* output, bool heap);
294 static const char* name() {
295 return "GC.class_histogram";
296 }
297 static const char* description() {
298 return "Provide statistics about the Java heap usage.";
299 }
300 static const char* impact() {
301 return "High: Depends on Java heap size and content.";
302 }
303 virtual void execute(DCmdSource source, TRAPS);
304 };
305
306 class ClassHierarchyDCmd : public DCmdWithParser {
307 protected:
308 DCmdArgument<bool> _print_interfaces; // true if inherited interfaces should be printed.
309 DCmdArgument<bool> _print_subclasses; // true if subclasses of the specified classname should be printed.
310 DCmdArgument<char*> _classname; // Optional single class name whose hierarchy should be printed.
311 public:
312 static int num_arguments() { return 3; }
313 ClassHierarchyDCmd(outputStream* output, bool heap);
314 static const char* name() {
315 return "VM.class_hierarchy";
316 }
317 static const char* description() {
318 return "Print a list of all loaded classes, indented to show the class hierarchy. "
319 "The name of each class is followed by the ClassLoaderData* of its ClassLoader, "
320 "or \"null\" if loaded by the bootstrap class loader.";
321 }
322 static const char* impact() {
323 return "Medium: Depends on number of loaded classes.";
324 }
325 virtual void execute(DCmdSource source, TRAPS);
326 };
327
328 class PrintClassLayoutDCmd : public DCmdWithParser {
329 protected:
330 DCmdArgument<char*> _classname; // lass name whose layout should be printed.
331 public:
332 PrintClassLayoutDCmd(outputStream* output, bool heap);
333 static const char* name() {
334 return "VM.class_print_layout";
335 }
336 static const char* description() {
337 return "Print the layout of an instance of a class, including flat fields. "
338 "The name of each class is followed by the ClassLoaderData* of its ClassLoader, "
339 "or \"null\" if loaded by the bootstrap class loader.";
340 }
341 static const char* impact() {
342 return "Medium: Depends on number of loaded classes.";
343 }
344 static int num_arguments();
345 virtual void execute(DCmdSource source, TRAPS);
346 };
347
348 #if INCLUDE_CDS
349 class DumpSharedArchiveDCmd: public DCmdWithParser {
350 protected:
351 DCmdArgument<char*> _suboption; // option of VM.cds
352 DCmdArgument<char*> _filename; // file name, optional
353 public:
354 static int num_arguments() { return 2; }
355 DumpSharedArchiveDCmd(outputStream* output, bool heap);
356 static const char* name() {
357 return "VM.cds";
358 }
359 static const char* description() {
360 return "Dump a static or dynamic shared archive including all shareable classes";
361 }
362 static const char* impact() {
363 return "Medium: Pause time depends on number of loaded classes";
364 }
365 virtual void execute(DCmdSource source, TRAPS);
366 };
367 #endif // INCLUDE_CDS
368
369 // See also: thread_dump in attachListener.cpp
370 class ThreadDumpDCmd : public DCmdWithParser {
371 protected:
372 DCmdArgument<bool> _locks;
373 DCmdArgument<bool> _extended;
374 public:
375 static int num_arguments() { return 2; }
376 ThreadDumpDCmd(outputStream* output, bool heap);
377 static const char* name() { return "Thread.print"; }
378 static const char* description() {
379 return "Print all platform threads, and mounted virtual threads, "
380 "with stack traces. The Thread.dump_to_file command will "
381 "print all threads to a file.";
382 }
383 static const char* impact() {
384 return "Medium: Depends on the number of threads.";
385 }
386 virtual void execute(DCmdSource source, TRAPS);
387 };
388
389 // Enhanced JMX Agent support
390
391 class JMXStartRemoteDCmd : public DCmdWithParser {
392
393 // Explicitly list all properties that could be
394 // passed to Agent.startRemoteManagementAgent()
395 // com.sun.management is omitted
396
397 DCmdArgument<char *> _config_file;
398 DCmdArgument<char *> _jmxremote_host;
399 DCmdArgument<char *> _jmxremote_port;
400 DCmdArgument<char *> _jmxremote_rmi_port;
401 DCmdArgument<char *> _jmxremote_ssl;
402 DCmdArgument<char *> _jmxremote_registry_ssl;
403 DCmdArgument<char *> _jmxremote_authenticate;
404 DCmdArgument<char *> _jmxremote_password_file;
405 DCmdArgument<char *> _jmxremote_access_file;
406 DCmdArgument<char *> _jmxremote_login_config;
407 DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites;
408 DCmdArgument<char *> _jmxremote_ssl_enabled_protocols;
409 DCmdArgument<char *> _jmxremote_ssl_need_client_auth;
410 DCmdArgument<char *> _jmxremote_ssl_config_file;
411
412 // JDP support
413 // Keep autodiscovery char* not bool to pass true/false
414 // as property value to java level.
415 DCmdArgument<char *> _jmxremote_autodiscovery;
416 DCmdArgument<jlong> _jdp_port;
417 DCmdArgument<char *> _jdp_address;
418 DCmdArgument<char *> _jdp_source_addr;
419 DCmdArgument<jlong> _jdp_ttl;
420 DCmdArgument<jlong> _jdp_pause;
421 DCmdArgument<char *> _jdp_name;
422
423 public:
424 static int num_arguments() { return 21; }
425
426 JMXStartRemoteDCmd(outputStream *output, bool heap_allocated);
427
428 static const char *name() {
429 return "ManagementAgent.start";
430 }
431
432 static const char *description() {
433 return "Start remote management agent.";
434 }
435
436 virtual void execute(DCmdSource source, TRAPS);
437 };
438
439 class JMXStartLocalDCmd : public DCmd {
440
441 // Explicitly request start of local agent,
442 // it will not be started by start dcmd
443
444
445 public:
446 JMXStartLocalDCmd(outputStream *output, bool heap_allocated);
447
448 static const char *name() {
449 return "ManagementAgent.start_local";
450 }
451
452 static const char *description() {
453 return "Start local management agent.";
454 }
455
456 virtual void execute(DCmdSource source, TRAPS);
457
458 };
459
460 class JMXStopRemoteDCmd : public DCmd {
461 public:
462 JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) :
463 DCmd(output, heap_allocated) {
464 // Do Nothing
465 }
466
467 static const char *name() {
468 return "ManagementAgent.stop";
469 }
470
471 static const char *description() {
472 return "Stop remote management agent.";
473 }
474
475 virtual void execute(DCmdSource source, TRAPS);
476 };
477
478 // Print the JMX system status
479 class JMXStatusDCmd : public DCmd {
480 public:
481 JMXStatusDCmd(outputStream *output, bool heap_allocated);
482
483 static const char *name() {
484 return "ManagementAgent.status";
485 }
486
487 static const char *description() {
488 return "Print the management agent status.";
489 }
490
491 virtual void execute(DCmdSource source, TRAPS);
492
493 };
494
495 class CompileQueueDCmd : public DCmd {
496 public:
497 CompileQueueDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
498 static const char* name() {
499 return "Compiler.queue";
500 }
501 static const char* description() {
502 return "Print methods queued for compilation.";
503 }
504 static const char* impact() {
505 return "Low";
506 }
507 virtual void execute(DCmdSource source, TRAPS);
508 };
509
510 #ifdef LINUX
511 class PerfMapDCmd : public DCmdWithParser {
512 protected:
513 DCmdArgument<char*> _filename;
514 public:
515 static int num_arguments() { return 1; }
516 PerfMapDCmd(outputStream* output, bool heap);
517 static const char* name() {
518 return "Compiler.perfmap";
519 }
520 static const char* description() {
521 return "Write map file for Linux perf tool.";
522 }
523 static const char* impact() {
524 return "Low";
525 }
526 virtual void execute(DCmdSource source, TRAPS);
527 };
528 #endif // LINUX
529
530 class CodeListDCmd : public DCmd {
531 public:
532 CodeListDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
533 static const char* name() {
534 return "Compiler.codelist";
535 }
536 static const char* description() {
537 return "Print all compiled methods in code cache that are alive";
538 }
539 static const char* impact() {
540 return "Medium";
541 }
542 virtual void execute(DCmdSource source, TRAPS);
543 };
544
545 class CodeCacheDCmd : public DCmd {
546 public:
547 CodeCacheDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
548 static const char* name() {
549 return "Compiler.codecache";
550 }
551 static const char* description() {
552 return "Print code cache layout and bounds.";
553 }
554 static const char* impact() {
555 return "Low";
556 }
557 virtual void execute(DCmdSource source, TRAPS);
558 };
559
560 //---< BEGIN >--- CodeHeap State Analytics.
561 class CodeHeapAnalyticsDCmd : public DCmdWithParser {
562 protected:
563 DCmdArgument<char*> _function;
564 DCmdArgument<jlong> _granularity;
565 public:
566 static int num_arguments() { return 2; }
567 CodeHeapAnalyticsDCmd(outputStream* output, bool heap);
568 static const char* name() {
569 return "Compiler.CodeHeap_Analytics";
570 }
571 static const char* description() {
572 return "Print CodeHeap analytics";
573 }
574 static const char* impact() {
575 return "Low: Depends on code heap size and content. "
576 "Holds CodeCache_lock during analysis step, usually sub-second duration.";
577 }
578 virtual void execute(DCmdSource source, TRAPS);
579 };
580 //---< END >--- CodeHeap State Analytics.
581
582 class CompilerDirectivesPrintDCmd : public DCmd {
583 public:
584 CompilerDirectivesPrintDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
585 static const char* name() {
586 return "Compiler.directives_print";
587 }
588 static const char* description() {
589 return "Print all active compiler directives.";
590 }
591 static const char* impact() {
592 return "Low";
593 }
594 virtual void execute(DCmdSource source, TRAPS);
595 };
596
597 class CompilerDirectivesRemoveDCmd : public DCmd {
598 public:
599 CompilerDirectivesRemoveDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
600 static const char* name() {
601 return "Compiler.directives_remove";
602 }
603 static const char* description() {
604 return "Remove latest added compiler directive.";
605 }
606 static const char* impact() {
607 return "Low";
608 }
609 virtual void execute(DCmdSource source, TRAPS);
610 };
611
612 class CompilerDirectivesAddDCmd : public DCmdWithParser {
613 protected:
614 DCmdArgument<char*> _filename;
615 public:
616 static int num_arguments() { return 1; }
617 CompilerDirectivesAddDCmd(outputStream* output, bool heap);
618 static const char* name() {
619 return "Compiler.directives_add";
620 }
621 static const char* description() {
622 return "Add compiler directives from file.";
623 }
624 static const char* impact() {
625 return "Low";
626 }
627 virtual void execute(DCmdSource source, TRAPS);
628 };
629
630 class CompilerDirectivesClearDCmd : public DCmd {
631 public:
632 CompilerDirectivesClearDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
633 static const char* name() {
634 return "Compiler.directives_clear";
635 }
636 static const char* description() {
637 return "Remove all compiler directives.";
638 }
639 static const char* impact() {
640 return "Low";
641 }
642 virtual void execute(DCmdSource source, TRAPS);
643 };
644
645 ///////////////////////////////////////////////////////////////////////
646 //
647 // jcmd command support for symbol table, string table and system dictionary dumping:
648 // VM.symboltable -verbose: for dumping the symbol table
649 // VM.stringtable -verbose: for dumping the string table
650 // VM.systemdictionary -verbose: for dumping the system dictionary table
651 //
652 class VM_DumpHashtable : public VM_Operation {
653 private:
654 outputStream* _out;
655 int _which;
656 bool _verbose;
657 public:
658 enum {
659 DumpSymbols = 1 << 0,
660 DumpStrings = 1 << 1,
661 DumpSysDict = 1 << 2 // not implemented yet
662 };
663 VM_DumpHashtable(outputStream* out, int which, bool verbose) {
664 _out = out;
665 _which = which;
666 _verbose = verbose;
667 }
668
669 virtual VMOp_Type type() const { return VMOp_DumpHashtable; }
670
671 virtual void doit() {
672 switch (_which) {
673 case DumpSymbols:
674 SymbolTable::dump(_out, _verbose);
675 break;
676 case DumpStrings:
677 StringTable::dump(_out, _verbose);
678 break;
679 case DumpSysDict:
680 SystemDictionary::dump(_out, _verbose);
681 break;
682 default:
683 ShouldNotReachHere();
684 }
685 }
686 };
687
688 class SymboltableDCmd : public DCmdWithParser {
689 protected:
690 DCmdArgument<bool> _verbose;
691 public:
692 static int num_arguments() { return 1; }
693 SymboltableDCmd(outputStream* output, bool heap);
694 static const char* name() {
695 return "VM.symboltable";
696 }
697 static const char* description() {
698 return "Dump symbol table.";
699 }
700 static const char* impact() {
701 return "Medium: Depends on Java content.";
702 }
703 virtual void execute(DCmdSource source, TRAPS);
704 };
705
706 class StringtableDCmd : public DCmdWithParser {
707 protected:
708 DCmdArgument<bool> _verbose;
709 public:
710 static int num_arguments() { return 1; }
711 StringtableDCmd(outputStream* output, bool heap);
712 static const char* name() {
713 return "VM.stringtable";
714 }
715 static const char* description() {
716 return "Dump string table.";
717 }
718 static const char* impact() {
719 return "Medium: Depends on Java content.";
720 }
721 virtual void execute(DCmdSource source, TRAPS);
722 };
723
724 class SystemDictionaryDCmd : public DCmdWithParser {
725 protected:
726 DCmdArgument<bool> _verbose;
727 public:
728 static int num_arguments() { return 1; }
729 SystemDictionaryDCmd(outputStream* output, bool heap);
730 static const char* name() {
731 return "VM.systemdictionary";
732 }
733 static const char* description() {
734 return "Prints the statistics for dictionary hashtable sizes and bucket length";
735 }
736 static const char* impact() {
737 return "Medium: Depends on Java content.";
738 }
739 virtual void execute(DCmdSource source, TRAPS);
740 };
741
742 class ClassesDCmd : public DCmdWithParser {
743 protected:
744 DCmdArgument<bool> _verbose;
745 public:
746 static int num_arguments() { return 1; }
747 ClassesDCmd(outputStream* output, bool heap);
748 static const char* name() {
749 return "VM.classes";
750 }
751 static const char* description() {
752 return "Print all loaded classes";
753 }
754 static const char* impact() {
755 return "Medium: Depends on number of loaded classes.";
756 }
757 virtual void execute(DCmdSource source, TRAPS);
758 };
759
760 class EventLogDCmd : public DCmdWithParser {
761 protected:
762 DCmdArgument<char*> _log;
763 DCmdArgument<jlong> _max;
764 public:
765 static int num_arguments() { return 2; }
766 EventLogDCmd(outputStream* output, bool heap);
767 static const char* name() {
768 return "VM.events";
769 }
770 static const char* description() {
771 return "Print VM event logs";
772 }
773 static const char* impact() {
774 return "Low: Depends on event log size. ";
775 }
776 virtual void execute(DCmdSource source, TRAPS);
777 };
778
779 class ThreadDumpToFileDCmd : public DCmdWithParser {
780 private:
781 void dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS);
782 protected:
783 DCmdArgument<bool> _overwrite;
784 DCmdArgument<char*> _format;
785 DCmdArgument<char*> _filepath;
786 public:
787 static int num_arguments() { return 3; }
788 ThreadDumpToFileDCmd(outputStream *output, bool heap);
789 static const char *name() {
790 return "Thread.dump_to_file";
791 }
792 static const char *description() {
793 return "Dump all threads, with stack traces, "
794 "to a file in plain text or JSON format.";
795 }
796 static const char* impact() {
797 return "Medium: Depends on the number of threads.";
798 }
799 virtual void execute(DCmdSource source, TRAPS);
800 };
801
802 class VThreadSchedulerDCmd : public DCmd {
803 public:
804 VThreadSchedulerDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
805 static const char* name() {
806 return "Thread.vthread_scheduler";
807 }
808 static const char* description() {
809 return "Print the virtual thread scheduler, and the delayed task schedulers that support "
810 "virtual threads doing timed operations.";
811 }
812 static const char* impact() { return "Low"; }
813 virtual void execute(DCmdSource source, TRAPS);
814 };
815
816 class VThreadPollersDCmd : public DCmd {
817 public:
818 VThreadPollersDCmd(outputStream* output, bool heap) : DCmd(output, heap) { }
819 static const char* name() {
820 return "Thread.vthread_pollers";
821 }
822 static const char* description() {
823 return "Print the I/O pollers that support virtual threads doing blocking network I/O operations.";
824 }
825 static const char* impact() { return "Low"; }
826 virtual void execute(DCmdSource source, TRAPS);
827 };
828
829 class CompilationMemoryStatisticDCmd: public DCmdWithParser {
830 protected:
831 DCmdArgument<bool> _verbose;
832 DCmdArgument<bool> _legend;
833 DCmdArgument<MemorySizeArgument> _minsize;
834 public:
835 static int num_arguments() { return 3; }
836 CompilationMemoryStatisticDCmd(outputStream* output, bool heap);
837 static const char* name() {
838 return "Compiler.memory";
839 }
840 static const char* description() {
841 return "Print compilation footprint";
842 }
843 static const char* impact() {
844 return "Medium: Pause time depends on number of compiled methods";
845 }
846 virtual void execute(DCmdSource source, TRAPS);
847 };
848
849 #if defined(LINUX) || defined(_WIN64) || defined(__APPLE__)
850
851 class SystemMapDCmd : public DCmd {
852 public:
853 SystemMapDCmd(outputStream* output, bool heap);
854 static const char* name() { return "System.map"; }
855 static const char* description() {
856 return "Prints an annotated process memory map of the VM process (linux, Windows and MacOS only).";
857 }
858 static const char* impact() { return "Medium; can be high for very large java heaps."; }
859 virtual void execute(DCmdSource source, TRAPS);
860 };
861
862 class SystemDumpMapDCmd : public DCmdWithParser {
863 DCmdArgument<char*> _filename;
864 public:
865 static int num_arguments() { return 1; }
866 SystemDumpMapDCmd(outputStream* output, bool heap);
867 static const char* name() { return "System.dump_map"; }
868 static const char* description() {
869 return "Dumps an annotated process memory map to an output file (linux, Windows and MacOS only).";
870 }
871 static const char* impact() { return "Medium; can be high for very large java heaps."; }
872 virtual void execute(DCmdSource source, TRAPS);
873 };
874
875 #endif // LINUX, WINDOWS or MACOS
876
877 #endif // SHARE_SERVICES_DIAGNOSTICCOMMAND_HPP