src/hotspot/share/services/diagnosticCommand.cpp
author dcubed
Wed, 18 Sep 2019 20:49:13 -0400
changeset 58223 778fc2dcbdaa
parent 55516 f3b62797e2d0
child 58679 9c3209ff7550
child 59006 d3f1cb09b704
permissions -rw-r--r--
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread Reviewed-by: phh, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     1
/*
55217
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     4
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     7
 * published by the Free Software Foundation.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     8
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    13
 * accompanied this code).
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    14
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    18
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    21
 * questions.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    22
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    23
 */
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    24
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    25
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    26
#include "jvm.h"
50443
8e56de95ce10 8203682: Add jcmd "VM.classloaders" command to print out class loader hierarchy, details
stuefe
parents: 49980
diff changeset
    27
#include "classfile/classLoaderHierarchyDCmd.hpp"
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents: 24424
diff changeset
    28
#include "classfile/classLoaderStats.hpp"
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
    29
#include "compiler/compileBroker.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
    30
#include "compiler/directivesParser.hpp"
52876
2d17750d41e7 8214791: Consistently name gc files containing VM operations
tschatzl
parents: 52148
diff changeset
    31
#include "gc/shared/gcVMOperations.hpp"
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49902
diff changeset
    32
#include "memory/metaspace/metaspaceDCmd.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 37195
diff changeset
    33
#include "memory/resourceArea.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 52976
diff changeset
    34
#include "memory/universe.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49053
diff changeset
    35
#include "oops/objArrayOop.inline.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 28935
diff changeset
    36
#include "oops/oop.inline.hpp"
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 47765
diff changeset
    37
#include "oops/typeArrayOop.inline.hpp"
51467
12997ebbc0d8 8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled
iklam
parents: 51334
diff changeset
    38
#include "runtime/fieldDescriptor.inline.hpp"
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    39
#include "runtime/flags/jvmFlag.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49053
diff changeset
    40
#include "runtime/handles.inline.hpp"
52976
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
    41
#include "runtime/interfaceSupport.inline.hpp"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    42
#include "runtime/javaCalls.hpp"
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
    43
#include "runtime/os.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    44
#include "services/diagnosticArgument.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    45
#include "services/diagnosticCommand.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    46
#include "services/diagnosticFramework.hpp"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    47
#include "services/heapDumper.hpp"
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    48
#include "services/management.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30134
diff changeset
    49
#include "services/writeableFlags.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46458
diff changeset
    50
#include "utilities/debug.hpp"
55217
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
    51
#include "utilities/events.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46458
diff changeset
    52
#include "utilities/formatBuffer.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13977
diff changeset
    53
#include "utilities/macros.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    54
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    55
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    56
static void loadAgentModule(TRAPS) {
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    57
  ResourceMark rm(THREAD);
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    58
  HandleMark hm(THREAD);
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    59
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    60
  JavaValue result(T_OBJECT);
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    61
  Handle h_module_name = java_lang_String::create_from_str("jdk.management.agent", CHECK);
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    62
  JavaCalls::call_static(&result,
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    63
                         SystemDictionary::module_Modules_klass(),
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    64
                         vmSymbols::loadModule_name(),
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    65
                         vmSymbols::loadModule_signature(),
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    66
                         h_module_name,
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    67
                         THREAD);
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    68
}
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
    69
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    70
void DCmdRegistrant::register_dcmds(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    71
  // Registration of the diagnostic commands
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    72
  // First argument specifies which interfaces will export the command
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    73
  // Second argument specifies if the command is enabled
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    74
  // Third  argument specifies if the command is hidden
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    75
  uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    76
                         | DCmd_Source_MBean;
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    77
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    78
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    79
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    80
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    81
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
30121
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
    82
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
    83
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    84
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33451
diff changeset
    85
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    86
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    87
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
32072
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
    88
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
    89
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
37195
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
    90
#if INCLUDE_SERVICES
20662
3296bf2cc204 8020789: Disable exporting of gc.heap_dump diagnostic command
sgabdura
parents: 18025
diff changeset
    91
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    92
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    93
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46560
diff changeset
    94
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
29071
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
    95
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26587
diff changeset
    96
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26587
diff changeset
    97
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents: 49902
diff changeset
    98
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
55217
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
    99
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
37195
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
   100
#if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
   101
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
   102
#endif // INCLUDE_JVMTI
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   103
#endif // INCLUDE_SERVICES
30121
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   104
#if INCLUDE_JVMTI
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   105
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   106
#endif // INCLUDE_JVMTI
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   107
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents: 24424
diff changeset
   108
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
50443
8e56de95ce10 8203682: Add jcmd "VM.classloaders" command to print out class loader hierarchy, details
stuefe
parents: 49980
diff changeset
   109
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderHierarchyDCmd>(full_export, true, false));
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   110
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   111
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   112
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
31790
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
   113
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   114
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   115
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
   116
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
   117
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
   118
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
   119
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
   120
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   121
  // Enhanced JMX Agent Support
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   122
  // These commands won't be exported via the DiagnosticCommandMBean until an
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   123
  // appropriate permission is created for them
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   124
  uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   125
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   126
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   127
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   128
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   129
52976
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
   130
  // Debug on cmd (only makes sense with JVMTI since the agentlib needs it).
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
   131
#if INCLUDE_JVMTI
55516
f3b62797e2d0 8226608: Hide the onjcmd option from the help output
rschmelter
parents: 55294
diff changeset
   132
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DebugOnCmdStartDCmd>(full_export, true, true));
52976
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
   133
#endif // INCLUDE_JVMTI
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
   134
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   135
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   136
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   137
#ifndef HAVE_EXTRA_DCMD
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   138
void DCmdRegistrant::register_dcmds_ext(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   139
   // Do nothing here
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   140
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   141
#endif
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   142
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
   143
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   144
HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   145
  _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   146
  _cmd("command name", "The name of the command for which we want help",
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   147
        "STRING", false) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   148
  _dcmdparser.add_dcmd_option(&_all);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   149
  _dcmdparser.add_dcmd_argument(&_cmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   150
};
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   151
49750
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   152
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   153
static int compare_strings(const char** s1, const char** s2) {
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   154
  return ::strcmp(*s1, *s2);
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   155
}
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   156
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   157
void HelpDCmd::execute(DCmdSource source, TRAPS) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   158
  if (_all.value()) {
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   159
    GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
49750
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   160
    cmd_list->sort(compare_strings);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   161
    for (int i = 0; i < cmd_list->length(); i++) {
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   162
      DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   163
                                                  strlen(cmd_list->at(i)));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   164
      output()->print_cr("%s%s", factory->name(),
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   165
                         factory->is_enabled() ? "" : " [disabled]");
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   166
      output()->print_cr("\t%s", factory->description());
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   167
      output()->cr();
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   168
      factory = factory->next();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   169
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   170
  } else if (_cmd.has_value()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   171
    DCmd* cmd = NULL;
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   172
    DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   173
                                                strlen(_cmd.value()));
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   174
    if (factory != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   175
      output()->print_cr("%s%s", factory->name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   176
                         factory->is_enabled() ? "" : " [disabled]");
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23517
diff changeset
   177
      output()->print_cr("%s", factory->description());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   178
      output()->print_cr("\nImpact: %s", factory->impact());
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   179
      JavaPermission p = factory->permission();
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   180
      if(p._class != NULL) {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   181
        if(p._action != NULL) {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   182
          output()->print_cr("\nPermission: %s(%s, %s)",
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   183
                  p._class, p._name == NULL ? "null" : p._name, p._action);
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   184
        } else {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   185
          output()->print_cr("\nPermission: %s(%s)",
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   186
                  p._class, p._name == NULL ? "null" : p._name);
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   187
        }
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   188
      }
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   189
      output()->cr();
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   190
      cmd = factory->create_resource_instance(output());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   191
      if (cmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   192
        DCmdMark mark(cmd);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   193
        cmd->print_help(factory->name());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   194
      }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   195
    } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   196
      output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   197
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   198
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   199
    output()->print_cr("The following commands are available:");
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   200
    GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
49750
bdcfe8154201 8200384: jcmd help output should be sorted
stuefe
parents: 49650
diff changeset
   201
    cmd_list->sort(compare_strings);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   202
    for (int i = 0; i < cmd_list->length(); i++) {
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   203
      DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   204
                                                  strlen(cmd_list->at(i)));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   205
      output()->print_cr("%s%s", factory->name(),
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   206
                         factory->is_enabled() ? "" : " [disabled]");
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   207
      factory = factory->_next;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   208
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   209
    output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   210
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   211
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   212
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   213
int HelpDCmd::num_arguments() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   214
  ResourceMark rm;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   215
  HelpDCmd* dcmd = new HelpDCmd(NULL, false);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   216
  if (dcmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   217
    DCmdMark mark(dcmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   218
    return dcmd->_dcmdparser.num_arguments();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   219
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   220
    return 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   221
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   222
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   223
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   224
void VersionDCmd::execute(DCmdSource source, TRAPS) {
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 51823
diff changeset
   225
  output()->print_cr("%s version %s", VM_Version::vm_name(),
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 51823
diff changeset
   226
          VM_Version::vm_release());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   227
  JDK_Version jdk_version = JDK_Version::current();
33959
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   228
  if (jdk_version.patch_version() > 0) {
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   229
    output()->print_cr("JDK %d.%d.%d.%d", jdk_version.major_version(),
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   230
            jdk_version.minor_version(), jdk_version.security_version(),
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   231
            jdk_version.patch_version());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   232
  } else {
33959
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   233
    output()->print_cr("JDK %d.%d.%d", jdk_version.major_version(),
36f534ca18c0 8087202: Add support for PATCH field and remove unused fields of new version string
amurillo
parents: 30764
diff changeset
   234
            jdk_version.minor_version(), jdk_version.security_version());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   235
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   236
}
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   237
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   238
PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   239
                                   DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   240
  _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   241
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   242
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   243
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   244
void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   245
  if (_all.value()) {
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   246
    JVMFlag::printFlags(output(), true);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   247
  } else {
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   248
    JVMFlag::printSetFlags(output());
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   249
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   250
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   251
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   252
int PrintVMFlagsDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   253
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   254
    PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   255
    if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   256
      DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   257
      return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   258
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   259
      return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   260
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   261
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   262
30121
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   263
SetVMFlagDCmd::SetVMFlagDCmd(outputStream* output, bool heap) :
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   264
                                   DCmdWithParser(output, heap),
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   265
  _flag("flag name", "The name of the flag we want to set",
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   266
        "STRING", true),
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   267
  _value("string value", "The value we want to set", "STRING", false) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   268
  _dcmdparser.add_dcmd_argument(&_flag);
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   269
  _dcmdparser.add_dcmd_argument(&_value);
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   270
}
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   271
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   272
void SetVMFlagDCmd::execute(DCmdSource source, TRAPS) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   273
  const char* val = NULL;
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   274
  if (_value.value() != NULL) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   275
    val = _value.value();
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   276
  }
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   277
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   278
  FormatBuffer<80> err_msg("%s", "");
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   279
  int ret = WriteableFlags::set_flag(_flag.value(), val, JVMFlag::MANAGEMENT, err_msg);
30121
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   280
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   281
  if (ret != JVMFlag::SUCCESS) {
30121
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   282
    output()->print_cr("%s", err_msg.buffer());
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   283
  }
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   284
}
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   285
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   286
int SetVMFlagDCmd::num_arguments() {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   287
  ResourceMark rm;
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   288
  SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   289
  if (dcmd != NULL) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   290
    DCmdMark mark(dcmd);
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   291
    return dcmd->_dcmdparser.num_arguments();
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   292
  } else {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   293
    return 0;
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   294
  }
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   295
}
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   296
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   297
void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   298
  if (JvmtiExport::should_post_data_dump()) {
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   299
    JvmtiExport::post_data_dump();
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   300
  }
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   301
}
cc43664a0ad7 8054890: Serviceability: New diagnostic commands 'VM.set_flag' and 'JVMTI.data_dump'
jbachorik
parents: 29085
diff changeset
   302
37195
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
   303
#if INCLUDE_SERVICES
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   304
JVMTIAgentLoadDCmd::JVMTIAgentLoadDCmd(outputStream* output, bool heap) :
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   305
                                       DCmdWithParser(output, heap),
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   306
  _libpath("library path", "Absolute path of the JVMTI agent to load.",
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   307
           "STRING", true),
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   308
  _option("agent option", "Option string to pass the agent.", "STRING", false) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   309
  _dcmdparser.add_dcmd_argument(&_libpath);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   310
  _dcmdparser.add_dcmd_argument(&_option);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   311
}
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   312
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   313
void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   314
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   315
  if (_libpath.value() == NULL) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   316
    output()->print_cr("JVMTI.agent_load dcmd needs library path.");
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   317
    return;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   318
  }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   319
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   320
  char *suffix = strrchr(_libpath.value(), '.');
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   321
  bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   322
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   323
  if (is_java_agent) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   324
    if (_option.value() == NULL) {
41078
db508643daab 8165881: Backout JDK-8164913
ctornqvi
parents: 41067
diff changeset
   325
      JvmtiExport::load_agent_library("instrument", "false",
db508643daab 8165881: Backout JDK-8164913
ctornqvi
parents: 41067
diff changeset
   326
                                      _libpath.value(), output());
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   327
    } else {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   328
      size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   329
      if (opt_len > 4096) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   330
        output()->print_cr("JVMTI agent attach failed: Options is too long.");
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   331
        return;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   332
      }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   333
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   334
      char *opt = (char *)os::malloc(opt_len, mtInternal);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   335
      if (opt == NULL) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   336
        output()->print_cr("JVMTI agent attach failed: "
43407
f6dc40ed6ce9 8171924: Use SIZE_FORMAT to print size_t values.
goetz
parents: 42075
diff changeset
   337
                           "Could not allocate " SIZE_FORMAT " bytes for argument.",
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   338
                           opt_len);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   339
        return;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   340
      }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   341
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   342
      jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
41078
db508643daab 8165881: Backout JDK-8164913
ctornqvi
parents: 41067
diff changeset
   343
      JvmtiExport::load_agent_library("instrument", "false", opt, output());
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   344
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   345
      os::free(opt);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   346
    }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   347
  } else {
41078
db508643daab 8165881: Backout JDK-8164913
ctornqvi
parents: 41067
diff changeset
   348
    JvmtiExport::load_agent_library(_libpath.value(), "true",
db508643daab 8165881: Backout JDK-8164913
ctornqvi
parents: 41067
diff changeset
   349
                                    _option.value(), output());
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   350
  }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   351
}
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   352
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   353
int JVMTIAgentLoadDCmd::num_arguments() {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   354
  ResourceMark rm;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   355
  JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   356
  if (dcmd != NULL) {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   357
    DCmdMark mark(dcmd);
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   358
    return dcmd->_dcmdparser.num_arguments();
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   359
  } else {
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   360
    return 0;
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   361
  }
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   362
}
37195
88b6f1271f64 8151991: jvmti diagnostics commands requires INCLUDE_SERVICES
dsamersoff
parents: 36597
diff changeset
   363
#endif // INCLUDE_SERVICES
36188
99b6836dd3e8 8147388: Add diagnostic commands to attach JVMTI agent.
ysuenaga
parents: 35825
diff changeset
   364
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   365
void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
36795
bfd8c074c8ec 8153181: Move sun.misc.VMSupport to an internal package
chegar
parents: 36597
diff changeset
   366
  // load VMSupport
bfd8c074c8ec 8153181: Move sun.misc.VMSupport to an internal package
chegar
parents: 36597
diff changeset
   367
  Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   368
  Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   369
  InstanceKlass* ik = InstanceKlass::cast(k);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   370
  if (ik->should_be_initialized()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   371
    ik->initialize(THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   372
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   373
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   374
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   375
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   376
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   377
    return;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   378
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   379
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   380
  // invoke the serializePropertiesToByteArray method
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   381
  JavaValue result(T_OBJECT);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   382
  JavaCallArguments args;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   383
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   384
  Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   385
  JavaCalls::call_static(&result,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   386
                         ik,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   387
                         vmSymbols::serializePropertiesToByteArray_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   388
                         signature,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   389
                         &args,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   390
                         THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   391
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   392
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   393
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   394
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   395
    return;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   396
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   397
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   398
  // The result should be a [B
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   399
  oop res = (oop)result.get_jobject();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   400
  assert(res->is_typeArray(), "just checking");
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   401
  assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   402
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   403
  // copy the bytes to the output stream
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   404
  typeArrayOop ba = typeArrayOop(res);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   405
  jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   406
  output()->print_raw((const char*)addr, ba->length());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   407
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   408
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   409
VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   410
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   411
  _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   412
  _dcmdparser.add_dcmd_option(&_date);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   413
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   414
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   415
void VMUptimeDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   416
  if (_date.value()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   417
    output()->date_stamp(true, "", ": ");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   418
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   419
  output()->time_stamp().update_to(tty->time_stamp().ticks());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   420
  output()->stamp();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   421
  output()->print_cr(" s");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   422
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   423
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   424
int VMUptimeDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   425
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   426
  VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   427
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   428
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   429
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   430
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   431
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   432
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   433
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   434
34139
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33451
diff changeset
   435
void VMInfoDCmd::execute(DCmdSource source, TRAPS) {
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33451
diff changeset
   436
  VMError::print_vm_info(_output);
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33451
diff changeset
   437
}
0728fe06ccf8 8027429: Add diagnostic command VM.info to get hs_err print-out
coleenp
parents: 33451
diff changeset
   438
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   439
void SystemGCDCmd::execute(DCmdSource source, TRAPS) {
47105
d8bd7f7d5147 8186902: jcmd GC.run should not be blocked by DisableExplicitGC
kevinw
parents: 46742
diff changeset
   440
  Universe::heap()->collect(GCCause::_dcmd_gc_run);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   441
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   442
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   443
void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   444
  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   445
                                                 true, CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   446
  JavaValue result(T_VOID);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   447
  JavaCalls::call_static(&result, k,
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   448
                         vmSymbols::run_finalization_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   449
                         vmSymbols::void_method_signature(), CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   450
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   451
32072
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   452
void HeapInfoDCmd::execute(DCmdSource source, TRAPS) {
39401
318e93828de1 8155730: HeapInfoDCmd should get Heap_lock
ysuenaga
parents: 37267
diff changeset
   453
  MutexLocker hl(Heap_lock);
32072
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   454
  Universe::heap()->print_on(output());
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   455
}
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   456
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   457
void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) {
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   458
  ResourceMark rm;
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   459
46311
7545c36a5e76 8175341: "java/util/Arrays/ParallelPrefix.java" Crash Internal Error ...diagnosticCommand.cpp...assert(k != __null) failed: FinalizerHistogram class is not accessible
cjplummer
parents: 43491
diff changeset
   460
  Klass* k = SystemDictionary::resolve_or_fail(
7545c36a5e76 8175341: "java/util/Arrays/ParallelPrefix.java" Crash Internal Error ...diagnosticCommand.cpp...assert(k != __null) failed: FinalizerHistogram class is not accessible
cjplummer
parents: 43491
diff changeset
   461
    vmSymbols::finalizer_histogram_klass(), true, CHECK);
32072
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   462
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   463
  JavaValue result(T_ARRAY);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   464
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   465
  // We are calling lang.ref.FinalizerHistogram.getFinalizerHistogram() method
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   466
  // and expect it to return array of FinalizerHistogramEntry as Object[]
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   467
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   468
  JavaCalls::call_static(&result, k,
32072
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   469
                         vmSymbols::get_finalizer_histogram_name(),
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   470
                         vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   471
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   472
  objArrayOop result_oop = (objArrayOop) result.get_jobject();
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   473
  if (result_oop->length() == 0) {
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   474
    output()->print_cr("No instances waiting for finalization found");
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   475
    return;
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   476
  }
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   477
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   478
  oop foop = result_oop->obj_at(0);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   479
  InstanceKlass* ik = InstanceKlass::cast(foop->klass());
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   480
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   481
  fieldDescriptor count_fd, name_fd;
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   482
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   483
  Klass* count_res = ik->find_field(
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   484
    vmSymbols::finalizer_histogram_entry_count_field(), vmSymbols::int_signature(), &count_fd);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   485
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   486
  Klass* name_res = ik->find_field(
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   487
    vmSymbols::finalizer_histogram_entry_name_field(), vmSymbols::string_signature(), &name_fd);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   488
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   489
  assert(count_res != NULL && name_res != NULL, "Unexpected layout of FinalizerHistogramEntry");
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   490
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   491
  output()->print_cr("Unreachable instances waiting for finalization");
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   492
  output()->print_cr("#instances  class name");
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   493
  output()->print_cr("-----------------------");
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   494
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   495
  for (int i = 0; i < result_oop->length(); ++i) {
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   496
    oop element_oop = result_oop->obj_at(i);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   497
    oop str_oop = element_oop->obj_field(name_fd.offset());
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   498
    char *name = java_lang_String::as_utf8_string(str_oop);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   499
    int count = element_oop->int_field(count_fd.offset());
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   500
    output()->print_cr("%10d  %s", count, name);
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   501
  }
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   502
}
bc13add2c295 8059036: Implement Diagnostic Commands for heap and finalizerinfo
dsamersoff
parents: 31790
diff changeset
   503
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   504
#if INCLUDE_SERVICES // Heap dumping/inspection supported
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   505
HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   506
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   507
  _filename("filename","Name of the dump file", "STRING",true),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   508
  _all("-all", "Dump all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   509
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   510
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   511
  _dcmdparser.add_dcmd_argument(&_filename);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   512
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   513
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   514
void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   515
  // Request a full GC before heap dump if _all is false
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   516
  // This helps reduces the amount of unreachable objects in the dump
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   517
  // and makes it easier to browse.
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   518
  HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   519
  int res = dumper.dump(_filename.value());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   520
  if (res == 0) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   521
    output()->print_cr("Heap dump file created");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   522
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   523
    // heap dump failed
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   524
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   525
    char* error = dumper.error_as_C_string();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   526
    if (error == NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   527
      output()->print_cr("Dump failed - reason unknown");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   528
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   529
      output()->print_cr("%s", error);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   530
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   531
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   532
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   533
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   534
int HeapDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   535
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   536
  HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   537
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   538
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   539
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   540
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   541
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   542
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   543
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   544
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   545
ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   546
                                       DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   547
  _all("-all", "Inspect all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   548
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   549
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   550
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   551
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   552
void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   553
  VM_GC_HeapInspection heapop(output(),
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17296
diff changeset
   554
                              !_all.value() /* request full gc if false */);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   555
  VMThread::execute(&heapop);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   556
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   557
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   558
int ClassHistogramDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   559
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   560
  ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   561
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   562
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   563
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   564
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   565
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   566
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   567
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   568
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   569
#define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   570
ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   571
                                       DCmdWithParser(output, heap),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 50785
diff changeset
   572
  _all("-all", "Show all columns",
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   573
       "BOOLEAN", false, "false"),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 50785
diff changeset
   574
  _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   575
       "BOOLEAN", false, "false"),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   576
  _help("-help", "Show meaning of all the columns",
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   577
       "BOOLEAN", false, "false"),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   578
  _columns("columns", "Comma-separated list of all the columns to show. "
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   579
           "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   580
           "STRING", false) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   581
  _dcmdparser.add_dcmd_option(&_all);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   582
  _dcmdparser.add_dcmd_option(&_csv);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   583
  _dcmdparser.add_dcmd_option(&_help);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   584
  _dcmdparser.add_dcmd_argument(&_columns);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   585
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   586
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   587
void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   588
  VM_GC_HeapInspection heapop(output(),
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17296
diff changeset
   589
                              true /* request_full_gc */);
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   590
  heapop.set_csv_format(_csv.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   591
  heapop.set_print_help(_help.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   592
  heapop.set_print_class_stats(true);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   593
  if (_all.value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   594
    if (_columns.has_value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   595
      output()->print_cr("Cannot specify -all and individual columns at the same time");
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   596
      return;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   597
    } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   598
      heapop.set_columns(NULL);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   599
    }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   600
  } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   601
    if (_columns.has_value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   602
      heapop.set_columns(_columns.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   603
    } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   604
      heapop.set_columns(DEFAULT_COLUMNS);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   605
    }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   606
  }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   607
  VMThread::execute(&heapop);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   608
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   609
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   610
int ClassStatsDCmd::num_arguments() {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   611
  ResourceMark rm;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   612
  ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   613
  if (dcmd != NULL) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   614
    DCmdMark mark(dcmd);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   615
    return dcmd->_dcmdparser.num_arguments();
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   616
  } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   617
    return 0;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   618
  }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   619
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   620
#endif // INCLUDE_SERVICES
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   621
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   622
ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   623
                               DCmdWithParser(output, heap),
50785
d1b24f2ceca5 8200720: Print additional information in thread dump (times, allocated bytes etc.)
ghaug
parents: 50443
diff changeset
   624
  _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false"),
d1b24f2ceca5 8200720: Print additional information in thread dump (times, allocated bytes etc.)
ghaug
parents: 50443
diff changeset
   625
  _extended("-e", "print extended thread information", "BOOLEAN", false, "false") {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   626
  _dcmdparser.add_dcmd_option(&_locks);
50785
d1b24f2ceca5 8200720: Print additional information in thread dump (times, allocated bytes etc.)
ghaug
parents: 50443
diff changeset
   627
  _dcmdparser.add_dcmd_option(&_extended);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   628
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   629
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   630
void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   631
  // thread stacks
50785
d1b24f2ceca5 8200720: Print additional information in thread dump (times, allocated bytes etc.)
ghaug
parents: 50443
diff changeset
   632
  VM_PrintThreads op1(output(), _locks.value(), _extended.value());
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   633
  VMThread::execute(&op1);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   634
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   635
  // JNI global handles
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   636
  VM_PrintJNI op2(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   637
  VMThread::execute(&op2);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   638
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   639
  // Deadlock detection
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   640
  VM_FindDeadlocks op3(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   641
  VMThread::execute(&op3);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   642
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   643
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   644
int ThreadDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   645
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   646
  ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   647
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   648
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   649
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   650
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   651
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   652
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   653
}
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   654
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   655
// Enhanced JMX Agent support
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   656
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   657
JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   658
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   659
  DCmdWithParser(output, heap_allocated),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   660
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   661
  _config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   662
  ("config.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   663
   "set com.sun.management.config.file", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   664
35186
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   665
  _jmxremote_host
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   666
  ("jmxremote.host",
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   667
   "set com.sun.management.jmxremote.host", "STRING", false),
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   668
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   669
  _jmxremote_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   670
  ("jmxremote.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   671
   "set com.sun.management.jmxremote.port", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   672
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   673
  _jmxremote_rmi_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   674
  ("jmxremote.rmi.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   675
   "set com.sun.management.jmxremote.rmi.port", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   676
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   677
  _jmxremote_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   678
  ("jmxremote.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   679
   "set com.sun.management.jmxremote.ssl", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   680
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   681
  _jmxremote_registry_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   682
  ("jmxremote.registry.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   683
   "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   684
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   685
  _jmxremote_authenticate
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   686
  ("jmxremote.authenticate",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   687
   "set com.sun.management.jmxremote.authenticate", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   688
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   689
  _jmxremote_password_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   690
  ("jmxremote.password.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   691
   "set com.sun.management.jmxremote.password.file", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   692
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   693
  _jmxremote_access_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   694
  ("jmxremote.access.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   695
   "set com.sun.management.jmxremote.access.file", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   696
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   697
  _jmxremote_login_config
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   698
  ("jmxremote.login.config",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   699
   "set com.sun.management.jmxremote.login.config", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   700
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   701
  _jmxremote_ssl_enabled_cipher_suites
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   702
  ("jmxremote.ssl.enabled.cipher.suites",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   703
   "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   704
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   705
  _jmxremote_ssl_enabled_protocols
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   706
  ("jmxremote.ssl.enabled.protocols",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   707
   "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   708
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   709
  _jmxremote_ssl_need_client_auth
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   710
  ("jmxremote.ssl.need.client.auth",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   711
   "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   712
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   713
  _jmxremote_ssl_config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   714
  ("jmxremote.ssl.config.file",
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   715
   "set com.sun.management.jmxremote.ssl_config_file", "STRING", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   716
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   717
// JDP Protocol support
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   718
  _jmxremote_autodiscovery
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   719
  ("jmxremote.autodiscovery",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   720
   "set com.sun.management.jmxremote.autodiscovery", "STRING", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   721
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   722
   _jdp_port
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   723
  ("jdp.port",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   724
   "set com.sun.management.jdp.port", "INT", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   725
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   726
   _jdp_address
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   727
  ("jdp.address",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   728
   "set com.sun.management.jdp.address", "STRING", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   729
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   730
   _jdp_source_addr
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   731
  ("jdp.source_addr",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   732
   "set com.sun.management.jdp.source_addr", "STRING", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   733
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   734
   _jdp_ttl
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   735
  ("jdp.ttl",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   736
   "set com.sun.management.jdp.ttl", "INT", false),
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   737
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   738
   _jdp_pause
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   739
  ("jdp.pause",
21076
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   740
   "set com.sun.management.jdp.pause", "INT", false),
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   741
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   742
   _jdp_name
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   743
  ("jdp.name",
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   744
   "set com.sun.management.jdp.name", "STRING", false)
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   745
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   746
  {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   747
    _dcmdparser.add_dcmd_option(&_config_file);
35186
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   748
    _dcmdparser.add_dcmd_option(&_jmxremote_host);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   749
    _dcmdparser.add_dcmd_option(&_jmxremote_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   750
    _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   751
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   752
    _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   753
    _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   754
    _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   755
    _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   756
    _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   757
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   758
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   759
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   760
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   761
    _dcmdparser.add_dcmd_option(&_jmxremote_autodiscovery);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   762
    _dcmdparser.add_dcmd_option(&_jdp_port);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   763
    _dcmdparser.add_dcmd_option(&_jdp_address);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   764
    _dcmdparser.add_dcmd_option(&_jdp_source_addr);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   765
    _dcmdparser.add_dcmd_option(&_jdp_ttl);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   766
    _dcmdparser.add_dcmd_option(&_jdp_pause);
21076
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   767
    _dcmdparser.add_dcmd_option(&_jdp_name);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   768
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   769
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   770
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   771
int JMXStartRemoteDCmd::num_arguments() {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   772
  ResourceMark rm;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   773
  JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   774
  if (dcmd != NULL) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   775
    DCmdMark mark(dcmd);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   776
    return dcmd->_dcmdparser.num_arguments();
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   777
  } else {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   778
    return 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   779
  }
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   780
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   781
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   782
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   783
void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) {
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   784
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   785
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   786
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   787
    // Load and initialize the jdk.internal.agent.Agent class
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   788
    // invoke startRemoteManagementAgent(string) method to start
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   789
    // the remote management server.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   790
    // throw java.lang.NoSuchMethodError if the method doesn't exist
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   791
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
   792
    loadAgentModule(CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   793
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   794
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   795
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   796
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   797
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   798
    // Pass all command line arguments to java as key=value,...
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   799
    // All checks are done on java side
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   800
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   801
    int len = 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   802
    stringStream options;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   803
    char comma[2] = {0,0};
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   804
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   805
    // Leave default values on Agent.class side and pass only
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   806
    // agruments explicitly set by user. All arguments passed
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   807
    // to jcmd override properties with the same name set by
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   808
    // command line with -D or by managmenent.properties
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   809
    // file.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   810
#define PUT_OPTION(a) \
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   811
    do { \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   812
        if ( (a).is_set() ){ \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   813
            if ( *((a).type()) == 'I' ) { \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   814
                options.print("%scom.sun.management.%s=" JLONG_FORMAT, comma, (a).name(), (jlong)((a).value())); \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   815
            } else { \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   816
                options.print("%scom.sun.management.%s=%s", comma, (a).name(), (char*)((a).value())); \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   817
            } \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   818
            comma[0] = ','; \
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   819
        }\
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   820
    } while(0);
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 32072
diff changeset
   821
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   822
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   823
    PUT_OPTION(_config_file);
35186
89076d5121c0 6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents: 35061
diff changeset
   824
    PUT_OPTION(_jmxremote_host);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   825
    PUT_OPTION(_jmxremote_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   826
    PUT_OPTION(_jmxremote_rmi_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   827
    PUT_OPTION(_jmxremote_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   828
    PUT_OPTION(_jmxremote_registry_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   829
    PUT_OPTION(_jmxremote_authenticate);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   830
    PUT_OPTION(_jmxremote_password_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   831
    PUT_OPTION(_jmxremote_access_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   832
    PUT_OPTION(_jmxremote_login_config);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   833
    PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   834
    PUT_OPTION(_jmxremote_ssl_enabled_protocols);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   835
    PUT_OPTION(_jmxremote_ssl_need_client_auth);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   836
    PUT_OPTION(_jmxremote_ssl_config_file);
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   837
    PUT_OPTION(_jmxremote_autodiscovery);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   838
    PUT_OPTION(_jdp_port);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   839
    PUT_OPTION(_jdp_address);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   840
    PUT_OPTION(_jdp_source_addr);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   841
    PUT_OPTION(_jdp_ttl);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   842
    PUT_OPTION(_jdp_pause);
21076
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   843
    PUT_OPTION(_jdp_name);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   844
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   845
#undef PUT_OPTION
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   846
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   847
    Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   848
    JavaCalls::call_static(&result, k, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   849
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   850
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   851
JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   852
  DCmd(output, heap_allocated) {
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   853
  // do nothing
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   854
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   855
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   856
void JMXStartLocalDCmd::execute(DCmdSource source, TRAPS) {
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   857
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   858
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   859
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   860
    // Load and initialize the jdk.internal.agent.Agent class
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   861
    // invoke startLocalManagementAgent(void) method to start
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   862
    // the local management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   863
    // throw java.lang.NoSuchMethodError if method doesn't exist
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   864
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
   865
    loadAgentModule(CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   866
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   867
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   868
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   869
    JavaValue result(T_VOID);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   870
    JavaCalls::call_static(&result, k, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   871
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   872
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   873
void JMXStopRemoteDCmd::execute(DCmdSource source, TRAPS) {
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   874
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   875
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   876
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   877
    // Load and initialize the jdk.internal.agent.Agent class
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   878
    // invoke stopRemoteManagementAgent method to stop the
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   879
    // management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   880
    // throw java.lang.NoSuchMethodError if method doesn't exist
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   881
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
   882
    loadAgentModule(CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   883
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   884
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   885
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   886
    JavaValue result(T_VOID);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   887
    JavaCalls::call_static(&result, k, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   888
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   889
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   890
JMXStatusDCmd::JMXStatusDCmd(outputStream *output, bool heap_allocated) :
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   891
  DCmd(output, heap_allocated) {
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   892
  // do nothing
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   893
}
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   894
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   895
void JMXStatusDCmd::execute(DCmdSource source, TRAPS) {
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   896
  ResourceMark rm(THREAD);
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   897
  HandleMark hm(THREAD);
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   898
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   899
  // Load and initialize the jdk.internal.agent.Agent class
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   900
  // invoke getManagementAgentStatus() method to generate the status info
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   901
  // throw java.lang.NoSuchMethodError if method doesn't exist
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   902
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43491
diff changeset
   903
  loadAgentModule(CHECK);
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   904
  Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
43400
cc18486e399f 8173608: Separate JDK management agent from java.management module
mchung
parents: 42075
diff changeset
   905
  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   906
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   907
  JavaValue result(T_OBJECT);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46311
diff changeset
   908
  JavaCalls::call_static(&result, k, vmSymbols::getAgentStatus_name(), vmSymbols::void_string_signature(), CHECK);
30134
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   909
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   910
  jvalue* jv = (jvalue*) result.get_value_addr();
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   911
  oop str = (oop) jv->l;
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   912
  if (str != NULL) {
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   913
      char* out = java_lang_String::as_utf8_string(str);
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   914
      if (out) {
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   915
          output()->print_cr("%s", out);
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   916
          return;
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   917
      }
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   918
  }
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   919
  output()->print_cr("Error obtaining management agent status");
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   920
}
ecd7b08105e9 8023093: Add ManagementAgent.status diagnostic command
jbachorik
parents: 30121
diff changeset
   921
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   922
VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   923
  DCmd(output, heap_allocated) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   924
  // do nothing
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   925
}
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   926
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   927
void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   928
  os::print_dll_info(output());
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   929
  output()->cr();
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   930
}
23517
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   931
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   932
void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
36322
218528915a61 8149789: SIGSEGV in CompileTask::print
neliasso
parents: 35825
diff changeset
   933
  VM_PrintCompileQueue printCompileQueueOp(output());
218528915a61 8149789: SIGSEGV in CompileTask::print
neliasso
parents: 35825
diff changeset
   934
  VMThread::execute(&printCompileQueueOp);
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   935
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   936
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   937
void CodeListDCmd::execute(DCmdSource source, TRAPS) {
35825
7c7652ee137b 8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents: 35186
diff changeset
   938
  CodeCache::print_codelist(output());
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   939
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   940
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   941
void CodeCacheDCmd::execute(DCmdSource source, TRAPS) {
35825
7c7652ee137b 8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents: 35186
diff changeset
   942
  CodeCache::print_layout(output());
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   943
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   944
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   945
//---<  BEGIN  >--- CodeHeap State Analytics.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   946
CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) :
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   947
                                             DCmdWithParser(output, heap),
49825
f909f09569ca 8200450: Root cause analysis for JDK-8200366
lucy
parents: 49750
diff changeset
   948
  _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"),
55294
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   949
  _granularity("granularity", "Detail level - smaller value -> more detail", "INT", false, "4096") {
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   950
  _dcmdparser.add_dcmd_argument(&_function);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   951
  _dcmdparser.add_dcmd_argument(&_granularity);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   952
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   953
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   954
void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) {
55294
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   955
  jlong granularity = _granularity.value();
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   956
  if (granularity < 1) {
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   957
    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   958
                       "Invalid granularity value " JLONG_FORMAT  ". Should be positive.\n", granularity);
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   959
    return;
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   960
  }
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   961
3493c1bc59fd 8225388: Running jcmd Compiler.CodeHeap_Analytics all 0 cause crash.
lmesnik
parents: 55217
diff changeset
   962
  CompileBroker::print_heapinfo(output(), _function.value(), granularity);
49611
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   963
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   964
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   965
int CodeHeapAnalyticsDCmd::num_arguments() {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   966
  ResourceMark rm;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   967
  CodeHeapAnalyticsDCmd* dcmd = new CodeHeapAnalyticsDCmd(NULL, false);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   968
  if (dcmd != NULL) {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   969
    DCmdMark mark(dcmd);
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   970
    return dcmd->_dcmdparser.num_arguments();
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   971
  } else {
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   972
    return 0;
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   973
  }
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   974
}
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   975
//---<  END  >--- CodeHeap State Analytics.
973c9504178e 8198691: CodeHeap State Analytics
lucy
parents: 49480
diff changeset
   976
55217
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   977
EventLogDCmd::EventLogDCmd(outputStream* output, bool heap) :
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   978
  DCmdWithParser(output, heap),
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   979
  _log("log", "Name of log to be printed. If omitted, all logs are printed.", "STRING", false, NULL),
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   980
  _max("max", "Maximum number of events to be printed (newest first). If omitted, all events are printed.", "STRING", false, NULL)
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   981
{
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   982
  _dcmdparser.add_dcmd_option(&_log);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   983
  _dcmdparser.add_dcmd_option(&_max);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   984
}
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   985
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   986
void EventLogDCmd::execute(DCmdSource source, TRAPS) {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   987
  const char* max_value = _max.value();
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   988
  long max = -1;
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   989
  if (max_value != NULL) {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   990
    char* endptr = NULL;
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   991
    max = ::strtol(max_value, &endptr, 10);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   992
    if (max == 0 && max_value == endptr) {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   993
      output()->print_cr("Invalid max option: \"%s\".", max_value);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   994
      return;
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   995
    }
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   996
  }
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   997
  const char* log_name = _log.value();
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   998
  if (log_name != NULL) {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
   999
    Events::print_one(output(), log_name, max);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1000
  } else {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1001
    Events::print_all(output(), max);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1002
  }
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1003
}
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1004
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1005
int EventLogDCmd::num_arguments() {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1006
  ResourceMark rm;
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1007
  EventLogDCmd* dcmd = new EventLogDCmd(NULL, false);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1008
  if (dcmd != NULL) {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1009
    DCmdMark mark(dcmd);
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1010
    return dcmd->_dcmdparser.num_arguments();
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1011
  } else {
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1012
    return 0;
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1013
  }
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1014
}
bb3359bcf534 8224600: Provide VM.events command
stuefe
parents: 54786
diff changeset
  1015
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1016
void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1017
  DirectivesStack::print(output());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1018
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1019
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1020
CompilerDirectivesAddDCmd::CompilerDirectivesAddDCmd(outputStream* output, bool heap) :
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1021
                           DCmdWithParser(output, heap),
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1022
  _filename("filename","Name of the directives file", "STRING",true) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1023
  _dcmdparser.add_dcmd_argument(&_filename);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1024
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1025
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1026
void CompilerDirectivesAddDCmd::execute(DCmdSource source, TRAPS) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1027
  DirectivesParser::parse_from_file(_filename.value(), output());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1028
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1029
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1030
int CompilerDirectivesAddDCmd::num_arguments() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1031
  ResourceMark rm;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1032
  CompilerDirectivesAddDCmd* dcmd = new CompilerDirectivesAddDCmd(NULL, false);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1033
  if (dcmd != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1034
    DCmdMark mark(dcmd);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1035
    return dcmd->_dcmdparser.num_arguments();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1036
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1037
    return 0;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1038
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1039
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1040
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1041
void CompilerDirectivesRemoveDCmd::execute(DCmdSource source, TRAPS) {
36597
ee256e343585 8150646: Add support for blocking compiles though whitebox API
simonis
parents: 36334
diff changeset
  1042
  DirectivesStack::pop(1);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1043
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1044
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1045
void CompilerDirectivesClearDCmd::execute(DCmdSource source, TRAPS) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1046
  DirectivesStack::clear();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33148
diff changeset
  1047
}
29071
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1048
#if INCLUDE_SERVICES
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1049
ClassHierarchyDCmd::ClassHierarchyDCmd(outputStream* output, bool heap) :
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1050
                                       DCmdWithParser(output, heap),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1051
  _print_interfaces("-i", "Inherited interfaces should be printed.", "BOOLEAN", false, "false"),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1052
  _print_subclasses("-s", "If a classname is specified, print its subclasses. "
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1053
                    "Otherwise only its superclasses are printed.", "BOOLEAN", false, "false"),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1054
  _classname("classname", "Name of class whose hierarchy should be printed. "
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1055
             "If not specified, all class hierarchies are printed.",
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1056
             "STRING", false) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1057
  _dcmdparser.add_dcmd_option(&_print_interfaces);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1058
  _dcmdparser.add_dcmd_option(&_print_subclasses);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1059
  _dcmdparser.add_dcmd_argument(&_classname);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1060
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1061
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1062
void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1063
  VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1064
                                               _print_subclasses.value(), _classname.value());
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1065
  VMThread::execute(&printClassHierarchyOp);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1066
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1067
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1068
int ClassHierarchyDCmd::num_arguments() {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1069
  ResourceMark rm;
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1070
  ClassHierarchyDCmd* dcmd = new ClassHierarchyDCmd(NULL, false);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1071
  if (dcmd != NULL) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1072
    DCmdMark mark(dcmd);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1073
    return dcmd->_dcmdparser.num_arguments();
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1074
  } else {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1075
    return 0;
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1076
  }
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1077
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1078
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
  1079
#endif
31790
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1080
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1081
class VM_DumpTouchedMethods : public VM_Operation {
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1082
private:
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1083
  outputStream* _out;
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1084
public:
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1085
  VM_DumpTouchedMethods(outputStream* out) {
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1086
    _out = out;
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1087
  }
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1088
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1089
  virtual VMOp_Type type() const { return VMOp_DumpTouchedMethods; }
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1090
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1091
  virtual void doit() {
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1092
    Method::print_touched_methods(_out);
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1093
  }
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1094
};
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1095
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1096
TouchedMethodsDCmd::TouchedMethodsDCmd(outputStream* output, bool heap) :
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1097
                                       DCmdWithParser(output, heap)
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1098
{}
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1099
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1100
void TouchedMethodsDCmd::execute(DCmdSource source, TRAPS) {
42075
e5b263ac8c2e 8168305: GC.class_stats should not require -XX:+UnlockDiagnosticVMOptions
sla
parents: 41078
diff changeset
  1101
  if (!LogTouchedMethods) {
e5b263ac8c2e 8168305: GC.class_stats should not require -XX:+UnlockDiagnosticVMOptions
sla
parents: 41078
diff changeset
  1102
    output()->print_cr("VM.print_touched_methods command requires -XX:+LogTouchedMethods");
31790
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1103
    return;
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1104
  }
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1105
  VM_DumpTouchedMethods dumper(output());
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1106
  VMThread::execute(&dumper);
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1107
}
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1108
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1109
int TouchedMethodsDCmd::num_arguments() {
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1110
  return 0;
4a08476437e8 8025692: Log what methods are touched at run-time
minqi
parents: 31371
diff changeset
  1111
}
52976
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1112
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1113
#if INCLUDE_JVMTI
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1114
extern "C" typedef char const* (JNICALL *debugInit_startDebuggingViaCommandPtr)(JNIEnv* env, jthread thread, char const** transport_name,
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1115
                                                                                char const** address, jboolean* first_start);
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1116
static debugInit_startDebuggingViaCommandPtr dvc_start_ptr = NULL;
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1117
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1118
DebugOnCmdStartDCmd::DebugOnCmdStartDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1119
}
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1120
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1121
void DebugOnCmdStartDCmd::execute(DCmdSource source, TRAPS) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1122
  char const* transport = NULL;
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1123
  char const* addr = NULL;
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1124
  jboolean is_first_start = JNI_FALSE;
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1125
  JavaThread* thread = (JavaThread*) THREAD;
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1126
  jthread jt = JNIHandles::make_local(thread->threadObj());
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1127
  ThreadToNativeFromVM ttn(thread);
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1128
  const char *error = "Could not find jdwp agent.";
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1129
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1130
  if (!dvc_start_ptr) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1131
    for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1132
      if ((strcmp("jdwp", agent->name()) == 0) && (dvc_start_ptr == NULL)) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1133
        char const* func = "debugInit_startDebuggingViaCommand";
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1134
        dvc_start_ptr = (debugInit_startDebuggingViaCommandPtr) os::find_agent_function(agent, false, &func, 1);
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1135
      }
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1136
    }
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1137
  }
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1138
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1139
  if (dvc_start_ptr) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1140
    error = dvc_start_ptr(thread->jni_environment(), jt, &transport, &addr, &is_first_start);
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1141
  }
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1142
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1143
  if (error != NULL) {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1144
    output()->print_cr("Debugging has not been started: %s", error);
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1145
  } else {
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1146
    output()->print_cr(is_first_start ? "Debugging has been started." : "Debugging is already active.");
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1147
    output()->print_cr("Transport : %s", transport ? transport : "#unknown");
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1148
    output()->print_cr("Address : %s", addr ? addr : "#unknown");
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1149
  }
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1150
}
21dfea980e23 8214892: Delayed starting of debugging via jcmd
clanger
parents: 52876
diff changeset
  1151
#endif // INCLUDE_JVMTI