hotspot/src/share/vm/services/diagnosticCommand.cpp
author ctornqvi
Sat, 14 Feb 2015 00:03:48 +0000
changeset 29074 fbd83ffd242b
parent 29071 73f45d04ad7a
parent 28935 a0a29e3b7864
child 29085 7b01b134b727
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     1
/*
29071
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
     2
 * Copyright (c) 2011, 2015, 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"
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents: 24424
diff changeset
    26
#include "classfile/classLoaderStats.hpp"
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26587
diff changeset
    27
#include "classfile/compactHashtable.hpp"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    28
#include "gc_implementation/shared/vmGCOperations.hpp"
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    29
#include "runtime/javaCalls.hpp"
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
    30
#include "runtime/os.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    31
#include "services/diagnosticArgument.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    32
#include "services/diagnosticCommand.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    33
#include "services/diagnosticFramework.hpp"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    34
#include "services/heapDumper.hpp"
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    35
#include "services/management.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13977
diff changeset
    36
#include "utilities/macros.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    37
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23517
diff changeset
    38
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23517
diff changeset
    39
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    40
void DCmdRegistrant::register_dcmds(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    41
  // Registration of the diagnostic commands
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    42
  // 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
    43
  // 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
    44
  // 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
    45
  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
    46
                         | DCmd_Source_MBean;
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    47
  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
    48
  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
    49
  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
    50
  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
    51
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
    52
  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
    53
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    54
  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
    55
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
    56
#if INCLUDE_SERVICES // Heap dumping/inspection supported
20662
3296bf2cc204 8020789: Disable exporting of gc.heap_dump diagnostic command
sgabdura
parents: 18025
diff changeset
    57
  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
    58
  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
    59
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
29071
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
    60
  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
    61
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26587
diff changeset
    62
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    63
#endif // INCLUDE_SERVICES
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    64
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
23517
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
    65
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false));
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents: 24424
diff changeset
    66
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
    67
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
    68
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
    69
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    70
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    71
  // Enhanced JMX Agent Support
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    72
  // 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
    73
  // appropriate permission is created for them
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    74
  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
    75
  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
    76
  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
    77
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(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
    78
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    79
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    80
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    81
#ifndef HAVE_EXTRA_DCMD
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    82
void DCmdRegistrant::register_dcmds_ext(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    83
   // Do nothing here
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    84
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    85
#endif
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    86
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    87
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    88
HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    89
  _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    90
  _cmd("command name", "The name of the command for which we want help",
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    91
        "STRING", false) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    92
  _dcmdparser.add_dcmd_option(&_all);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    93
  _dcmdparser.add_dcmd_argument(&_cmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    94
};
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    95
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    96
void HelpDCmd::execute(DCmdSource source, TRAPS) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    97
  if (_all.value()) {
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
    98
    GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    99
    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
   100
      DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   101
                                                  strlen(cmd_list->at(i)));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   102
      output()->print_cr("%s%s", factory->name(),
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   103
                         factory->is_enabled() ? "" : " [disabled]");
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   104
      output()->print_cr("\t%s", factory->description());
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   105
      output()->cr();
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   106
      factory = factory->next();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   107
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   108
  } else if (_cmd.has_value()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   109
    DCmd* cmd = NULL;
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   110
    DCmdFactory* factory = DCmdFactory::factory(source, _cmd.value(),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   111
                                                strlen(_cmd.value()));
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   112
    if (factory != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   113
      output()->print_cr("%s%s", factory->name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   114
                         factory->is_enabled() ? "" : " [disabled]");
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23517
diff changeset
   115
      output()->print_cr("%s", factory->description());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   116
      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
   117
      JavaPermission p = factory->permission();
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   118
      if(p._class != NULL) {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   119
        if(p._action != NULL) {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   120
          output()->print_cr("\nPermission: %s(%s, %s)",
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   121
                  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
   122
        } else {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   123
          output()->print_cr("\nPermission: %s(%s)",
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   124
                  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
   125
        }
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   126
      }
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   127
      output()->cr();
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   128
      cmd = factory->create_resource_instance(output());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   129
      if (cmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   130
        DCmdMark mark(cmd);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   131
        cmd->print_help(factory->name());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   132
      }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   133
    } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   134
      output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   135
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   136
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   137
    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
   138
    GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   139
    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
   140
      DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   141
                                                  strlen(cmd_list->at(i)));
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   142
      output()->print_cr("%s%s", factory->name(),
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   143
                         factory->is_enabled() ? "" : " [disabled]");
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   144
      factory = factory->_next;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   145
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   146
    output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   147
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   148
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   149
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   150
int HelpDCmd::num_arguments() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   151
  ResourceMark rm;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   152
  HelpDCmd* dcmd = new HelpDCmd(NULL, false);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   153
  if (dcmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   154
    DCmdMark mark(dcmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   155
    return dcmd->_dcmdparser.num_arguments();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   156
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   157
    return 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   158
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   159
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   160
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   161
void VersionDCmd::execute(DCmdSource source, TRAPS) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   162
  output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   163
          Abstract_VM_Version::vm_release());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   164
  JDK_Version jdk_version = JDK_Version::current();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   165
  if (jdk_version.update_version() > 0) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   166
    output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   167
            jdk_version.minor_version(), jdk_version.update_version());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   168
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   169
    output()->print_cr("JDK %d.%d", jdk_version.major_version(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   170
            jdk_version.minor_version());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   171
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   172
}
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   173
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   174
PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   175
                                   DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   176
  _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   177
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   178
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   179
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   180
void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   181
  if (_all.value()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   182
    CommandLineFlags::printFlags(output(), true);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   183
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   184
    CommandLineFlags::printSetFlags(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   185
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   186
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   187
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   188
int PrintVMFlagsDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   189
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   190
    PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   191
    if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   192
      DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   193
      return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   194
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   195
      return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   196
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   197
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   198
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   199
void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   200
  // load sun.misc.VMSupport
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   201
  Symbol* klass = vmSymbols::sun_misc_VMSupport();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   202
  Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   203
  instanceKlassHandle ik (THREAD, k);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   204
  if (ik->should_be_initialized()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   205
    ik->initialize(THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   206
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   207
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   208
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   209
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   210
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   211
    return;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   212
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   213
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   214
  // invoke the serializePropertiesToByteArray method
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   215
  JavaValue result(T_OBJECT);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   216
  JavaCallArguments args;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   217
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   218
  Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   219
  JavaCalls::call_static(&result,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   220
                         ik,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   221
                         vmSymbols::serializePropertiesToByteArray_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   222
                         signature,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   223
                         &args,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   224
                         THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   225
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   226
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   227
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   228
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   229
    return;
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
  // The result should be a [B
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   233
  oop res = (oop)result.get_jobject();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   234
  assert(res->is_typeArray(), "just checking");
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
   235
  assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   236
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   237
  // copy the bytes to the output stream
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   238
  typeArrayOop ba = typeArrayOop(res);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   239
  jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   240
  output()->print_raw((const char*)addr, ba->length());
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
VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   244
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   245
  _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   246
  _dcmdparser.add_dcmd_option(&_date);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   247
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   248
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   249
void VMUptimeDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   250
  if (_date.value()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   251
    output()->date_stamp(true, "", ": ");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   252
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   253
  output()->time_stamp().update_to(tty->time_stamp().ticks());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   254
  output()->stamp();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   255
  output()->print_cr(" s");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   256
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   257
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   258
int VMUptimeDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   259
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   260
  VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   261
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   262
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   263
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   264
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   265
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   266
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   267
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   268
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   269
void SystemGCDCmd::execute(DCmdSource source, TRAPS) {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   270
  if (!DisableExplicitGC) {
28935
a0a29e3b7864 8072693: [BACKOUT] GCCause should distinguish jcmd GC.run from System.gc()
mgerdin
parents: 28836
diff changeset
   271
    Universe::heap()->collect(GCCause::_java_lang_system_gc);
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   272
  } else {
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   273
    output()->print_cr("Explicit GC is disabled, no GC has been performed.");
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   274
  }
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   275
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   276
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   277
void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   278
  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   279
                                                 true, CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   280
  instanceKlassHandle klass(THREAD, k);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   281
  JavaValue result(T_VOID);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   282
  JavaCalls::call_static(&result, klass,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   283
                         vmSymbols::run_finalization_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   284
                         vmSymbols::void_method_signature(), CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   285
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   286
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   287
#if INCLUDE_SERVICES // Heap dumping/inspection supported
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   288
HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   289
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   290
  _filename("filename","Name of the dump file", "STRING",true),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   291
  _all("-all", "Dump all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   292
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   293
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   294
  _dcmdparser.add_dcmd_argument(&_filename);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   295
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   296
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   297
void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   298
  // Request a full GC before heap dump if _all is false
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   299
  // This helps reduces the amount of unreachable objects in the dump
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   300
  // and makes it easier to browse.
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   301
  HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   302
  int res = dumper.dump(_filename.value());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   303
  if (res == 0) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   304
    output()->print_cr("Heap dump file created");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   305
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   306
    // heap dump failed
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   307
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   308
    char* error = dumper.error_as_C_string();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   309
    if (error == NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   310
      output()->print_cr("Dump failed - reason unknown");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   311
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   312
      output()->print_cr("%s", error);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   313
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   314
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   315
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   316
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   317
int HeapDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   318
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   319
  HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   320
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   321
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   322
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   323
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   324
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   325
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   326
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   327
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   328
ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   329
                                       DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   330
  _all("-all", "Inspect all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   331
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   332
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   333
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   334
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   335
void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   336
  VM_GC_HeapInspection heapop(output(),
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17296
diff changeset
   337
                              !_all.value() /* request full gc if false */);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   338
  VMThread::execute(&heapop);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   339
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   340
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   341
int ClassHistogramDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   342
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   343
  ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   344
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   345
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   346
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   347
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   348
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   349
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   350
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   351
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   352
#define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   353
ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   354
                                       DCmdWithParser(output, heap),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   355
  _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   356
       "BOOLEAN", false, "false"),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   357
  _all("-all", "Show all columns",
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   358
       "BOOLEAN", false, "false"),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   359
  _help("-help", "Show meaning of all the columns",
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   360
       "BOOLEAN", false, "false"),
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   361
  _columns("columns", "Comma-separated list of all the columns to show. "
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   362
           "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   363
           "STRING", false) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   364
  _dcmdparser.add_dcmd_option(&_all);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   365
  _dcmdparser.add_dcmd_option(&_csv);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   366
  _dcmdparser.add_dcmd_option(&_help);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   367
  _dcmdparser.add_dcmd_argument(&_columns);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   368
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   369
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   370
void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   371
  if (!UnlockDiagnosticVMOptions) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   372
    output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions");
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   373
    return;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   374
  }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   375
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   376
  VM_GC_HeapInspection heapop(output(),
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17296
diff changeset
   377
                              true /* request_full_gc */);
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   378
  heapop.set_csv_format(_csv.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   379
  heapop.set_print_help(_help.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   380
  heapop.set_print_class_stats(true);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   381
  if (_all.value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   382
    if (_columns.has_value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   383
      output()->print_cr("Cannot specify -all and individual columns at the same time");
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   384
      return;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   385
    } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   386
      heapop.set_columns(NULL);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   387
    }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   388
  } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   389
    if (_columns.has_value()) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   390
      heapop.set_columns(_columns.value());
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   391
    } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   392
      heapop.set_columns(DEFAULT_COLUMNS);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   393
    }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   394
  }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   395
  VMThread::execute(&heapop);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   396
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   397
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   398
int ClassStatsDCmd::num_arguments() {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   399
  ResourceMark rm;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   400
  ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   401
  if (dcmd != NULL) {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   402
    DCmdMark mark(dcmd);
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   403
    return dcmd->_dcmdparser.num_arguments();
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   404
  } else {
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   405
    return 0;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   406
  }
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   407
}
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   408
#endif // INCLUDE_SERVICES
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 13977
diff changeset
   409
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   410
ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   411
                               DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   412
  _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   413
  _dcmdparser.add_dcmd_option(&_locks);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   414
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   415
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   416
void ThreadDumpDCmd::execute(DCmdSource source, TRAPS) {
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   417
  // thread stacks
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   418
  VM_PrintThreads op1(output(), _locks.value());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   419
  VMThread::execute(&op1);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   420
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   421
  // JNI global handles
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   422
  VM_PrintJNI op2(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   423
  VMThread::execute(&op2);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   424
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   425
  // Deadlock detection
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   426
  VM_FindDeadlocks op3(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   427
  VMThread::execute(&op3);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   428
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   429
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   430
int ThreadDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   431
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   432
  ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   433
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   434
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   435
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   436
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   437
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   438
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   439
}
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   440
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   441
// Enhanced JMX Agent support
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   442
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   443
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
   444
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   445
  DCmdWithParser(output, heap_allocated),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   446
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   447
  _config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   448
  ("config.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   449
   "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
   450
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   451
  _jmxremote_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   452
  ("jmxremote.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   453
   "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
   454
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   455
  _jmxremote_rmi_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   456
  ("jmxremote.rmi.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   457
   "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
   458
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   459
  _jmxremote_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   460
  ("jmxremote.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   461
   "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
   462
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   463
  _jmxremote_registry_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   464
  ("jmxremote.registry.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   465
   "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
   466
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   467
  _jmxremote_authenticate
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   468
  ("jmxremote.authenticate",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   469
   "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
   470
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   471
  _jmxremote_password_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   472
  ("jmxremote.password.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   473
   "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
   474
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   475
  _jmxremote_access_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   476
  ("jmxremote.access.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   477
   "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
   478
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   479
  _jmxremote_login_config
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   480
  ("jmxremote.login.config",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   481
   "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
   482
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   483
  _jmxremote_ssl_enabled_cipher_suites
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   484
  ("jmxremote.ssl.enabled.cipher.suites",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   485
   "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
   486
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   487
  _jmxremote_ssl_enabled_protocols
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   488
  ("jmxremote.ssl.enabled.protocols",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   489
   "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
   490
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   491
  _jmxremote_ssl_need_client_auth
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   492
  ("jmxremote.ssl.need.client.auth",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   493
   "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
   494
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   495
  _jmxremote_ssl_config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   496
  ("jmxremote.ssl.config.file",
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   497
   "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
   498
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   499
// JDP Protocol support
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   500
  _jmxremote_autodiscovery
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   501
  ("jmxremote.autodiscovery",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   502
   "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
   503
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   504
   _jdp_port
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   505
  ("jdp.port",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   506
   "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
   507
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   508
   _jdp_address
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   509
  ("jdp.address",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   510
   "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
   511
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   512
   _jdp_source_addr
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   513
  ("jdp.source_addr",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   514
   "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
   515
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   516
   _jdp_ttl
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   517
  ("jdp.ttl",
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   518
   "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
   519
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   520
   _jdp_pause
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   521
  ("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
   522
   "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
   523
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   524
   _jdp_name
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   525
  ("jdp.name",
7cea9d36a46e 8026930: In ManagementAgent.start it should be possible to set the jdp.name parameter (hotspot part)
dsamersoff
parents: 18025
diff changeset
   526
   "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
   527
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   528
  {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   529
    _dcmdparser.add_dcmd_option(&_config_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   530
    _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
   531
    _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
   532
    _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
   533
    _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
   534
    _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
   535
    _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
   536
    _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
   537
    _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
   538
    _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
   539
    _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
   540
    _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
   541
    _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
   542
    _dcmdparser.add_dcmd_option(&_jmxremote_autodiscovery);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   543
    _dcmdparser.add_dcmd_option(&_jdp_port);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   544
    _dcmdparser.add_dcmd_option(&_jdp_address);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   545
    _dcmdparser.add_dcmd_option(&_jdp_source_addr);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   546
    _dcmdparser.add_dcmd_option(&_jdp_ttl);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   547
    _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
   548
    _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
   549
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   550
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   551
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   552
int JMXStartRemoteDCmd::num_arguments() {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   553
  ResourceMark rm;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   554
  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
   555
  if (dcmd != NULL) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   556
    DCmdMark mark(dcmd);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   557
    return dcmd->_dcmdparser.num_arguments();
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   558
  } else {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   559
    return 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   560
  }
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   561
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   562
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   563
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   564
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
   565
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   566
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   567
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   568
    // Load and initialize the sun.management.Agent class
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   569
    // 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
   570
    // the remote management server.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   571
    // 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
   572
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   573
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   574
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_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
   575
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   576
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   577
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   578
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   579
    // 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
   580
    // 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
   581
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   582
    int len = 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   583
    stringStream options;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   584
    char comma[2] = {0,0};
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   585
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   586
    // 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
   587
    // 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
   588
    // 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
   589
    // 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
   590
    // file.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   591
#define PUT_OPTION(a) \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   592
    if ( (a).is_set() ){ \
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   593
        options.print(\
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   594
               ( *((a).type()) == 'I' ) ? "%scom.sun.management.%s=%d" : "%scom.sun.management.%s=%s",\
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   595
                comma, (a).name(), (a).value()); \
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   596
        comma[0] = ','; \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   597
    }
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   598
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   599
    PUT_OPTION(_config_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   600
    PUT_OPTION(_jmxremote_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   601
    PUT_OPTION(_jmxremote_rmi_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   602
    PUT_OPTION(_jmxremote_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   603
    PUT_OPTION(_jmxremote_registry_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   604
    PUT_OPTION(_jmxremote_authenticate);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   605
    PUT_OPTION(_jmxremote_password_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   606
    PUT_OPTION(_jmxremote_access_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   607
    PUT_OPTION(_jmxremote_login_config);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   608
    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
   609
    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
   610
    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
   611
    PUT_OPTION(_jmxremote_ssl_config_file);
15460
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   612
    PUT_OPTION(_jmxremote_autodiscovery);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   613
    PUT_OPTION(_jdp_port);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   614
    PUT_OPTION(_jdp_address);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   615
    PUT_OPTION(_jdp_source_addr);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   616
    PUT_OPTION(_jdp_ttl);
ac08a4bdd0f6 8002048: Protocol to discovery of manageable Java processes on a network
dsamersoff
parents: 15437
diff changeset
   617
    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
   618
    PUT_OPTION(_jdp_name);
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   619
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   620
#undef PUT_OPTION
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   621
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   622
    Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   623
    JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   624
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   625
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   626
JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   627
  DCmd(output, heap_allocated) {
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   628
  // do nothing
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   629
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   630
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   631
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
   632
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   633
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   634
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   635
    // Load and initialize the sun.management.Agent class
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   636
    // 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
   637
    // the local management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   638
    // 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
   639
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   640
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   641
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_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
   642
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   643
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   644
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   645
    JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   646
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   647
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 15484
diff changeset
   648
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
   649
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   650
    HandleMark hm(THREAD);
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
    // Load and initialize the sun.management.Agent class
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   653
    // 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
   654
    // management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   655
    // 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
   656
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   657
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11953
diff changeset
   658
    Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_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
   659
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   660
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   661
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   662
    JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
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
22490
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   665
VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   666
  DCmd(output, heap_allocated) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   667
  // do nothing
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   668
}
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   669
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   670
void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   671
  os::print_dll_info(output());
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   672
  output()->cr();
039128291aa6 8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents: 21121
diff changeset
   673
}
23517
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   674
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   675
void RotateGCLogDCmd::execute(DCmdSource source, TRAPS) {
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   676
  if (UseGCLogFileRotation) {
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   677
    VM_RotateGCLog rotateop(output());
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   678
    VMThread::execute(&rotateop);
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   679
  } else {
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   680
    output()->print_cr("Target VM does not support GC log file rotation.");
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   681
  }
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   682
}
27c4307d6cda 7090324: gclog rotation via external tool
minqi
parents: 22490
diff changeset
   683
26587
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   684
void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   685
  VM_PrintCompileQueue printCompileQueueOp(output());
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   686
  VMThread::execute(&printCompileQueueOp);
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   687
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   688
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   689
void CodeListDCmd::execute(DCmdSource source, TRAPS) {
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   690
  VM_PrintCodeList printCodeListOp(output());
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   691
  VMThread::execute(&printCodeListOp);
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   692
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   693
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   694
void CodeCacheDCmd::execute(DCmdSource source, TRAPS) {
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   695
  VM_PrintCodeCache printCodeCacheOp(output());
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   696
  VMThread::execute(&printCodeCacheOp);
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   697
}
e8b28fa936af 8054889: Compiler team's implementation task
neliasso
parents: 25051
diff changeset
   698
29071
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   699
#if INCLUDE_SERVICES
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   700
ClassHierarchyDCmd::ClassHierarchyDCmd(outputStream* output, bool heap) :
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   701
                                       DCmdWithParser(output, heap),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   702
  _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
   703
  _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
   704
                    "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
   705
  _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
   706
             "If not specified, all class hierarchies are printed.",
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   707
             "STRING", false) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   708
  _dcmdparser.add_dcmd_option(&_print_interfaces);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   709
  _dcmdparser.add_dcmd_option(&_print_subclasses);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   710
  _dcmdparser.add_dcmd_argument(&_classname);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   711
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   712
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   713
void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   714
  VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   715
                                               _print_subclasses.value(), _classname.value());
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   716
  VMThread::execute(&printClassHierarchyOp);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   717
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   718
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   719
int ClassHierarchyDCmd::num_arguments() {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   720
  ResourceMark rm;
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   721
  ClassHierarchyDCmd* dcmd = new ClassHierarchyDCmd(NULL, false);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   722
  if (dcmd != NULL) {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   723
    DCmdMark mark(dcmd);
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   724
    return dcmd->_dcmdparser.num_arguments();
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   725
  } else {
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   726
    return 0;
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   727
  }
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   728
}
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   729
73f45d04ad7a 8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents: 28836
diff changeset
   730
#endif