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