Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java
41161 views
1
/*
2
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
package sun.jvm.hotspot.tools;
26
27
import sun.jvm.hotspot.debugger.JVMDebugger;
28
29
public class JStack extends Tool {
30
public JStack(boolean mixedMode, boolean concurrentLocks) {
31
this.mixedMode = mixedMode;
32
this.concurrentLocks = concurrentLocks;
33
}
34
35
public JStack() {
36
this(true, true);
37
}
38
39
public JStack(JVMDebugger d) {
40
super(d);
41
}
42
43
protected boolean needsJavaPrefix() {
44
return false;
45
}
46
47
@Override
48
public String getName() {
49
return "jstack";
50
}
51
52
protected void printFlagsUsage() {
53
System.out.println(" -l\tto print java.util.concurrent locks");
54
System.out.println(" -m\tto print both java and native frames (mixed mode)");
55
super.printFlagsUsage();
56
}
57
58
public void run() {
59
Tool tool = null;
60
if (mixedMode) {
61
tool = new PStack(false, concurrentLocks);
62
} else {
63
tool = new StackTrace(false, concurrentLocks);
64
}
65
tool.setAgent(getAgent());
66
tool.setDebugeeType(getDebugeeType());
67
tool.run();
68
}
69
70
public void runWithArgs(String... args) {
71
int used = 0;
72
for (int i = 0; i < args.length; i++) {
73
if (args[i].equals("-m")) {
74
mixedMode = true;
75
used++;
76
} else if (args[i].equals("-l")) {
77
concurrentLocks = true;
78
used++;
79
}
80
}
81
82
if (used != 0) {
83
String[] newArgs = new String[args.length - used];
84
for (int i = 0; i < newArgs.length; i++) {
85
newArgs[i] = args[i + used];
86
}
87
args = newArgs;
88
}
89
90
execute(args);
91
}
92
93
public static void main(String[] args) {
94
JStack jstack = new JStack();
95
jstack.runWithArgs(args);
96
}
97
98
private boolean mixedMode;
99
private boolean concurrentLocks;
100
}
101
102