annotate agent/src/share/classes/sun/jvm/hotspot/HSDB.java @ 17716:cdb71841f4bc

6498581: ThreadInterruptTest3 produces wrong output on Windows Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set. Reviewed-by: acorn, kvn Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author minqi
date Wed, 26 Feb 2014 15:20:41 -0800
parents 55fb97c4c58d
children 4ca6dc0799b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17467
55fb97c4c58d 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 11054
diff changeset
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1385
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1385
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: 1385
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.awt.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.awt.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import java.math.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import javax.swing.tree.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.compiler.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.gc_interface.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 import sun.jvm.hotspot.ui.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 import sun.jvm.hotspot.ui.tree.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 import sun.jvm.hotspot.ui.classbrowser.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 /** The top-level HotSpot Debugger. FIXME: make this an embeddable
a61af66fc99e Initial load
duke
parents:
diff changeset
50 component! (Among other things, figure out what to do with the
a61af66fc99e Initial load
duke
parents:
diff changeset
51 menu bar...) */
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 new HSDB(args).run();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private HotSpotAgent agent;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
62 private JVMDebugger jvmDebugger;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private JDesktopPane desktop;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private boolean attached;
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
65 private boolean argError;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
66 private JFrame frame;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
67 /** List <JMenuItem> */
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private java.util.List attachMenuItems;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /** List <JMenuItem> */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private java.util.List detachMenuItems;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private JMenu toolsMenu;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 private JMenuItem showDbgConsoleMenuItem;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private JMenuItem computeRevPtrsMenuItem;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 private JInternalFrame attachWaitDialog;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private JInternalFrame threadsFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private JInternalFrame consoleFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private WorkerThread workerThread;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // These had to be made data members because they are referenced in inner classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private String pidText;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private int pid;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private String execPath;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 private String coreFilename;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private void doUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 System.out.println("Usage: java HSDB [[pid] | [path-to-java-executable [path-to-corefile]] | help ]");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 System.out.println(" pid: attach to the process whose id is 'pid'");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 System.out.println(" path-to-java-executable: Debug a core file produced by this program");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 System.out.println(" path-to-corefile: Debug this corefile. The default is 'core'");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 System.out.println(" If no arguments are specified, you can select what to do from the GUI.\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 HotSpotAgent.showUsage();
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
91 argError = true;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
92 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
93
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
94 public HSDB(JVMDebugger d) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
95 jvmDebugger = d;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 private HSDB(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 switch (args.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 case (0):
a61af66fc99e Initial load
duke
parents:
diff changeset
101 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 case (1):
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (args[0].equals("help") || args[0].equals("-help")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 doUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // If all numbers, it is a PID to attach to
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Else, it is a pathname to a .../bin/java for a core file.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 int unused = Integer.parseInt(args[0]);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // If we get here, we have a PID and not a core file name
a61af66fc99e Initial load
duke
parents:
diff changeset
112 pidText = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
113 } catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 execPath = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
115 coreFilename = "core";
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 case (2):
a61af66fc99e Initial load
duke
parents:
diff changeset
120 execPath = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
121 coreFilename = args[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
122 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 System.out.println("HSDB Error: Too many options specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 doUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
130 // close this tool without calling System.exit
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
131 protected void closeUI() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
132 workerThread.shutdown();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
133 frame.dispose();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
134 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
135
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
136 public void run() {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
137 // Don't start the UI if there were bad arguments.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
138 if (argError) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
139 return;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
140 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 agent = new HotSpotAgent();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 workerThread = new WorkerThread();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 attachMenuItems = new java.util.ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 detachMenuItems = new java.util.ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
146
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
147 frame = new JFrame("HSDB - HotSpot Debugger");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 frame.setSize(800, 600);
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
149 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 JMenuBar menuBar = new JMenuBar();
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 //
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // File menu
a61af66fc99e Initial load
duke
parents:
diff changeset
155 //
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 JMenu menu = new JMenu("File");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 menu.setMnemonic(KeyEvent.VK_F);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 JMenuItem item;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 item = createMenuItem("Attach to HotSpot process...",
a61af66fc99e Initial load
duke
parents:
diff changeset
161 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 showAttachDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 });
a61af66fc99e Initial load
duke
parents:
diff changeset
166 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
167 item.setMnemonic(KeyEvent.VK_A);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 menu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 attachMenuItems.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 item = createMenuItem("Open HotSpot core file...",
a61af66fc99e Initial load
duke
parents:
diff changeset
172 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 showOpenCoreFileDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 });
a61af66fc99e Initial load
duke
parents:
diff changeset
177 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
178 item.setMnemonic(KeyEvent.VK_O);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 menu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 attachMenuItems.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 item = createMenuItem("Connect to debug server...",
a61af66fc99e Initial load
duke
parents:
diff changeset
183 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 showConnectDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 });
a61af66fc99e Initial load
duke
parents:
diff changeset
188 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
189 item.setMnemonic(KeyEvent.VK_S);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 menu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 attachMenuItems.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 item = createMenuItem("Detach",
a61af66fc99e Initial load
duke
parents:
diff changeset
194 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 });
a61af66fc99e Initial load
duke
parents:
diff changeset
199 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
200 item.setMnemonic(KeyEvent.VK_S);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 menu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 detachMenuItems.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Disable detach menu items at first
a61af66fc99e Initial load
duke
parents:
diff changeset
205 setMenuItemsEnabled(detachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 menu.addSeparator();
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 item = createMenuItem("Exit",
a61af66fc99e Initial load
duke
parents:
diff changeset
210 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 public void actionPerformed(ActionEvent e) {
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
212 closeUI();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 });
a61af66fc99e Initial load
duke
parents:
diff changeset
215 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
216 item.setMnemonic(KeyEvent.VK_X);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 menu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 menuBar.add(menu);
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 //
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // Tools menu
a61af66fc99e Initial load
duke
parents:
diff changeset
222 //
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 toolsMenu = new JMenu("Tools");
a61af66fc99e Initial load
duke
parents:
diff changeset
225 toolsMenu.setMnemonic(KeyEvent.VK_T);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 item = createMenuItem("Class Browser",
a61af66fc99e Initial load
duke
parents:
diff changeset
228 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 showClassBrowser();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 });
a61af66fc99e Initial load
duke
parents:
diff changeset
233 item.setMnemonic(KeyEvent.VK_B);
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 item = createMenuItem("Code Viewer",
a61af66fc99e Initial load
duke
parents:
diff changeset
238 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 showCodeViewer();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 });
a61af66fc99e Initial load
duke
parents:
diff changeset
243 item.setMnemonic(KeyEvent.VK_C);
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 item = createMenuItem("Compute Reverse Ptrs",
a61af66fc99e Initial load
duke
parents:
diff changeset
249 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 fireComputeReversePtrs();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 });
a61af66fc99e Initial load
duke
parents:
diff changeset
254 computeRevPtrsMenuItem = item;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 item.setMnemonic(KeyEvent.VK_M);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 item = createMenuItem("Deadlock Detection",
a61af66fc99e Initial load
duke
parents:
diff changeset
259 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 showDeadlockDetectionPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 });
a61af66fc99e Initial load
duke
parents:
diff changeset
264 item.setMnemonic(KeyEvent.VK_D);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 item = createMenuItem("Find Object by Query",
a61af66fc99e Initial load
duke
parents:
diff changeset
268 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 showFindByQueryPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 });
a61af66fc99e Initial load
duke
parents:
diff changeset
273 item.setMnemonic(KeyEvent.VK_Q);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 item = createMenuItem("Find Pointer",
a61af66fc99e Initial load
duke
parents:
diff changeset
278 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 showFindPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 });
a61af66fc99e Initial load
duke
parents:
diff changeset
283 item.setMnemonic(KeyEvent.VK_P);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 item = createMenuItem("Find Value In Heap",
a61af66fc99e Initial load
duke
parents:
diff changeset
287 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 showFindInHeapPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 });
a61af66fc99e Initial load
duke
parents:
diff changeset
292 item.setMnemonic(KeyEvent.VK_V);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 item = createMenuItem("Find Value In Code Cache",
a61af66fc99e Initial load
duke
parents:
diff changeset
296 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 showFindInCodeCachePanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 });
a61af66fc99e Initial load
duke
parents:
diff changeset
301 item.setMnemonic(KeyEvent.VK_A);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 item = createMenuItem("Heap Parameters",
a61af66fc99e Initial load
duke
parents:
diff changeset
305 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 showHeapParametersPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309 });
a61af66fc99e Initial load
duke
parents:
diff changeset
310 item.setMnemonic(KeyEvent.VK_H);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 item = createMenuItem("Inspector",
a61af66fc99e Initial load
duke
parents:
diff changeset
314 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 showInspector(null);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 });
a61af66fc99e Initial load
duke
parents:
diff changeset
319 item.setMnemonic(KeyEvent.VK_R);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
321 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 item = createMenuItem("Memory Viewer",
a61af66fc99e Initial load
duke
parents:
diff changeset
324 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 showMemoryViewer();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 });
a61af66fc99e Initial load
duke
parents:
diff changeset
329 item.setMnemonic(KeyEvent.VK_M);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 item = createMenuItem("Monitor Cache Dump",
a61af66fc99e Initial load
duke
parents:
diff changeset
333 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 showMonitorCacheDumpPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
337 });
a61af66fc99e Initial load
duke
parents:
diff changeset
338 item.setMnemonic(KeyEvent.VK_D);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 item = createMenuItem("Object Histogram",
a61af66fc99e Initial load
duke
parents:
diff changeset
342 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 showObjectHistogram();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 });
a61af66fc99e Initial load
duke
parents:
diff changeset
347 item.setMnemonic(KeyEvent.VK_O);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 item = createMenuItem("Show System Properties",
a61af66fc99e Initial load
duke
parents:
diff changeset
351 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 showSystemProperties();
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355 });
a61af66fc99e Initial load
duke
parents:
diff changeset
356 item.setMnemonic(KeyEvent.VK_S);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 item = createMenuItem("Show VM Version",
a61af66fc99e Initial load
duke
parents:
diff changeset
360 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
362 showVMVersion();
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 });
a61af66fc99e Initial load
duke
parents:
diff changeset
365 item.setMnemonic(KeyEvent.VK_M);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 item = createMenuItem("Show -XX flags",
a61af66fc99e Initial load
duke
parents:
diff changeset
369 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 showCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 });
a61af66fc99e Initial load
duke
parents:
diff changeset
374 item.setMnemonic(KeyEvent.VK_X);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 toolsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 toolsMenu.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 menuBar.add(toolsMenu);
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 //
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // Windows menu
a61af66fc99e Initial load
duke
parents:
diff changeset
382 //
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 JMenu windowsMenu = new JMenu("Windows");
a61af66fc99e Initial load
duke
parents:
diff changeset
385 windowsMenu.setMnemonic(KeyEvent.VK_W);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 item = createMenuItem("Console",
a61af66fc99e Initial load
duke
parents:
diff changeset
387 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 showConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391 });
a61af66fc99e Initial load
duke
parents:
diff changeset
392 item.setMnemonic(KeyEvent.VK_C);
a61af66fc99e Initial load
duke
parents:
diff changeset
393 windowsMenu.add(item);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 showDbgConsoleMenuItem = createMenuItem("Debugger Console",
a61af66fc99e Initial load
duke
parents:
diff changeset
395 new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 showDebuggerConsole();
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399 });
a61af66fc99e Initial load
duke
parents:
diff changeset
400 showDbgConsoleMenuItem.setMnemonic(KeyEvent.VK_D);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 windowsMenu.add(showDbgConsoleMenuItem);
a61af66fc99e Initial load
duke
parents:
diff changeset
402 showDbgConsoleMenuItem.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 menuBar.add(windowsMenu);
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 frame.setJMenuBar(menuBar);
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 desktop = new JDesktopPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
410 frame.getContentPane().add(desktop);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 GraphicsUtilities.reshapeToAspectRatio(frame, 4.0f/3.0f, 0.75f, Toolkit.getDefaultToolkit().getScreenSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
412 GraphicsUtilities.centerInContainer(frame, Toolkit.getDefaultToolkit().getScreenSize());
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
413 frame.setVisible(true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 Runtime.getRuntime().addShutdownHook(new java.lang.Thread() {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 detachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419 });
a61af66fc99e Initial load
duke
parents:
diff changeset
420
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
421 // If jvmDebugger is already set, we have been given a JVMDebugger.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
422 // Otherwise, if pidText != null we are supposed to attach to it.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
423 // Finally, if execPath != null, it is the path of a jdk/bin/java
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
424 // and coreFilename is the pathname of a core file we are
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
425 // supposed to attach to.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
426
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
427 if (jvmDebugger != null) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
428 attach(jvmDebugger);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
429 } else if (pidText != null) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
430 attach(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 } else if (execPath != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
432 attach(execPath, coreFilename);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // FIXME: merge showAttachDialog, showOpenCoreFileDialog, showConnectDialog
a61af66fc99e Initial load
duke
parents:
diff changeset
437 private void showAttachDialog() {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // FIXME: create filtered text field which only accepts numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
439 setMenuItemsEnabled(attachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 final JInternalFrame attachDialog = new JInternalFrame("Attach to HotSpot process");
a61af66fc99e Initial load
duke
parents:
diff changeset
441 attachDialog.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443 JPanel panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
445 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
446 attachDialog.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 panel.add(new JLabel("Enter process ID:"));
a61af66fc99e Initial load
duke
parents:
diff changeset
449 final JTextField pidTextField = new JTextField(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 ActionListener attacher = new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 attachDialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 desktop.remove(attachDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 workerThread.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
456 attach(pidTextField.getText());
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458 });
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 };
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 pidTextField.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 panel.add(pidTextField);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 attachDialog.getContentPane().add(panel, BorderLayout.NORTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 Box vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
468 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
469 panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
470 JTextArea ta = new JTextArea(
a61af66fc99e Initial load
duke
parents:
diff changeset
471 "Enter the process ID of a currently-running HotSpot process. On " +
a61af66fc99e Initial load
duke
parents:
diff changeset
472 "Solaris and most Unix operating systems, this can be determined by " +
a61af66fc99e Initial load
duke
parents:
diff changeset
473 "typing \"ps -u <your username> | grep java\"; the process ID is the " +
a61af66fc99e Initial load
duke
parents:
diff changeset
474 "first number which appears on the resulting line. On Windows, the " +
a61af66fc99e Initial load
duke
parents:
diff changeset
475 "process ID is present in the Task Manager, which can be brought up " +
a61af66fc99e Initial load
duke
parents:
diff changeset
476 "while logged on to the desktop by pressing Ctrl-Alt-Delete.");
a61af66fc99e Initial load
duke
parents:
diff changeset
477 ta.setLineWrap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
478 ta.setWrapStyleWord(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 ta.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
480 ta.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
481 panel.add(ta);
a61af66fc99e Initial load
duke
parents:
diff changeset
482 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 Box hbox = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
486 JButton button = new JButton("OK");
a61af66fc99e Initial load
duke
parents:
diff changeset
487 button.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
489 hbox.add(Box.createHorizontalStrut(20));
a61af66fc99e Initial load
duke
parents:
diff changeset
490 button = new JButton("Cancel");
a61af66fc99e Initial load
duke
parents:
diff changeset
491 button.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
492 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 attachDialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
494 desktop.remove(attachDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
495 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497 });
a61af66fc99e Initial load
duke
parents:
diff changeset
498 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
499 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
500 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
501 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
502 panel.add(hbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
503 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 attachDialog.getContentPane().add(vbox, BorderLayout.SOUTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 desktop.add(attachDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 attachDialog.setSize(400, 300);
a61af66fc99e Initial load
duke
parents:
diff changeset
509 GraphicsUtilities.centerInContainer(attachDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 attachDialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 pidTextField.requestFocus();
a61af66fc99e Initial load
duke
parents:
diff changeset
512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // FIXME: merge showAttachDialog, showOpenCoreFileDialog, showConnectDialog
a61af66fc99e Initial load
duke
parents:
diff changeset
515 private void showOpenCoreFileDialog() {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 setMenuItemsEnabled(attachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
517 final JInternalFrame dialog = new JInternalFrame("Open Core File");
a61af66fc99e Initial load
duke
parents:
diff changeset
518 dialog.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 JPanel panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
521 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
522 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
523 dialog.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 Box hbox = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
526 Box vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
527 vbox.add(new JLabel("Path to core file:"));
a61af66fc99e Initial load
duke
parents:
diff changeset
528 vbox.add(new JLabel("Path to Java executable:"));
a61af66fc99e Initial load
duke
parents:
diff changeset
529 hbox.add(vbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
532 final JTextField corePathField = new JTextField(40);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 final JTextField execPathField = new JTextField(40);
a61af66fc99e Initial load
duke
parents:
diff changeset
534 vbox.add(corePathField);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 vbox.add(execPathField);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 hbox.add(vbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 final JButton browseCorePath = new JButton("Browse ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
539 final JButton browseExecPath = new JButton("Browse ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
540 browseCorePath.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
541 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 JFileChooser fileChooser = new JFileChooser(new File("."));
a61af66fc99e Initial load
duke
parents:
diff changeset
543 int retVal = fileChooser.showOpenDialog(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
544 if (retVal == JFileChooser.APPROVE_OPTION) {
a61af66fc99e Initial load
duke
parents:
diff changeset
545 corePathField.setText(fileChooser.getSelectedFile().getPath());
a61af66fc99e Initial load
duke
parents:
diff changeset
546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
548 });
a61af66fc99e Initial load
duke
parents:
diff changeset
549 browseExecPath.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 JFileChooser fileChooser = new JFileChooser(new File("."));
a61af66fc99e Initial load
duke
parents:
diff changeset
552 int retVal = fileChooser.showOpenDialog(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
553 if (retVal == JFileChooser.APPROVE_OPTION) {
a61af66fc99e Initial load
duke
parents:
diff changeset
554 execPathField.setText(fileChooser.getSelectedFile().getPath());
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557 });
a61af66fc99e Initial load
duke
parents:
diff changeset
558 vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
559 vbox.add(browseCorePath);
a61af66fc99e Initial load
duke
parents:
diff changeset
560 vbox.add(browseExecPath);
a61af66fc99e Initial load
duke
parents:
diff changeset
561 hbox.add(vbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 panel.add(hbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
564 dialog.getContentPane().add(panel, BorderLayout.NORTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 ActionListener attacher = new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
568 dialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 desktop.remove(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
570 workerThread.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
571 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 attach(execPathField.getText(), corePathField.getText());
a61af66fc99e Initial load
duke
parents:
diff changeset
573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
574 });
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 };
a61af66fc99e Initial load
duke
parents:
diff changeset
577 corePathField.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
578 execPathField.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580 vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
581 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
582 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
583 panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
584 JTextArea ta = new JTextArea(
a61af66fc99e Initial load
duke
parents:
diff changeset
585 "Enter the full path names to the core file from a HotSpot process " +
a61af66fc99e Initial load
duke
parents:
diff changeset
586 "and the Java executable from which it came. The latter is typically " +
a61af66fc99e Initial load
duke
parents:
diff changeset
587 "located in the JDK/JRE directory under the directory " +
a61af66fc99e Initial load
duke
parents:
diff changeset
588 "jre/bin/<arch>/native_threads.");
a61af66fc99e Initial load
duke
parents:
diff changeset
589 ta.setLineWrap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
590 ta.setWrapStyleWord(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
591 ta.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
592 ta.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
593 panel.add(ta);
a61af66fc99e Initial load
duke
parents:
diff changeset
594 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 hbox = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
597 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
598 JButton button = new JButton("OK");
a61af66fc99e Initial load
duke
parents:
diff changeset
599 button.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
600 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
601 hbox.add(Box.createHorizontalStrut(20));
a61af66fc99e Initial load
duke
parents:
diff changeset
602 button = new JButton("Cancel");
a61af66fc99e Initial load
duke
parents:
diff changeset
603 button.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
604 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 dialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
606 desktop.remove(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
607 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609 });
a61af66fc99e Initial load
duke
parents:
diff changeset
610 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
611 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
612 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
613 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
614 panel.add(hbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
615 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
616
a61af66fc99e Initial load
duke
parents:
diff changeset
617 dialog.getContentPane().add(vbox, BorderLayout.SOUTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
618
a61af66fc99e Initial load
duke
parents:
diff changeset
619 desktop.add(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 dialog.setSize(500, 300);
a61af66fc99e Initial load
duke
parents:
diff changeset
621 GraphicsUtilities.centerInContainer(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
622 dialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
623 corePathField.requestFocus();
a61af66fc99e Initial load
duke
parents:
diff changeset
624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 // FIXME: merge showAttachDialog, showOpenCoreFileDialog, showConnectDialog
a61af66fc99e Initial load
duke
parents:
diff changeset
627 private void showConnectDialog() {
a61af66fc99e Initial load
duke
parents:
diff changeset
628 // FIXME: create filtered text field which only accepts numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
629 setMenuItemsEnabled(attachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
630 final JInternalFrame dialog = new JInternalFrame("Connect to HotSpot Debug Server");
a61af66fc99e Initial load
duke
parents:
diff changeset
631 dialog.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633 JPanel panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
634 panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
635 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
636 dialog.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638 panel.add(new JLabel("Enter machine name:"));
a61af66fc99e Initial load
duke
parents:
diff changeset
639 final JTextField pidTextField = new JTextField(40);
a61af66fc99e Initial load
duke
parents:
diff changeset
640 ActionListener attacher = new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
641 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
642 dialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
643 desktop.remove(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
644 workerThread.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
645 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
646 connect(pidTextField.getText());
a61af66fc99e Initial load
duke
parents:
diff changeset
647 }
a61af66fc99e Initial load
duke
parents:
diff changeset
648 });
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650 };
a61af66fc99e Initial load
duke
parents:
diff changeset
651
a61af66fc99e Initial load
duke
parents:
diff changeset
652 pidTextField.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
653 panel.add(pidTextField);
a61af66fc99e Initial load
duke
parents:
diff changeset
654 dialog.getContentPane().add(panel, BorderLayout.NORTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
655
a61af66fc99e Initial load
duke
parents:
diff changeset
656 Box vbox = Box.createVerticalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
657 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
658 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
659 panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
660 JTextArea ta = new JTextArea(
a61af66fc99e Initial load
duke
parents:
diff changeset
661 "Enter the name of a machine on which the HotSpot \"Debug Server\" is " +
a61af66fc99e Initial load
duke
parents:
diff changeset
662 "running and is attached to a process or core file.");
a61af66fc99e Initial load
duke
parents:
diff changeset
663 ta.setLineWrap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 ta.setWrapStyleWord(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
665 ta.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
666 ta.setBackground(panel.getBackground());
a61af66fc99e Initial load
duke
parents:
diff changeset
667 panel.add(ta);
a61af66fc99e Initial load
duke
parents:
diff changeset
668 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
669
a61af66fc99e Initial load
duke
parents:
diff changeset
670 Box hbox = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
671 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
672 JButton button = new JButton("OK");
a61af66fc99e Initial load
duke
parents:
diff changeset
673 button.addActionListener(attacher);
a61af66fc99e Initial load
duke
parents:
diff changeset
674 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
675 hbox.add(Box.createHorizontalStrut(20));
a61af66fc99e Initial load
duke
parents:
diff changeset
676 button = new JButton("Cancel");
a61af66fc99e Initial load
duke
parents:
diff changeset
677 button.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
679 dialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 desktop.remove(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683 });
a61af66fc99e Initial load
duke
parents:
diff changeset
684 hbox.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
685 hbox.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
686 panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
687 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
688 panel.add(hbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 vbox.add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
690
a61af66fc99e Initial load
duke
parents:
diff changeset
691 dialog.getContentPane().add(vbox, BorderLayout.SOUTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
692
a61af66fc99e Initial load
duke
parents:
diff changeset
693 desktop.add(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
694 dialog.setSize(400, 300);
a61af66fc99e Initial load
duke
parents:
diff changeset
695 GraphicsUtilities.centerInContainer(dialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
696 dialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
697 pidTextField.requestFocus();
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699
a61af66fc99e Initial load
duke
parents:
diff changeset
700 public void showThreadOopInspector(JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 showInspector(new OopTreeNodeAdapter(thread.getThreadObj(), null));
a61af66fc99e Initial load
duke
parents:
diff changeset
702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
703
a61af66fc99e Initial load
duke
parents:
diff changeset
704 public void showInspector(SimpleTreeNode adapter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
705 showPanel("Inspector", new Inspector(adapter), 1.0f, 0.65f);
a61af66fc99e Initial load
duke
parents:
diff changeset
706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
707
a61af66fc99e Initial load
duke
parents:
diff changeset
708 public void showLiveness(Oop oop, LivenessPathList liveness) {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
710 PrintStream tty = new PrintStream(bos);
a61af66fc99e Initial load
duke
parents:
diff changeset
711 int numPaths = liveness.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
712 for (int i = 0; i < numPaths; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 tty.println("Path " + (i + 1) + " of " + numPaths + ":");
a61af66fc99e Initial load
duke
parents:
diff changeset
714 liveness.get(i).printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
716 JTextArea ta = new JTextArea(bos.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
717 ta.setLineWrap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
718 ta.setWrapStyleWord(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
719 ta.setEditable(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
720
a61af66fc99e Initial load
duke
parents:
diff changeset
721 JPanel panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
722 panel.setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
723
a61af66fc99e Initial load
duke
parents:
diff changeset
724 JScrollPane scroller = new JScrollPane();
a61af66fc99e Initial load
duke
parents:
diff changeset
725 scroller.getViewport().add(ta);
a61af66fc99e Initial load
duke
parents:
diff changeset
726
a61af66fc99e Initial load
duke
parents:
diff changeset
727 panel.add(scroller, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
728
a61af66fc99e Initial load
duke
parents:
diff changeset
729 bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
730 tty = new PrintStream(bos);
a61af66fc99e Initial load
duke
parents:
diff changeset
731 tty.print("Liveness result for ");
a61af66fc99e Initial load
duke
parents:
diff changeset
732 Oop.printOopValueOn(oop, tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
733
a61af66fc99e Initial load
duke
parents:
diff changeset
734 JInternalFrame frame = new JInternalFrame(bos.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
735 frame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
736 frame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
737 frame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
738 frame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
739 frame.getContentPane().add(panel, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 frame.pack();
a61af66fc99e Initial load
duke
parents:
diff changeset
741 desktop.add(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
742 GraphicsUtilities.reshapeToAspectRatio(frame, 0.5f / 0.2f, 0.5f, frame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
743 frame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 private void fireComputeReversePtrs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
747 // Possible this might have been computed elsewhere
a61af66fc99e Initial load
duke
parents:
diff changeset
748 if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
749 computeRevPtrsMenuItem.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
750 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
751 }
a61af66fc99e Initial load
duke
parents:
diff changeset
752
a61af66fc99e Initial load
duke
parents:
diff changeset
753 workerThread.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
754 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
755 HeapProgress progress = new HeapProgress("Reverse Pointers Analysis");
a61af66fc99e Initial load
duke
parents:
diff changeset
756 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
757 ReversePtrsAnalysis analysis = new ReversePtrsAnalysis();
a61af66fc99e Initial load
duke
parents:
diff changeset
758 analysis.setHeapProgressThunk(progress);
a61af66fc99e Initial load
duke
parents:
diff changeset
759 analysis.run();
a61af66fc99e Initial load
duke
parents:
diff changeset
760 computeRevPtrsMenuItem.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
761 } catch (OutOfMemoryError e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
762 final String errMsg = formatMessage(e.toString(), 80);
a61af66fc99e Initial load
duke
parents:
diff changeset
763 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
764 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
765 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
766 "Error computing reverse pointers:" + errMsg,
a61af66fc99e Initial load
duke
parents:
diff changeset
767 "Error",
a61af66fc99e Initial load
duke
parents:
diff changeset
768 JOptionPane.WARNING_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
770 });
a61af66fc99e Initial load
duke
parents:
diff changeset
771 } finally {
a61af66fc99e Initial load
duke
parents:
diff changeset
772 // make sure the progress bar goes away
a61af66fc99e Initial load
duke
parents:
diff changeset
773 progress.heapIterationComplete();
a61af66fc99e Initial load
duke
parents:
diff changeset
774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
776 });
a61af66fc99e Initial load
duke
parents:
diff changeset
777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
778
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // Simple struct containing signal information
a61af66fc99e Initial load
duke
parents:
diff changeset
780 class SignalInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
781 public int sigNum;
a61af66fc99e Initial load
duke
parents:
diff changeset
782 public String sigName;
a61af66fc99e Initial load
duke
parents:
diff changeset
783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
784
a61af66fc99e Initial load
duke
parents:
diff changeset
785 // Need to have mutable vframe as well as visible memory panel
a61af66fc99e Initial load
duke
parents:
diff changeset
786 abstract class StackWalker implements Runnable {
a61af66fc99e Initial load
duke
parents:
diff changeset
787 protected JavaVFrame vf;
a61af66fc99e Initial load
duke
parents:
diff changeset
788 protected AnnotatedMemoryPanel annoPanel;
a61af66fc99e Initial load
duke
parents:
diff changeset
789
a61af66fc99e Initial load
duke
parents:
diff changeset
790 StackWalker(JavaVFrame vf, AnnotatedMemoryPanel annoPanel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
791 this.vf = vf;
a61af66fc99e Initial load
duke
parents:
diff changeset
792 this.annoPanel = annoPanel;
a61af66fc99e Initial load
duke
parents:
diff changeset
793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
795
a61af66fc99e Initial load
duke
parents:
diff changeset
796 public void showThreadStackMemory(final JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
797 // dumpStack(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
798 JavaVFrame vframe = getLastJavaVFrame(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
799 if (vframe == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
800 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
801 "Thread \"" + thread.getThreadName() +
a61af66fc99e Initial load
duke
parents:
diff changeset
802 "\" has no Java frames on its stack",
a61af66fc99e Initial load
duke
parents:
diff changeset
803 "Show Stack Memory",
a61af66fc99e Initial load
duke
parents:
diff changeset
804 JOptionPane.INFORMATION_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
805 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
806 }
a61af66fc99e Initial load
duke
parents:
diff changeset
807
a61af66fc99e Initial load
duke
parents:
diff changeset
808 JInternalFrame stackFrame = new JInternalFrame("Stack Memory for " + thread.getThreadName());
a61af66fc99e Initial load
duke
parents:
diff changeset
809 stackFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
810 stackFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
811 stackFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
812 stackFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 final long addressSize = agent.getTypeDataBase().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
814 boolean is64Bit = (addressSize == 8);
a61af66fc99e Initial load
duke
parents:
diff changeset
815 // This is somewhat of a hack to guess a thread's stack limits since the
a61af66fc99e Initial load
duke
parents:
diff changeset
816 // JavaThread doesn't support this functionality. However it is nice in that
a61af66fc99e Initial load
duke
parents:
diff changeset
817 // it locks us into the active region of the thread's stack and not its
a61af66fc99e Initial load
duke
parents:
diff changeset
818 // theoretical limits.
a61af66fc99e Initial load
duke
parents:
diff changeset
819 //
a61af66fc99e Initial load
duke
parents:
diff changeset
820 sun.jvm.hotspot.runtime.Frame tmpFrame = thread.getCurrentFrameGuess();
a61af66fc99e Initial load
duke
parents:
diff changeset
821 Address sp = tmpFrame.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
822 Address starting = sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
823 Address maxSP = starting;
a61af66fc99e Initial load
duke
parents:
diff changeset
824 Address minSP = starting;
a61af66fc99e Initial load
duke
parents:
diff changeset
825 RegisterMap tmpMap = thread.newRegisterMap(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
826 while ((tmpFrame != null) && (!tmpFrame.isFirstFrame())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
827 tmpFrame = tmpFrame.sender(tmpMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
828 if (tmpFrame != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
829 sp = tmpFrame.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
830 if (sp != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
831 maxSP = AddressOps.max(maxSP, sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
832 minSP = AddressOps.min(minSP, sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
833 }
a61af66fc99e Initial load
duke
parents:
diff changeset
834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 }
a61af66fc99e Initial load
duke
parents:
diff changeset
837 // It is useful to be able to see say +/- 8K on the current stack range
a61af66fc99e Initial load
duke
parents:
diff changeset
838 AnnotatedMemoryPanel annoMemPanel = new AnnotatedMemoryPanel(agent.getDebugger(), is64Bit, starting,
a61af66fc99e Initial load
duke
parents:
diff changeset
839 minSP.addOffsetTo(-8192),
a61af66fc99e Initial load
duke
parents:
diff changeset
840 maxSP.addOffsetTo( 8192));
a61af66fc99e Initial load
duke
parents:
diff changeset
841
a61af66fc99e Initial load
duke
parents:
diff changeset
842 stackFrame.getContentPane().add(annoMemPanel, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
843 desktop.add(stackFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
844 GraphicsUtilities.reshapeToAspectRatio(stackFrame, 4.0f / 3.0f, 0.85f, stackFrame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
845 stackFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
846
a61af66fc99e Initial load
duke
parents:
diff changeset
847 // Stackmap computation for interpreted frames is expensive; do
a61af66fc99e Initial load
duke
parents:
diff changeset
848 // all stackwalking work in another thread for better GUI
a61af66fc99e Initial load
duke
parents:
diff changeset
849 // responsiveness
a61af66fc99e Initial load
duke
parents:
diff changeset
850 workerThread.invokeLater(new StackWalker(vframe, annoMemPanel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
852 Address startAddr = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
853
a61af66fc99e Initial load
duke
parents:
diff changeset
854 // As this is a debugger, we want to provide potential crash
a61af66fc99e Initial load
duke
parents:
diff changeset
855 // information to the user, i.e., by marking signal handler frames
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // on the stack. Since this system is currently targeted at
a61af66fc99e Initial load
duke
parents:
diff changeset
857 // annotating the Java frames (interpreted or compiled) on the
a61af66fc99e Initial load
duke
parents:
diff changeset
858 // stack and not, for example, "external" frames (note the current
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // absence of a PC-to-symbol lookup mechanism at the Debugger
a61af66fc99e Initial load
duke
parents:
diff changeset
860 // level), we want to mark any Java frames which were interrupted
a61af66fc99e Initial load
duke
parents:
diff changeset
861 // by a signal. We do this by making two passes over the stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
862 // one which finds signal handler frames and puts the parent
a61af66fc99e Initial load
duke
parents:
diff changeset
863 // frames in a table and one which finds Java frames and if they
a61af66fc99e Initial load
duke
parents:
diff changeset
864 // are in the table indicates that they were interrupted by a signal.
a61af66fc99e Initial load
duke
parents:
diff changeset
865
a61af66fc99e Initial load
duke
parents:
diff changeset
866 Map interruptedFrameMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
867 {
a61af66fc99e Initial load
duke
parents:
diff changeset
868 sun.jvm.hotspot.runtime.Frame tmpFrame = thread.getCurrentFrameGuess();
a61af66fc99e Initial load
duke
parents:
diff changeset
869 RegisterMap tmpMap = thread.newRegisterMap(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
870 while ((tmpFrame != null) && (!tmpFrame.isFirstFrame())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
871 if (tmpFrame.isSignalHandlerFrameDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
872 // Add some information to the map that we can extract later
a61af66fc99e Initial load
duke
parents:
diff changeset
873 sun.jvm.hotspot.runtime.Frame interruptedFrame = tmpFrame.sender(tmpMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
874 SignalInfo info = new SignalInfo();
a61af66fc99e Initial load
duke
parents:
diff changeset
875 info.sigNum = tmpFrame.getSignalNumberDbg();
a61af66fc99e Initial load
duke
parents:
diff changeset
876 info.sigName = tmpFrame.getSignalNameDbg();
a61af66fc99e Initial load
duke
parents:
diff changeset
877 interruptedFrameMap.put(interruptedFrame, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
879 tmpFrame = tmpFrame.sender(tmpMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
880 }
a61af66fc99e Initial load
duke
parents:
diff changeset
881 }
a61af66fc99e Initial load
duke
parents:
diff changeset
882
a61af66fc99e Initial load
duke
parents:
diff changeset
883 while (vf != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
884 String anno = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
885 JavaVFrame curVFrame = vf;
a61af66fc99e Initial load
duke
parents:
diff changeset
886 sun.jvm.hotspot.runtime.Frame curFrame = curVFrame.getFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
887 Method interpreterFrameMethod = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
888
a61af66fc99e Initial load
duke
parents:
diff changeset
889 if (curVFrame.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
890 anno = "Interpreted frame";
a61af66fc99e Initial load
duke
parents:
diff changeset
891 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
892 anno = "Compiled frame";
a61af66fc99e Initial load
duke
parents:
diff changeset
893 if (curVFrame.isDeoptimized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
894 anno += " (deoptimized)";
a61af66fc99e Initial load
duke
parents:
diff changeset
895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
897 if (curVFrame.mayBeImpreciseDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
898 anno += "; information may be imprecise";
a61af66fc99e Initial load
duke
parents:
diff changeset
899 }
a61af66fc99e Initial load
duke
parents:
diff changeset
900
a61af66fc99e Initial load
duke
parents:
diff changeset
901 if (curVFrame.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
902 // Find the codelet
a61af66fc99e Initial load
duke
parents:
diff changeset
903 InterpreterCodelet codelet = VM.getVM().getInterpreter().getCodeletContaining(curFrame.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
904 String description = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
905 if (codelet != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
906 description = codelet.getDescription();
a61af66fc99e Initial load
duke
parents:
diff changeset
907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
908 if (description == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
909 anno += "\n(Unknown interpreter codelet)";
a61af66fc99e Initial load
duke
parents:
diff changeset
910 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
911 anno += "\nExecuting in codelet \"" + description + "\" at PC = " + curFrame.getPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
913 } else if (curVFrame.isCompiledFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
914 anno += "\nExecuting at PC = " + curFrame.getPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917 if (startAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
918 startAddr = curFrame.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
919 }
a61af66fc99e Initial load
duke
parents:
diff changeset
920
a61af66fc99e Initial load
duke
parents:
diff changeset
921 // FIXME: some compiled frames with empty oop map sets have been
a61af66fc99e Initial load
duke
parents:
diff changeset
922 // found (for example, Vector's inner Enumeration class, method
a61af66fc99e Initial load
duke
parents:
diff changeset
923 // "hasMoreElements"). Not sure yet why these cases are showing
a61af66fc99e Initial load
duke
parents:
diff changeset
924 // up -- should be possible (though unlikely) for safepoint code
a61af66fc99e Initial load
duke
parents:
diff changeset
925 // to patch the return instruction of these methods and then
a61af66fc99e Initial load
duke
parents:
diff changeset
926 // later attempt to get an oop map for that instruction. For
a61af66fc99e Initial load
duke
parents:
diff changeset
927 // now, we warn if we find such a method.
a61af66fc99e Initial load
duke
parents:
diff changeset
928 boolean shouldSkipOopMaps = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
929 if (curVFrame.isCompiledFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
930 CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
931 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
932 if ((maps == null) || (maps.getSize() == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
933 shouldSkipOopMaps = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
934 }
a61af66fc99e Initial load
duke
parents:
diff changeset
935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
936
a61af66fc99e Initial load
duke
parents:
diff changeset
937 // Add signal information to annotation if necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
938 SignalInfo sigInfo = (SignalInfo) interruptedFrameMap.get(curFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
939 if (sigInfo != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
940 // This frame took a signal and we need to report it.
a61af66fc99e Initial load
duke
parents:
diff changeset
941 anno = (anno + "\n*** INTERRUPTED BY SIGNAL " + Integer.toString(sigInfo.sigNum) +
a61af66fc99e Initial load
duke
parents:
diff changeset
942 " (" + sigInfo.sigName + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
944
a61af66fc99e Initial load
duke
parents:
diff changeset
945 JavaVFrame nextVFrame = curVFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
946 sun.jvm.hotspot.runtime.Frame nextFrame = curFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
947 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
948 curVFrame = nextVFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
949 curFrame = nextFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
950
a61af66fc99e Initial load
duke
parents:
diff changeset
951 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
952 Method method = curVFrame.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
953 if (interpreterFrameMethod == null && curVFrame.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
954 interpreterFrameMethod = method;
a61af66fc99e Initial load
duke
parents:
diff changeset
955 }
a61af66fc99e Initial load
duke
parents:
diff changeset
956 int bci = curVFrame.getBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
957 String lineNumberAnno = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
958 if (method.hasLineNumberTable()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
959 if ((bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
960 (bci >= 0 && bci < method.getCodeSize())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
961 lineNumberAnno = ", line " + method.getLineNumberFromBCI(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
962 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
963 lineNumberAnno = " (INVALID BCI)";
a61af66fc99e Initial load
duke
parents:
diff changeset
964 }
a61af66fc99e Initial load
duke
parents:
diff changeset
965 }
a61af66fc99e Initial load
duke
parents:
diff changeset
966 anno += "\n" + method.getMethodHolder().getName().asString() + "." +
a61af66fc99e Initial load
duke
parents:
diff changeset
967 method.getName().asString() + method.getSignature().asString() +
a61af66fc99e Initial load
duke
parents:
diff changeset
968 "\n@bci " + bci + lineNumberAnno;
a61af66fc99e Initial load
duke
parents:
diff changeset
969 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
970 anno += "\n(ERROR while iterating vframes for frame " + curFrame + ")";
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972
a61af66fc99e Initial load
duke
parents:
diff changeset
973 nextVFrame = curVFrame.javaSender();
a61af66fc99e Initial load
duke
parents:
diff changeset
974 if (nextVFrame != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
975 nextFrame = nextVFrame.getFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
976 }
a61af66fc99e Initial load
duke
parents:
diff changeset
977 } while (nextVFrame != null && nextFrame.equals(curFrame));
a61af66fc99e Initial load
duke
parents:
diff changeset
978
a61af66fc99e Initial load
duke
parents:
diff changeset
979 if (shouldSkipOopMaps) {
a61af66fc99e Initial load
duke
parents:
diff changeset
980 anno = anno + "\nNOTE: null or empty OopMapSet found for this CodeBlob";
a61af66fc99e Initial load
duke
parents:
diff changeset
981 }
a61af66fc99e Initial load
duke
parents:
diff changeset
982
a61af66fc99e Initial load
duke
parents:
diff changeset
983 if (curFrame.getFP() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
984 annoPanel.addAnnotation(new Annotation(curFrame.getSP(),
a61af66fc99e Initial load
duke
parents:
diff changeset
985 curFrame.getFP(),
a61af66fc99e Initial load
duke
parents:
diff changeset
986 anno));
a61af66fc99e Initial load
duke
parents:
diff changeset
987 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 if (VM.getVM().getCPU().equals("x86") || VM.getVM().getCPU().equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
989 // For C2, which has null frame pointers on x86/amd64
a61af66fc99e Initial load
duke
parents:
diff changeset
990 CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
991 Address sp = curFrame.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
992 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
993 Assert.that(cb.getFrameSize() > 0, "CodeBlob must have non-zero frame size");
a61af66fc99e Initial load
duke
parents:
diff changeset
994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
995 annoPanel.addAnnotation(new Annotation(sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
996 sp.addOffsetTo(cb.getFrameSize()),
a61af66fc99e Initial load
duke
parents:
diff changeset
997 anno));
a61af66fc99e Initial load
duke
parents:
diff changeset
998 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
999 Assert.that(VM.getVM().getCPU().equals("ia64"), "only ia64 should reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1002
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 // Add interpreter frame annotations
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 if (curFrame.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameExpressionStack(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 curFrame.addressOfInterpreterFrameTOS(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 "Interpreter expression stack"));
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1008 Address monBegin = curFrame.interpreterFrameMonitorBegin().address();
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1009 Address monEnd = curFrame.interpreterFrameMonitorEnd().address();
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1010 if (!monBegin.equals(monEnd)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1011 annoPanel.addAnnotation(new Annotation(monBegin, monEnd,
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1012 "BasicObjectLocks"));
bc32f286fae0 6945219: minor SA fixes
never
parents: 196
diff changeset
1013 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 if (interpreterFrameMethod != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 // The offset is just to get the right stack slots highlighted in the output
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 int offset = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameLocal(offset),
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset),
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 "Interpreter locals area for frame with SP = " + curFrame.getSP()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3908
diff changeset
1021 String methodAnno = "Interpreter frame Method*";
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 if (interpreterFrameMethod == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 methodAnno += " (BAD OOP)";
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 Address a = curFrame.addressOfInterpreterFrameMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 annoPanel.addAnnotation(new Annotation(a, a.addOffsetTo(addressSize), methodAnno));
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 a = curFrame.addressOfInterpreterFrameCPCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 annoPanel.addAnnotation(new Annotation(a, a.addOffsetTo(addressSize), "Interpreter constant pool cache"));
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1030
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 RegisterMap rm = (RegisterMap) vf.getRegisterMap().clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 if (!shouldSkipOopMaps) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 curFrame.oopsDo(new AddressVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 public void visitAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 Assert.that(addr.andWithMask(VM.getVM().getAddressSize() - 1) == null,
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 "Address " + addr + "should have been aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1040 OopHandle handle = addr.getOopHandleAt(0);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1041 addAnnotation(addr, handle);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1042 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1043
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1044 public void visitCompOopAddress(Address addr) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1045 if (Assert.ASSERTS_ENABLED) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1046 Assert.that(addr.andWithMask(VM.getVM().getAddressSize() - 1) == null,
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1047 "Address " + addr + "should have been aligned");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1048 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1049 OopHandle handle = addr.getCompOopHandleAt(0);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1050 addAnnotation(addr, handle);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1051 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1052
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
1053 public void addAnnotation(Address addr, OopHandle handle) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 // Check contents
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 String anno = "null oop";
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 if (handle != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 // Find location
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 CollectedHeap collHeap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 boolean bad = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 anno = "BAD OOP";
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 if (collHeap instanceof GenCollectedHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 GenCollectedHeap heap = (GenCollectedHeap) collHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 for (int i = 0; i < heap.nGens(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 if (heap.getGen(i).isIn(handle)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 if (i == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 anno = "NewGen ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 } else if (i == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 anno = "OldGen ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 anno = "Gen " + i + " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 bad = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1076
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 } else if (collHeap instanceof ParallelScavengeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 if (heap.youngGen().isIn(handle)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 anno = "PSYoungGen ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 bad = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 } else if (heap.oldGen().isIn(handle)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 anno = "PSOldGen ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 bad = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 // Optimistically assume the oop isn't bad
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 anno = "[Unknown generation] ";
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 bad = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1091
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 if (!bad) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 Oop oop = VM.getVM().getObjectHeap().newOop(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 if (oop instanceof Instance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 // Java-level objects always have workable names
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 anno = anno + oop.getKlass().getName().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 Oop.printOopValueOn(oop, new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 anno = anno + bos.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 catch (AddressException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 anno += "CORRUPT OOP";
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 catch (NullPointerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 anno += "CORRUPT OOP (null pointer)";
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1112
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 annoPanel.addAnnotation(new Annotation(addr, addr.addOffsetTo(addressSize), anno));
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 }, rm);
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 System.err.println("Error while performing oopsDo for frame " + curFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1121
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 vf = nextVFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1124
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 // This used to paint as we walked the frames. This caused the display to be refreshed
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 // enough to be annoying on remote displays. It also would cause the annotations to
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 // be displayed in varying order which caused some annotations to overwrite others
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 // depending on the races between painting and adding annotations. This latter problem
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 // still exists to some degree but moving this code here definitely seems to reduce it
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 annoPanel.makeVisible(startAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 annoPanel.repaint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1135
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1136 // Attach to existing JVMDebugger, which should be already attached to a core/process.
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1137 private void attach(JVMDebugger d) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1138 attached = true;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1139 showThreadsDialog();
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1140 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 6725
diff changeset
1141
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 /** NOTE we are in a different thread here than either the main
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 thread or the Swing/AWT event handler thread, so we must be very
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 careful when creating or removing widgets */
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 private void attach(String pidText) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 this.pidText = pidText;
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 pid = Integer.parseInt(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 "Unable to parse process ID \"" + HSDB.this.pidText + "\".\nPlease enter a number.",
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 "Parse error",
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 JOptionPane.WARNING_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1162
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 // Try to attach to this process
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 Runnable remover = new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 attachWaitDialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 desktop.remove(attachWaitDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 attachWaitDialog = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1171
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 JOptionPane pane = new JOptionPane("Attaching to process " + pid + ", please wait...", JOptionPane.INFORMATION_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 pane.setOptions(new Object[] {});
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 attachWaitDialog = pane.createInternalFrame(desktop, "Attaching to Process");
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 attachWaitDialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 // FIXME: display exec'd debugger's output messages during this
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 // lengthy call
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 agent.attach(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 if (agent.getDebugger().hasConsole()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 showDbgConsoleMenuItem.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 attached = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 catch (DebuggerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 final String errMsg = formatMessage(e.getMessage(), 80);
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 "Unable to connect to process ID " + pid + ":\n\n" + errMsg,
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 "Unable to Connect",
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 JOptionPane.WARNING_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 agent.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 // OK, the VM should be available. Create the Threads dialog.
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 showThreadsDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1210
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 /** NOTE we are in a different thread here than either the main
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 thread or the Swing/AWT event handler thread, so we must be very
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 careful when creating or removing widgets */
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 private void attach(final String executablePath, final String corePath) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 // Try to open this core file
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 Runnable remover = new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 attachWaitDialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 desktop.remove(attachWaitDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 attachWaitDialog = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1223
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 JOptionPane pane = new JOptionPane("Opening core file, please wait...", JOptionPane.INFORMATION_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 pane.setOptions(new Object[] {});
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 attachWaitDialog = pane.createInternalFrame(desktop, "Opening Core File");
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 attachWaitDialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1233
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 // FIXME: display exec'd debugger's output messages during this
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 // lengthy call
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 agent.attach(executablePath, corePath);
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 if (agent.getDebugger().hasConsole()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 showDbgConsoleMenuItem.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 attached = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 catch (DebuggerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 final String errMsg = formatMessage(e.getMessage(), 80);
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 "Unable to open core file\n" + corePath + ":\n\n" + errMsg,
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 "Unable to Open Core File",
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 JOptionPane.WARNING_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 agent.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 // OK, the VM should be available. Create the Threads dialog.
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 showThreadsDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 /** NOTE we are in a different thread here than either the main
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 thread or the Swing/AWT event handler thread, so we must be very
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 careful when creating or removing widgets */
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 private void connect(final String remoteMachineName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 // Try to open this core file
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 Runnable remover = new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 attachWaitDialog.setVisible(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 desktop.remove(attachWaitDialog);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 attachWaitDialog = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 JOptionPane pane = new JOptionPane("Connecting to debug server, please wait...", JOptionPane.INFORMATION_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 pane.setOptions(new Object[] {});
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 attachWaitDialog = pane.createInternalFrame(desktop, "Connecting to Debug Server");
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 attachWaitDialog.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1285
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 agent.attach(remoteMachineName);
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 if (agent.getDebugger().hasConsole()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 showDbgConsoleMenuItem.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 attached = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 catch (DebuggerException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 SwingUtilities.invokeLater(remover);
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 final String errMsg = formatMessage(e.getMessage(), 80);
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 JOptionPane.showInternalMessageDialog(desktop,
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 "Unable to connect to machine \"" + remoteMachineName + "\":\n\n" + errMsg,
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 "Unable to Connect",
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 JOptionPane.WARNING_MESSAGE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 agent.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1308
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 // OK, the VM should be available. Create the Threads dialog.
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 showThreadsDialog();
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1312
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 private void detachDebugger() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 if (!attached) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 agent.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 attached = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1320
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 private void detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 detachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 attachWaitDialog = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 threadsFrame = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 consoleFrame = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 setMenuItemsEnabled(attachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 setMenuItemsEnabled(detachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 toolsMenu.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 showDbgConsoleMenuItem.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 // FIXME: is this sufficient, or will I have to do anything else
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 // to the components to kill them off? What about WorkerThreads?
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 desktop.removeAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 desktop.invalidate();
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 desktop.validate();
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 desktop.repaint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1337
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 /** NOTE that this is called from another thread than the main or
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 Swing thread and we have to be careful about synchronization */
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 private void showThreadsDialog() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 threadsFrame = new JInternalFrame("Java Threads");
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 threadsFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 threadsFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 JavaThreadsPanel threadsPanel = new JavaThreadsPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 threadsPanel.addPanelListener(HSDB.this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 threadsFrame.getContentPane().add(threadsPanel);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 threadsFrame.setSize(500, 300);
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 threadsFrame.pack();
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 desktop.add(threadsFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 GraphicsUtilities.moveToInContainer(threadsFrame, 0.75f, 0.25f, 0, 20);
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 threadsFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 setMenuItemsEnabled(attachMenuItems, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 setMenuItemsEnabled(detachMenuItems, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 toolsMenu.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 computeRevPtrsMenuItem.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1365
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 private void showObjectHistogram() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 sun.jvm.hotspot.oops.ObjectHistogram histo = new sun.jvm.hotspot.oops.ObjectHistogram();
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 ObjectHistogramCleanupThunk cleanup =
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 new ObjectHistogramCleanupThunk(histo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 doHeapIteration("Object Histogram",
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 "Generating histogram...",
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 histo,
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 cleanup);
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1375
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 class ObjectHistogramCleanupThunk implements CleanupThunk {
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 sun.jvm.hotspot.oops.ObjectHistogram histo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 ObjectHistogramCleanupThunk(sun.jvm.hotspot.oops.ObjectHistogram histo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 this.histo = histo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 public void heapIterationComplete() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 JInternalFrame histoFrame = new JInternalFrame("Object Histogram");
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 histoFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 histoFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 histoFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 histoFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 ObjectHistogramPanel panel = new ObjectHistogramPanel(histo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 panel.addPanelListener(HSDB.this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 histoFrame.getContentPane().add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 desktop.add(histoFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 GraphicsUtilities.reshapeToAspectRatio(histoFrame, 4.0f / 3.0f, 0.6f,
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 histoFrame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 GraphicsUtilities.centerInContainer(histoFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 histoFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1403
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 public void showObjectsOfType(Klass type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 FindObjectByType finder = new FindObjectByType(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 FindObjectByTypeCleanupThunk cleanup =
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 new FindObjectByTypeCleanupThunk(finder);
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 type.printValueOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 String typeName = bos.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 doHeapIteration("Show Objects Of Type",
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 "Finding instances of \"" + typeName + "\"",
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 finder,
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 cleanup);
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1416
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 class FindObjectByTypeCleanupThunk implements CleanupThunk {
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 FindObjectByType finder;
a61af66fc99e Initial load
duke
parents:
diff changeset
1419
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 FindObjectByTypeCleanupThunk(FindObjectByType finder) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 this.finder = finder;
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1423
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 public void heapIterationComplete() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 JInternalFrame finderFrame = new JInternalFrame("Show Objects of Type");
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 finderFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 finderFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 finderFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 finderFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 ObjectListPanel panel = new ObjectListPanel(finder.getResults(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 new HeapProgress("Reverse Pointers Analysis"));
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 panel.addPanelListener(HSDB.this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 finderFrame.getContentPane().add(panel);
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 desktop.add(finderFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 GraphicsUtilities.reshapeToAspectRatio(finderFrame, 4.0f / 3.0f, 0.6f,
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 finderFrame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 GraphicsUtilities.centerInContainer(finderFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 finderFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1445
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 private void showDebuggerConsole() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 if (consoleFrame == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 consoleFrame = new JInternalFrame("Debugger Console");
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 consoleFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 consoleFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 consoleFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 consoleFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 consoleFrame.getContentPane().add(new DebuggerConsolePanel(agent.getDebugger()), BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 GraphicsUtilities.reshapeToAspectRatio(consoleFrame, 5.0f, 0.9f, desktop.getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 if (consoleFrame.getParent() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 desktop.add(consoleFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 consoleFrame.setVisible(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 consoleFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 consoleFrame.getContentPane().getComponent(0).requestFocus();
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1463
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 private void showConsole() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 CommandProcessor.DebuggerInterface di = new CommandProcessor.DebuggerInterface() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 public HotSpotAgent getAgent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 return agent;
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 public boolean isAttached() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 return attached;
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 public void attach(String pid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 attach(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 public void attach(String java, String core) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 public void detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 detachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 public void reattach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 if (attached) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 detachDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 if (pidText != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 attach(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 attach(execPath, coreFilename);
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1491
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 showPanel("Command Line", new CommandProcessorPanel(new CommandProcessor(di, null, null, null)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1494
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 private void showFindByQueryPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 showPanel("Find Object by Query", new FindByQueryPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1498
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 private void showFindPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 showPanel("Find Pointer", new FindPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1502
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 private void showFindInHeapPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 showPanel("Find Address In Heap", new FindInHeapPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1506
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 private void showFindInCodeCachePanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 showPanel("Find Address In Code Cache", new FindInCodeCachePanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1510
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 private void showHeapParametersPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 showPanel("Heap Parameters", new HeapParametersPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1514
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 public void showThreadInfo(final JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 showPanel("Info for " + thread.getThreadName(), new ThreadInfoPanel(thread));
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1518
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 public void showJavaStackTrace(final JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 JavaStackTracePanel jstp = new JavaStackTracePanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 showPanel("Java stack trace for " + thread.getThreadName(), jstp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 jstp.setJavaThread(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1524
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 private void showDeadlockDetectionPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 showPanel("Deadlock Detection", new DeadlockDetectionPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1528
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 private void showMonitorCacheDumpPanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 showPanel("Monitor Cache Dump", new MonitorCacheDumpPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1532
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 public void showClassBrowser() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 final JInternalFrame progressFrame = new JInternalFrame("Class Browser");
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 progressFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 progressFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 progressFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 progressFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 final ProgressBarPanel bar = new ProgressBarPanel("Generating class list ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 bar.setIndeterminate(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 progressFrame.getContentPane().add(bar, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 desktop.add(progressFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 progressFrame.pack();
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 GraphicsUtilities.centerInContainer(progressFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 progressFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1546
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 workerThread.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 HTMLGenerator htmlGen = new HTMLGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 InstanceKlass[] klasses = SystemDictionaryHelper.getAllInstanceKlasses();
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 final String htmlText = htmlGen.genHTMLForKlassNames(klasses);
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 JInternalFrame cbFrame = new JInternalFrame("Class Browser");
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 cbFrame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 cbFrame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 cbFrame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 cbFrame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 ClassBrowserPanel cbPanel = new ClassBrowserPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 cbFrame.getContentPane().add(cbPanel, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 desktop.remove(progressFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 desktop.repaint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 desktop.add(cbFrame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 GraphicsUtilities.reshapeToAspectRatio(cbFrame, 1.25f, 0.85f,
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 cbFrame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 cbFrame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 cbPanel.setClassesText(htmlText);
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1573
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 public void showCodeViewer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 showPanel("Code Viewer", new CodeViewerPanel(), 1.25f, 0.85f);
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1577
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 public void showCodeViewer(final Address address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 final CodeViewerPanel panel = new CodeViewerPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 showPanel("Code Viewer", panel, 1.25f, 0.85f);
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 panel.viewAddress(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1586
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1588
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 public void showMemoryViewer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 showPanel("Memory Viewer", new MemoryViewer(agent.getDebugger(), agent.getTypeDataBase().getAddressSize() == 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1592
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 public void showCommandLineFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 showPanel("Command Line Flags", new VMFlagsPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1596
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 public void showVMVersion() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 showPanel("VM Version Info", new VMVersionInfoPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1600
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 public void showSystemProperties() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 showPanel("System Properties", new SysPropsPanel());
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1604
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 private void showPanel(String name, JPanel panel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 showPanel(name, panel, 5.0f / 3.0f, 0.4f);
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1608
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 private void showPanel(String name, JPanel panel, float aspectRatio, float fillRatio) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 JInternalFrame frame = new JInternalFrame(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 frame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 frame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 frame.setClosable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 frame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 frame.setMaximizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 frame.getContentPane().add(panel, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 desktop.add(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 GraphicsUtilities.reshapeToAspectRatio(frame, aspectRatio, fillRatio, frame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 GraphicsUtilities.randomLocation(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 frame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 if (panel instanceof SAPanel) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 ((SAPanel)panel).addPanelListener(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1625
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 // Framework for heap iteration with progress bar
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1629
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 interface CleanupThunk {
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 public void heapIterationComplete();
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1633
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 class HeapProgress implements HeapProgressThunk {
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 private JInternalFrame frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 private ProgressBarPanel bar;
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 private String windowTitle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 private String progressBarTitle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 private CleanupThunk cleanup;
a61af66fc99e Initial load
duke
parents:
diff changeset
1640
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 HeapProgress(String windowTitle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 this(windowTitle, "Percentage of heap visited", null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1644
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 HeapProgress(String windowTitle, String progressBarTitle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 this(windowTitle, progressBarTitle, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1648
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 HeapProgress(String windowTitle, String progressBarTitle, CleanupThunk cleanup) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 this.windowTitle = windowTitle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 this.progressBarTitle = progressBarTitle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 this.cleanup = cleanup;
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1654
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 public void heapIterationFractionUpdate(final double fractionOfHeapVisited) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 if (frame == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 frame = new JInternalFrame(windowTitle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 frame.setResizable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 frame.setIconifiable(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 frame.getContentPane().setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 bar = new ProgressBarPanel(progressBarTitle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 frame.getContentPane().add(bar, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 desktop.add(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 frame.pack();
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 GraphicsUtilities.constrainToSize(frame, frame.getParent().getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 GraphicsUtilities.centerInContainer(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 frame.show();
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1673
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 bar.setValue(fractionOfHeapVisited);
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1680
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 public void heapIterationComplete() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 SwingUtilities.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 desktop.remove(frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 desktop.repaint();
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 // Ended up computing reverse pointers as a side-effect
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 computeRevPtrsMenuItem.setEnabled(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1692
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 if (cleanup != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 cleanup.heapIterationComplete();
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1698
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 class VisitHeap implements Runnable {
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 HeapVisitor visitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
1701
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 VisitHeap(HeapVisitor visitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 this.visitor = visitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1705
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 VM.getVM().getObjectHeap().iterate(visitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1710
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 private void doHeapIteration(String frameTitle,
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 String progressBarText,
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 HeapVisitor visitor,
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 CleanupThunk cleanup) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 sun.jvm.hotspot.oops.ObjectHistogram histo = new sun.jvm.hotspot.oops.ObjectHistogram();
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 HeapProgress progress = new HeapProgress(frameTitle,
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 progressBarText,
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 cleanup);
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 HeapVisitor progVisitor = new ProgressiveHeapVisitor(visitor, progress);
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 workerThread.invokeLater(new VisitHeap(progVisitor));
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1722
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 // Stack trace helper
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1726
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 private static JavaVFrame getLastJavaVFrame(JavaThread cur) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 RegisterMap regMap = cur.newRegisterMap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 sun.jvm.hotspot.runtime.Frame f = cur.getCurrentFrameGuess();
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 if (f == null) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 boolean imprecise = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 if (f.isInterpretedFrame() && !f.isInterpretedFrameValid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 System.err.println("Correcting for invalid interpreter frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 f = f.sender(regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 imprecise = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 VFrame vf = VFrame.newVFrame(f, regMap, cur, true, imprecise);
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 if (vf == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 System.err.println(" (Unable to create vframe for topmost frame guess)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 if (vf.isJavaFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 return (JavaVFrame) vf;
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 return (JavaVFrame) vf.javaSender();
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1747
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 // Internal routine for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 private static void dumpStack(JavaThread cur) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 RegisterMap regMap = cur.newRegisterMap(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 sun.jvm.hotspot.runtime.Frame f = cur.getCurrentFrameGuess();
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 PrintStream tty = System.err;
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 while (f != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 tty.print("Found ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 if (f.isInterpretedFrame()) { tty.print("interpreted"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 else if (f.isCompiledFrame()) { tty.print("compiled"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 else if (f.isEntryFrame()) { tty.print("entry"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 else if (f.isNativeFrame()) { tty.print("native"); }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
1759 else if (f.isRuntimeFrame()) { tty.print("runtime"); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 else { tty.print("external"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 tty.print(" frame with PC = " + f.getPC() + ", SP = " + f.getSP() + ", FP = " + f.getFP());
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 if (f.isSignalHandlerFrameDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 tty.print(" (SIGNAL HANDLER)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
1766
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 if (!f.isFirstFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 f = f.sender(regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 f = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1774
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 // Component utilities
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1778
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 private static JMenuItem createMenuItem(String name, ActionListener l) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 JMenuItem item = new JMenuItem(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 item.addActionListener(l);
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 return item;
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1784
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 /** Punctuates the given string with \n's where necessary to not
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 exceed the given number of characters per line. Strips
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 extraneous whitespace. */
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 private String formatMessage(String message, int charsPerLine) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 StringBuffer buf = new StringBuffer(message.length());
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 StringTokenizer tokenizer = new StringTokenizer(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 int curLineLength = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 while (tokenizer.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 String tok = tokenizer.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 if (curLineLength + tok.length() > charsPerLine) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 buf.append('\n');
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 curLineLength = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 if (curLineLength != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 ++curLineLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 buf.append(tok);
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 curLineLength += tok.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1808
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 private void setMenuItemsEnabled(java.util.List items, boolean enabled) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 for (Iterator iter = items.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 ((JMenuItem) iter.next()).setEnabled(enabled);
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 }