hotspot/src/share/vm/services/diagnosticCommand.cpp
author coleenp
Fri, 23 Mar 2012 11:16:05 -0400
changeset 12263 d20640f4f8fe
parent 11953 d06edd28ba62
child 13728 882756847a04
permissions -rw-r--r--
7150058: Allocate symbols from null boot loader to an arena for NMT Summary: Move symbol allocation to an arena so NMT doesn't have to track them at startup. Reviewed-by: never, kamg, zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     1
/*
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
     2
 * Copyright (c) 2011, 2012, 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"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    26
#include "gc_implementation/shared/vmGCOperations.hpp"
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    27
#include "runtime/javaCalls.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    28
#include "services/diagnosticArgument.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    29
#include "services/diagnosticCommand.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    30
#include "services/diagnosticFramework.hpp"
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    31
#include "services/heapDumper.hpp"
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    32
#include "services/management.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    33
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    34
void DCmdRegistrant::register_dcmds(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    35
  // Registration of the diagnostic commands
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    36
  // First boolean argument specifies if the command is enabled
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    37
  // Second boolean argument specifies if the command is hidden
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    38
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    39
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    40
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    41
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    42
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    43
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    44
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    45
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    46
#ifndef SERVICES_KERNEL   // Heap dumping not supported
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    47
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    48
#endif // SERVICES_KERNEL
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    49
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    50
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    51
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
    52
  //Enhanced JMX Agent Support
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
    53
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
    54
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
    55
  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
    56
11598
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    57
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    58
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    59
#ifndef HAVE_EXTRA_DCMD
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    60
void DCmdRegistrant::register_dcmds_ext(){
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    61
   // Do nothing here
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    62
}
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    63
#endif
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    64
db8931f2a56d 7132515: Add dcmd to manage UnlockingCommercialFeature flag
dsamersoff
parents: 11441
diff changeset
    65
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    66
HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    67
  _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    68
  _cmd("command name", "The name of the command for which we want help",
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    69
        "STRING", false) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    70
  _dcmdparser.add_dcmd_option(&_all);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    71
  _dcmdparser.add_dcmd_argument(&_cmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    72
};
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    73
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    74
void HelpDCmd::execute(TRAPS) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    75
  if (_all.value()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    76
    GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    77
    for (int i = 0; i < cmd_list->length(); i++) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    78
      DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    79
                                                  strlen(cmd_list->at(i)));
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    80
      if (!factory->is_hidden()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    81
        output()->print_cr("%s%s", factory->name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    82
                           factory->is_enabled() ? "" : " [disabled]");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    83
        output()->print_cr("\t%s", factory->description());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    84
        output()->cr();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    85
      }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    86
      factory = factory->next();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    87
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    88
  } else if (_cmd.has_value()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    89
    DCmd* cmd = NULL;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    90
    DCmdFactory* factory = DCmdFactory::factory(_cmd.value(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    91
                                                strlen(_cmd.value()));
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    92
    if (factory != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    93
      output()->print_cr("%s%s", factory->name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    94
                         factory->is_enabled() ? "" : " [disabled]");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    95
      output()->print_cr(factory->description());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    96
      output()->print_cr("\nImpact: %s", factory->impact());
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
    97
      output()->cr();
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    98
      cmd = factory->create_resource_instance(output());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    99
      if (cmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   100
        DCmdMark mark(cmd);
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   101
        cmd->print_help(factory->name());
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   102
      }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   103
    } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   104
      output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   105
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   106
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   107
    output()->print_cr("The following commands are available:");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   108
    GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   109
    for (int i = 0; i < cmd_list->length(); i++) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   110
      DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   111
                                                  strlen(cmd_list->at(i)));
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   112
      if (!factory->is_hidden()) {
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]");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   115
      }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   116
      factory = factory->_next;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   117
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   118
    output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   119
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   120
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   121
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   122
int HelpDCmd::num_arguments() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   123
  ResourceMark rm;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   124
  HelpDCmd* dcmd = new HelpDCmd(NULL, false);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   125
  if (dcmd != NULL) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   126
    DCmdMark mark(dcmd);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   127
    return dcmd->_dcmdparser.num_arguments();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   128
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   129
    return 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   130
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   131
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   132
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   133
void VersionDCmd::execute(TRAPS) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   134
  output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   135
          Abstract_VM_Version::vm_release());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   136
  JDK_Version jdk_version = JDK_Version::current();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   137
  if (jdk_version.update_version() > 0) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   138
    output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   139
            jdk_version.minor_version(), jdk_version.update_version());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   140
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   141
    output()->print_cr("JDK %d.%d", jdk_version.major_version(),
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   142
            jdk_version.minor_version());
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   143
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   144
}
11441
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   145
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   146
PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   147
                                   DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   148
  _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   149
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   150
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   151
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   152
void PrintVMFlagsDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   153
  if (_all.value()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   154
    CommandLineFlags::printFlags(output(), true);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   155
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   156
    CommandLineFlags::printSetFlags(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   157
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   158
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   159
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   160
int PrintVMFlagsDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   161
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   162
    PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   163
    if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   164
      DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   165
      return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   166
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   167
      return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   168
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   169
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   170
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   171
void PrintSystemPropertiesDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   172
  // load sun.misc.VMSupport
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   173
  Symbol* klass = vmSymbols::sun_misc_VMSupport();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   174
  klassOop k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   175
  instanceKlassHandle ik (THREAD, k);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   176
  if (ik->should_be_initialized()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   177
    ik->initialize(THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   178
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   179
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   180
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   181
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   182
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   183
    return;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   184
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   185
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   186
  // invoke the serializePropertiesToByteArray method
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   187
  JavaValue result(T_OBJECT);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   188
  JavaCallArguments args;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   189
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   190
  Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   191
  JavaCalls::call_static(&result,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   192
                         ik,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   193
                         vmSymbols::serializePropertiesToByteArray_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   194
                         signature,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   195
                         &args,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   196
                         THREAD);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   197
  if (HAS_PENDING_EXCEPTION) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   198
    java_lang_Throwable::print(PENDING_EXCEPTION, output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   199
    output()->cr();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   200
    CLEAR_PENDING_EXCEPTION;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   201
    return;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   202
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   203
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   204
  // The result should be a [B
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   205
  oop res = (oop)result.get_jobject();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   206
  assert(res->is_typeArray(), "just checking");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   207
  assert(typeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   208
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   209
  // copy the bytes to the output stream
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   210
  typeArrayOop ba = typeArrayOop(res);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   211
  jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   212
  output()->print_raw((const char*)addr, ba->length());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   213
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   214
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   215
VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   216
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   217
  _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   218
  _dcmdparser.add_dcmd_option(&_date);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   219
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   220
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   221
void VMUptimeDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   222
  if (_date.value()) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   223
    output()->date_stamp(true, "", ": ");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   224
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   225
  output()->time_stamp().update_to(tty->time_stamp().ticks());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   226
  output()->stamp();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   227
  output()->print_cr(" s");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   228
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   229
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   230
int VMUptimeDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   231
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   232
  VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   233
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   234
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   235
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   236
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   237
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   238
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   239
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   240
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   241
void SystemGCDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   242
  Universe::heap()->collect(GCCause::_java_lang_system_gc);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   243
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   244
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   245
void RunFinalizationDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   246
  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   247
                                                 true, CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   248
  instanceKlassHandle klass(THREAD, k);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   249
  JavaValue result(T_VOID);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   250
  JavaCalls::call_static(&result, klass,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   251
                         vmSymbols::run_finalization_name(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   252
                         vmSymbols::void_method_signature(), CHECK);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   253
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   254
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   255
#ifndef SERVICES_KERNEL   // Heap dumping not supported
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   256
HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   257
                           DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   258
  _filename("filename","Name of the dump file", "STRING",true),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   259
  _all("-all", "Dump all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   260
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   261
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   262
  _dcmdparser.add_dcmd_argument(&_filename);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   263
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   264
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   265
void HeapDumpDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   266
  // Request a full GC before heap dump if _all is false
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   267
  // This helps reduces the amount of unreachable objects in the dump
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   268
  // and makes it easier to browse.
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   269
  HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   270
  int res = dumper.dump(_filename.value());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   271
  if (res == 0) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   272
    output()->print_cr("Heap dump file created");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   273
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   274
    // heap dump failed
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   275
    ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   276
    char* error = dumper.error_as_C_string();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   277
    if (error == NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   278
      output()->print_cr("Dump failed - reason unknown");
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   279
    } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   280
      output()->print_cr("%s", error);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   281
    }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   282
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   283
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   284
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   285
int HeapDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   286
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   287
  HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   288
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   289
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   290
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   291
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   292
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   293
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   294
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   295
#endif // SERVICES_KERNEL
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   296
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   297
ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   298
                                       DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   299
  _all("-all", "Inspect all objects, including unreachable objects",
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   300
       "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   301
  _dcmdparser.add_dcmd_option(&_all);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   302
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   303
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   304
void ClassHistogramDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   305
  VM_GC_HeapInspection heapop(output(),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   306
                              !_all.value() /* request full gc if false */,
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   307
                              true /* need_prologue */);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   308
  VMThread::execute(&heapop);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   309
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   310
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   311
int ClassHistogramDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   312
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   313
  ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   314
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   315
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   316
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   317
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   318
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   319
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   320
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   321
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   322
ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   323
                               DCmdWithParser(output, heap),
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   324
  _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   325
  _dcmdparser.add_dcmd_option(&_locks);
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
void ThreadDumpDCmd::execute(TRAPS) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   329
  // thread stacks
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   330
  VM_PrintThreads op1(output(), _locks.value());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   331
  VMThread::execute(&op1);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   332
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   333
  // JNI global handles
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   334
  VM_PrintJNI op2(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   335
  VMThread::execute(&op2);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   336
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   337
  // Deadlock detection
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   338
  VM_FindDeadlocks op3(output());
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   339
  VMThread::execute(&op3);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   340
}
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   341
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   342
int ThreadDumpDCmd::num_arguments() {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   343
  ResourceMark rm;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   344
  ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   345
  if (dcmd != NULL) {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   346
    DCmdMark mark(dcmd);
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   347
    return dcmd->_dcmdparser.num_arguments();
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   348
  } else {
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   349
    return 0;
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   350
  }
a89f443814cd 7120511: Add diagnostic commands
fparain
parents: 11209
diff changeset
   351
}
11953
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   352
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   353
// Enhanced JMX Agent support
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   354
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   355
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
   356
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   357
  DCmdWithParser(output, heap_allocated),
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   358
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   359
  _config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   360
  ("config.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   361
   "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
   362
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   363
  _jmxremote_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   364
  ("jmxremote.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   365
   "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
   366
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   367
  _jmxremote_rmi_port
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   368
  ("jmxremote.rmi.port",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   369
   "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
   370
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   371
  _jmxremote_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   372
  ("jmxremote.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   373
   "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
   374
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   375
  _jmxremote_registry_ssl
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   376
  ("jmxremote.registry.ssl",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   377
   "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
   378
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   379
  _jmxremote_authenticate
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   380
  ("jmxremote.authenticate",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   381
   "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
   382
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   383
  _jmxremote_password_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   384
  ("jmxremote.password.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   385
   "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
   386
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   387
  _jmxremote_access_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   388
  ("jmxremote.access.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   389
   "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
   390
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   391
  _jmxremote_login_config
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   392
  ("jmxremote.login.config",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   393
   "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
   394
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   395
  _jmxremote_ssl_enabled_cipher_suites
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   396
  ("jmxremote.ssl.enabled.cipher.suites",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   397
   "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
   398
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   399
  _jmxremote_ssl_enabled_protocols
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   400
  ("jmxremote.ssl.enabled.protocols",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   401
   "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
   402
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   403
  _jmxremote_ssl_need_client_auth
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   404
  ("jmxremote.ssl.need.client.auth",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   405
   "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
   406
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   407
  _jmxremote_ssl_config_file
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   408
  ("jmxremote.ssl.config.file",
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   409
   "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   410
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   411
  {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   412
    _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
   413
    _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
   414
    _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
   415
    _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
   416
    _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
   417
    _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
   418
    _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
   419
    _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
   420
    _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
   421
    _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
   422
    _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
   423
    _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
   424
    _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   425
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   426
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   427
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   428
int JMXStartRemoteDCmd::num_arguments() {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   429
  ResourceMark rm;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   430
  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
   431
  if (dcmd != NULL) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   432
    DCmdMark mark(dcmd);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   433
    return dcmd->_dcmdparser.num_arguments();
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   434
  } else {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   435
    return 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   436
  }
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   437
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   438
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   439
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   440
void JMXStartRemoteDCmd::execute(TRAPS) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   441
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   442
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   443
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   444
    // 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
   445
    // 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
   446
    // the remote management server.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   447
    // 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
   448
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   449
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   450
    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   451
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   452
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   453
    JavaValue result(T_VOID);
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
    // 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
   456
    // 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
   457
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   458
    int len = 0;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   459
    stringStream options;
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   460
    char comma[2] = {0,0};
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   461
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   462
    // 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
   463
    // 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
   464
    // 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
   465
    // 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
   466
    // file.
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   467
#define PUT_OPTION(a) \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   468
    if ( (a).is_set() ){ \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   469
        options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   470
        comma[0] = ','; \
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   471
    }
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   472
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   473
    PUT_OPTION(_config_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   474
    PUT_OPTION(_jmxremote_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   475
    PUT_OPTION(_jmxremote_rmi_port);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   476
    PUT_OPTION(_jmxremote_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   477
    PUT_OPTION(_jmxremote_registry_ssl);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   478
    PUT_OPTION(_jmxremote_authenticate);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   479
    PUT_OPTION(_jmxremote_password_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   480
    PUT_OPTION(_jmxremote_access_file);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   481
    PUT_OPTION(_jmxremote_login_config);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   482
    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
   483
    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
   484
    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
   485
    PUT_OPTION(_jmxremote_ssl_config_file);
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
#undef PUT_OPTION
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   488
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   489
    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
   490
    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
   491
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   492
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   493
JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   494
  DCmd(output, heap_allocated)
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   495
{
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   496
  // do nothing
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   497
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   498
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   499
void JMXStartLocalDCmd::execute(TRAPS) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   500
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   501
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   502
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   503
    // 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
   504
    // 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
   505
    // the local management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   506
    // 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
   507
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   508
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   509
    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   510
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   511
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   512
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   513
    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
   514
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   515
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   516
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   517
void JMXStopRemoteDCmd::execute(TRAPS) {
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   518
    ResourceMark rm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   519
    HandleMark hm(THREAD);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   520
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   521
    // 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
   522
    // 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
   523
    // management server
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   524
    // 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
   525
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   526
    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   527
    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   528
    instanceKlassHandle ik (THREAD, k);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   529
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   530
    JavaValue result(T_VOID);
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   531
    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
   532
}
d06edd28ba62 7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents: 11598
diff changeset
   533