Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java @ 17467:55fb97c4c58d hs25-b65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
Summary: Copyright year updated for files modified during 2013
Reviewed-by: twisti, iveresov
author | mikael |
---|---|
date | Tue, 24 Dec 2013 11:48:39 -0800 |
parents | b03f33670080 |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
0 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
13387
diff
changeset
|
2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.tools; | |
26 | |
11054
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
27 import sun.jvm.hotspot.debugger.JVMDebugger; |
13387
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
28 import sun.jvm.hotspot.runtime.Arguments; |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
29 import sun.jvm.hotspot.runtime.VM; |
0 | 30 |
31 public class JInfo extends Tool { | |
11054
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
32 public JInfo() { |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
33 super(); |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
34 } |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
35 |
0 | 36 public JInfo(int m) { |
37 mode = m; | |
38 } | |
39 | |
11054
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
40 public JInfo(JVMDebugger d) { |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
41 super(d); |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
42 } |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
1552
diff
changeset
|
43 |
0 | 44 protected boolean needsJavaPrefix() { |
45 return false; | |
46 } | |
47 | |
48 public String getName() { | |
49 return "jinfo"; | |
50 } | |
51 | |
52 protected void printFlagsUsage() { | |
53 System.out.println(" -flags\tto print VM flags"); | |
54 System.out.println(" -sysprops\tto print Java System properties"); | |
55 System.out.println(" <no option>\tto print both of the above"); | |
56 super.printFlagsUsage(); | |
57 } | |
58 | |
59 public static final int MODE_FLAGS = 0; | |
60 public static final int MODE_SYSPROPS = 1; | |
61 public static final int MODE_BOTH = 2; | |
62 | |
63 public void run() { | |
64 Tool tool = null; | |
65 switch (mode) { | |
66 case MODE_FLAGS: | |
67 printVMFlags(); | |
68 return; | |
69 case MODE_SYSPROPS: | |
70 tool = new SysPropsDumper(); | |
71 break; | |
72 case MODE_BOTH: { | |
73 tool = new Tool() { | |
74 public void run() { | |
75 Tool sysProps = new SysPropsDumper(); | |
76 sysProps.setAgent(getAgent()); | |
77 System.out.println("Java System Properties:"); | |
78 System.out.println(); | |
79 sysProps.run(); | |
80 System.out.println(); | |
81 System.out.println("VM Flags:"); | |
82 printVMFlags(); | |
83 System.out.println(); | |
84 } | |
85 }; | |
86 } | |
87 break; | |
88 | |
89 default: | |
90 usage(); | |
91 break; | |
92 } | |
93 tool.setAgent(getAgent()); | |
94 tool.run(); | |
95 } | |
96 | |
97 public static void main(String[] args) { | |
98 int mode = -1; | |
99 switch (args.length) { | |
100 case 1: | |
101 if (args[0].charAt(0) == '-') { | |
102 // -h or -help or some invalid flag | |
103 new JInfo(mode).usage(); | |
104 } else { | |
105 mode = MODE_BOTH; | |
106 } | |
107 break; | |
108 case 2: | |
109 case 3: { | |
110 String modeFlag = args[0]; | |
111 if (modeFlag.equals("-flags")) { | |
112 mode = MODE_FLAGS; | |
113 } else if (modeFlag.equals("-sysprops")) { | |
114 mode = MODE_SYSPROPS; | |
115 } else if (modeFlag.charAt(0) == '-') { | |
116 // -h or -help or some invalid flag | |
117 new JInfo(mode).usage(); | |
118 } else { | |
119 mode = MODE_BOTH; | |
120 } | |
121 | |
122 if (mode != MODE_BOTH) { | |
123 // we have to consume first flag argument. | |
124 String[] newArgs = new String[args.length - 1]; | |
125 for (int i = 0; i < newArgs.length; i++) { | |
126 newArgs[i] = args[i + 1]; | |
127 } | |
128 args = newArgs; | |
129 } | |
130 break; | |
131 } | |
132 | |
133 default: | |
134 new JInfo(mode).usage(); | |
135 } | |
136 | |
137 JInfo jinfo = new JInfo(mode); | |
12932
7fe6ef09d242
8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents:
11054
diff
changeset
|
138 jinfo.execute(args); |
0 | 139 } |
140 | |
141 private void printVMFlags() { | |
13387
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
142 VM.Flag[] flags = VM.getVM().getCommandLineFlags(); |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
143 System.out.print("Non-default VM flags: "); |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
144 for (VM.Flag flag : flags) { |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
145 if (flag.getOrigin() == 0) { |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
146 // only print flags which aren't their defaults |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
147 continue; |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
148 } |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
149 if (flag.isBool()) { |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
150 String onoff = flag.getBool() ? "+" : "-"; |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
151 System.out.print("-XX:" + onoff + flag.getName() + " "); |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
152 } else { |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
153 System.out.print("-XX:" + flag.getName() + "=" |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
154 + flag.getValue() + " "); |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
155 } |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
156 } |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
157 System.out.println(); |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
158 |
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
159 System.out.print("Command line: "); |
0 | 160 String str = Arguments.getJVMFlags(); |
161 if (str != null) { | |
13387
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
162 System.out.print(str + " "); |
0 | 163 } |
164 str = Arguments.getJVMArgs(); | |
165 if (str != null) { | |
13387
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
166 System.out.print(str); |
0 | 167 } |
13387
b03f33670080
6606002: jinfo doesn't detect dynamic vm flags changing
sla
parents:
12932
diff
changeset
|
168 System.out.println(); |
0 | 169 } |
170 | |
171 private int mode; | |
172 } |