1 7 34 35 package com.sun.tools.example.debug.gui; 36 37 import java.io.*; 38 import java.util.*; 39 40 import javax.swing.*; 41 import javax.swing.border.*; 42 import java.awt.*; 43 import java.awt.event.*; 44 45 import com.sun.jdi.*; 46 import com.sun.tools.example.debug.bdi.*; 47 48 public class GUI extends JPanel { 49 50 private CommandTool cmdTool; 51 private ApplicationTool appTool; 52 public static SourceTool srcTool; 57 58 private SourceTreeTool sourceTreeTool; 59 private ClassTreeTool classTreeTool; 60 private ThreadTreeTool threadTreeTool; 61 private StackTraceTool stackTool; 62 private MonitorTool monitorTool; 63 64 public static final String progname = "javadt"; 65 public static final String version = "1.0Beta"; public static final String windowBanner = "Java(tm) platform Debug Tool"; 67 68 private Font fixedFont = new Font("monospaced", Font.PLAIN, 10); 69 70 private GUI(Environment env) { 71 setLayout(new BorderLayout()); 72 73 setBorder(new EmptyBorder(5, 5, 5, 5)); 74 75 add(new JDBToolBar(env), BorderLayout.NORTH); 76 77 srcTool = new SourceTool(env); 78 srcTool.setPreferredSize(new java.awt.Dimension (500, 300)); 79 srcTool.setTextFont(fixedFont); 80 81 stackTool = new StackTraceTool(env); 82 stackTool.setPreferredSize(new java.awt.Dimension (500, 100)); 83 84 monitorTool = new MonitorTool(env); 85 monitorTool.setPreferredSize(new java.awt.Dimension (500, 50)); 86 87 JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool, 88 new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool)); 89 90 sourceTreeTool = new SourceTreeTool(env); 91 sourceTreeTool.setPreferredSize(new java.awt.Dimension (200, 450)); 92 93 classTreeTool = new ClassTreeTool(env); 94 classTreeTool.setPreferredSize(new java.awt.Dimension (200, 450)); 95 96 threadTreeTool = new ThreadTreeTool(env); 97 threadTreeTool.setPreferredSize(new java.awt.Dimension (200, 450)); 98 99 JTabbedPane treePane = new JTabbedPane(JTabbedPane.BOTTOM); 100 treePane.addTab("Source", null, sourceTreeTool); 101 treePane.addTab("Classes", null, classTreeTool); 102 treePane.addTab("Threads", null, threadTreeTool); 103 104 JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right); 105 106 cmdTool = new CommandTool(env); 107 cmdTool.setPreferredSize(new java.awt.Dimension (700, 150)); 108 109 appTool = new ApplicationTool(env); 110 appTool.setPreferredSize(new java.awt.Dimension (700, 200)); 111 112 JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool); 113 115 JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom); 116 117 add(center, BorderLayout.CENTER); 118 119 120 } 121 122 private static void usage() { 123 String separator = File.pathSeparator; 124 System.out.println("Usage: " + progname + " <options> <class> <arguments>"); 125 System.out.println(); 126 System.out.println("where options include:"); 127 System.out.println(" -help print out this message and exit"); 128 System.out.println(" -sourcepath <directories separated by \"" + 129 separator + "\">"); 130 System.out.println(" list directories in which to look for source files"); 131 System.out.println(" -remote <hostname>:<port-number>"); 132 System.out.println(" host machine and port number of interpreter to attach to"); 133 System.out.println(" -dbgtrace [flags] print info for debugging " + progname); 134 System.out.println(); 135 System.out.println("options forwarded to debuggee process:"); 136 System.out.println(" -v -verbose[:class|gc|jni]"); 137 System.out.println(" turn on verbose mode"); 138 System.out.println(" -D<name>=<value> set a system property"); 139 System.out.println(" -classpath <directories separated by \"" + 140 separator + "\">"); 141 System.out.println(" list directories in which to look for classes"); 142 System.out.println(" -X<option> non-standard debuggee VM option"); 143 System.out.println(); 144 System.out.println("<class> is the name of the class to begin debugging"); 145 System.out.println("<arguments> are the arguments passed to the main() method of <class>"); 146 System.out.println(); 147 System.out.println("For command help type 'help' at " + progname + " prompt"); 148 } 149 150 public static void main(String argv[]) { 151 String remote = null; 152 String clsName = ""; 153 String progArgs = ""; 154 String javaArgs = ""; 155 boolean verbose = false; 157 final Environment env = new Environment(); 158 159 JPanel mainPanel = new GUI(env); 160 161 ContextManager context = env.getContextManager(); 162 ExecutionManager runtime = env.getExecutionManager(); 163 164 for (int i = 0; i < argv.length; i++) { 165 String token = argv[i]; 166 if (token.equals("-dbgtrace")) { 167 if ((i == argv.length - 1) || 168 ! Character.isDigit(argv[i+1].charAt(0))) { 169 runtime.setTraceMode(VirtualMachine.TRACE_ALL); 170 } else { 171 String flagStr = argv[++i]; 172 runtime.setTraceMode(Integer.decode(flagStr).intValue()); 173 } 174 } else if (token.equals("-X")) { 175 System.out.println( 176 "Use 'java -X' to see the available non-standard options"); 177 System.out.println(); 178 usage(); 179 System.exit(1); 180 } else if ( 181 token.equals("-v") || token.startsWith("-v:") || token.startsWith("-verbose") || token.startsWith("-D") || 185 token.startsWith("-X") || 187 token.equals("-noasyncgc") || token.equals("-prof") || 190 token.equals("-verify") || token.equals("-noverify") || 191 token.equals("-verifyremote") || 192 token.equals("-verbosegc") || 193 token.startsWith("-ms") || token.startsWith("-mx") || 194 token.startsWith("-ss") || token.startsWith("-oss") ) { 195 javaArgs += token + " "; 196 } else if (token.equals("-sourcepath")) { 197 if (i == (argv.length - 1)) { 198 System.out.println("No sourcepath specified."); 199 usage(); 200 System.exit(1); 201 } 202 env.getSourceManager().setSourcePath(new SearchPath(argv[++i])); 203 } else if (token.equals("-classpath")) { 204 if (i == (argv.length - 1)) { 205 System.out.println("No classpath specified."); 206 usage(); 207 System.exit(1); 208 } 209 env.getClassManager().setClassPath(new SearchPath(argv[++i])); 210 } else if (token.equals("-remote")) { 211 if (i == (argv.length - 1)) { 212 System.out.println("No remote specified."); 213 usage(); 214 System.exit(1); 215 } 216 env.getContextManager().setRemotePort(argv[++i]); 217 } else if (token.equals("-help")) { 218 usage(); 219 System.exit(0); 220 } else if (token.equals("-version")) { 221 System.out.println(progname + " version " + version); 222 System.exit(0); 223 } else if (token.startsWith("-")) { 224 System.out.println("invalid option: " + token); 225 usage(); 226 System.exit(1); 227 } else { 228 clsName = token; 230 for (i++; i < argv.length; i++) { 231 progArgs += argv[i] + " "; 232 } 233 break; 234 } 235 } 236 237 context.setMainClassName(clsName); 238 context.setProgramArguments(progArgs); 239 context.setVmArguments(javaArgs); 240 241 try { 243 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 244 } catch (Exception exc) { 248 System.err.println("Error loading L&F: " + exc); 249 } 250 251 JFrame frame = new JFrame(); 252 frame.setBackground(Color.lightGray); 253 frame.setTitle(windowBanner); 254 frame.setJMenuBar(new JDBMenuBar(env)); 255 frame.setContentPane(mainPanel); 256 257 frame.addWindowListener(new WindowAdapter() { 258 public void windowClosing(WindowEvent e) { 259 env.terminate(); 260 } 261 }); 262 263 frame.pack(); 264 frame.show(); 265 266 } 267 268 } 269 | Popular Tags |