2362N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class is the main class for the JStack utility. It parses its arguments 0N/A * and decides if the command should be executed by the SA JStack tool or by 0N/A * obtained the thread dump from a target process using the VM attach mechanism 0N/A // Parse the options (arguments starting with "-" ) 0N/A // mixed stack implies SA tool 0N/A // Next we check the parameter count. If there are two parameters 0N/A // we assume core file and executable so we use SA. 0N/A // If we can't parse it as a pid then it must be debug server 0N/A // now execute using the SA JStack tool or the built-in thread dumper 0N/A // parameters (<pid> or <exe> <core> 0N/A // pass -l to thread dump operation to get extra lock info 0N/A // JStack tool also takes -m and -l arguments 0N/A // Returns sun.jvm.hotspot.tools.JStack if available, otherwise null. 0N/A // Attempt to load JStack class - we specify the system class 0N/A // loader so as to cater for development environments where 0N/A // this class is on the boot class path but sa-jdi.jar is on 0N/A // the system class path. Once the JDK is deployed then both 0N/A // tools.jar and sa-jdi.jar are on the system class path. 0N/A // Attach to pid and perform a thread dump 0N/A "process is not responding");
0N/A // Cast to HotSpotVirtualMachine as this is implementation specific 0N/A // read to EOF and just print output 0N/A byte b[] =
new byte[
256];
0N/A // return a new string array with arg as the first element 0N/A // print usage message 0N/A " (process is hung)");