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