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