jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java
author ctornqvi
Wed, 18 Feb 2015 19:28:08 -0800
changeset 29105 3927f8f0bf4b
parent 25859 3317bb8137f4
child 36511 9d0388c6b336
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21673
diff changeset
     2
 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.jstack;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.attach.VirtualMachine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.attach.AttachNotSupportedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.tools.attach.HotSpotVirtualMachine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class is the main class for the JStack utility. It parses its arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * and decides if the command should be executed by the SA JStack tool or by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * obtained the thread dump from a target process using the VM attach mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public class JStack {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        if (args.length == 0) {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    45
            usage(1); // no arguments
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        boolean useSA = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        boolean mixed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        boolean locks = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        // Parse the options (arguments starting with "-" )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        int optionCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        while (optionCount < args.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            String arg = args[optionCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            if (!arg.startsWith("-")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            }
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    59
            if (arg.equals("-help") || arg.equals("-h")) {
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    60
                usage(0);
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    61
            }
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    62
            else if (arg.equals("-F")) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                useSA = true;
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    64
            }
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    65
            else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                if (arg.equals("-m")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                    mixed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                    if (arg.equals("-l")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                       locks = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                    } else {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    72
                        usage(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            optionCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        // mixed stack implies SA tool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if (mixed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            useSA = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        // Next we check the parameter count. If there are two parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        // we assume core file and executable so we use SA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        int paramCount = args.length - optionCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (paramCount == 0 || paramCount > 2) {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
    88
            usage(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        if (paramCount == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            useSA = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            // If we can't parse it as a pid then it must be debug server
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (!args[optionCount].matches("[0-9]+")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                useSA = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // now execute using the SA JStack tool or the built-in thread dumper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (useSA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            // parameters (<pid> or <exe> <core>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            String params[] = new String[paramCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            for (int i=optionCount; i<args.length; i++ ){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                params[i-optionCount] = args[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            runJStackTool(mixed, locks, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            // pass -l to thread dump operation to get extra lock info
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            String pid = args[optionCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            String params[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            if (locks) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                params = new String[] { "-l" };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                params = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            runThreadDump(pid, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // SA JStack tool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private static void runJStackTool(boolean mixed, boolean locks, String args[]) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        Class<?> cl = loadSAClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (cl == null) {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   125
            usage(1);            // SA not available
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        // JStack tool also takes -m and -l arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (mixed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            args = prepend("-m", args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (locks) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            args = prepend("-l", args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
24871
224e298c3978 8044865: Fix raw and unchecked lint warnings in management-related code
sjiang
parents: 23010
diff changeset
   136
        Class<?>[] argTypes = { String[].class };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        Method m = cl.getDeclaredMethod("main", argTypes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        Object[] invokeArgs = { args };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        m.invoke(null, invokeArgs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    // Returns sun.jvm.hotspot.tools.JStack if available, otherwise null.
11125
99b115114fa3 7117357: Warnings in sun.instrument, tools and other sun.* classes
alanb
parents: 5506
diff changeset
   144
    private static Class<?> loadSAClass() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // Attempt to load JStack class - we specify the system class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // loader so as to cater for development environments where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        // this class is on the boot class path but sa-jdi.jar is on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        // the system class path. Once the JDK is deployed then both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        // tools.jar and sa-jdi.jar are on the system class path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            return Class.forName("sun.jvm.hotspot.tools.JStack", true,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                 ClassLoader.getSystemClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        } catch (Exception x)  { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    // Attach to pid and perform a thread dump
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private static void runThreadDump(String pid, String args[]) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        VirtualMachine vm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            vm = VirtualMachine.attach(pid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        } catch (Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            String msg = x.getMessage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            if (msg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                System.err.println(pid + ": " + msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                x.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            if ((x instanceof AttachNotSupportedException) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                (loadSAClass() != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                System.err.println("The -F option can be used when the target " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    "process is not responding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // Cast to HotSpotVirtualMachine as this is implementation specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        InputStream in = ((HotSpotVirtualMachine)vm).remoteDataDump((Object[])args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // read to EOF and just print output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        byte b[] = new byte[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        int n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            n = in.read(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if (n > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                String s = new String(b, 0, n, "UTF-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                System.out.print(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        } while (n > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        vm.detach();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    // return a new string array with arg as the first element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    private static String[] prepend(String arg, String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        String[] newargs = new String[args.length+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        newargs[0] = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        System.arraycopy(args, 0, newargs, 1, args.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return newargs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    // print usage message
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   206
    private static void usage(int exit) {
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   207
        System.err.println("Usage:");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   208
        System.err.println("    jstack [-l] <pid>");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   209
        System.err.println("        (to connect to running process)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (loadSAClass() != null) {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   212
            System.err.println("    jstack -F [-m] [-l] <pid>");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   213
            System.err.println("        (to connect to a hung process)");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   214
            System.err.println("    jstack [-m] [-l] <executable> <core>");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   215
            System.err.println("        (to connect to a core file)");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   216
            System.err.println("    jstack [-m] [-l] [server_id@]<remote server IP or hostname>");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   217
            System.err.println("        (to connect to a remote debug server)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   220
        System.err.println("");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   221
        System.err.println("Options:");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (loadSAClass() != null) {
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   224
            System.err.println("    -F  to force a thread dump. Use when jstack <pid> does not respond" +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                " (process is hung)");
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   226
            System.err.println("    -m  to print both java and native frames (mixed mode)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
21673
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   229
        System.err.println("    -l  long listing. Prints additional information about locks");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   230
        System.err.println("    -h or -help to print this help message");
c5d341bc60dd 8027765: Make exit codes and stdout/stderr printing from jmap/jinfo/jstack/jps consistent
sla
parents: 14342
diff changeset
   231
        System.exit(exit);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
}