1 21 22 package org.armedbear.j.jdb; 23 24 import com.sun.jdi.Bootstrap; 25 import org.armedbear.j.Help; 26 import org.armedbear.j.JavaMode; 27 import org.armedbear.j.Log; 28 import org.armedbear.j.MessageDialog; 29 30 public final class JdbCommands implements JdbConstants 31 { 32 public static int findCommand(String cmd) 33 { 34 if (cmd.equals("b")) 36 return JDB_BREAK; 37 if (cmd.equals("c")) 38 return JDB_CONTINUE; 39 if (cmd.equals("f")) 40 return JDB_FINISH; 41 if (cmd.equals("n")) 42 return JDB_NEXT; 43 if (cmd.equals("q")) 44 return JDB_QUIT; 45 if (cmd.equals("s")) 46 return JDB_STEP; 47 if (cmd.equals("p")) 48 return JDB_PRINT; 49 50 if ("break".startsWith(cmd)) 51 return JDB_BREAK; 52 if (cmd.startsWith("ca")) 53 if ("catch".startsWith(cmd)) 54 return JDB_CATCH; 55 if (cmd.startsWith("co")) 56 if ("continue".startsWith(cmd)) 57 return JDB_CONTINUE; 58 if (cmd.startsWith("cl")) 59 if ("clear".startsWith(cmd)) 60 return JDB_CLEAR; 61 if ("finish".startsWith(cmd)) 62 return JDB_FINISH; 63 if ("go".startsWith(cmd)) 64 return JDB_CONTINUE; 65 if ("locals".startsWith(cmd)) 66 return JDB_LOCALS; 67 if ("next".startsWith(cmd)) 68 return JDB_NEXT; 69 if ("print".startsWith(cmd)) 70 return JDB_PRINT; 71 if ("quit".startsWith(cmd)) 72 return JDB_QUIT; 73 if (cmd.startsWith("rest")) 74 if ("restart".startsWith(cmd)) 75 return JDB_RESTART; 76 if (cmd.startsWith("resu")) 77 if ("resume".startsWith(cmd)) 78 return JDB_CONTINUE; 79 if (cmd.startsWith("std")) 80 if ("stdin".startsWith(cmd)) 81 return JDB_STDIN; 82 if (cmd.startsWith("ste")) 83 if ("step".startsWith(cmd)) 84 return JDB_STEP; 85 if (cmd.startsWith("sto")) 86 if ("stop".startsWith(cmd)) 87 return JDB_BREAK; 88 if (cmd.startsWith("su")) 89 if ("suspend".startsWith(cmd)) 90 return JDB_SUSPEND; 91 if ("tbreak".startsWith(cmd)) 92 return JDB_TBREAK; 93 94 return -1; 95 } 96 97 public static void jdb() 98 { 99 if (JavaMode.getJdb() == null) { 100 try { 101 Bootstrap.virtualMachineManager(); 102 } 103 catch (NoClassDefFoundError e) { 104 Log.error("unable to load com.sun.jdi.Bootstrap"); 105 String classpath = System.getProperty("java.class.path"); 106 Log.error("classpath = " + classpath); 107 Help.help("jdb.html"); 108 MessageDialog.showMessageDialog( 109 "Unable to find tools.jar. " + 110 "See doc/jdb.html for installation instructions.", 111 "Jdb"); 112 return; 113 } 114 } 115 Jdb.jdb(); 116 } 117 118 public static void jdb(String s) 119 { 120 if (JavaMode.getJdb() != null) 121 command(s); 122 else 123 MessageDialog.showMessageDialog("The debugger is not running.", 124 "Error"); 125 } 126 127 public static void jdbContinue() 128 { 129 command("continue"); 130 } 131 132 public static void jdbFinish() 133 { 134 command("finish"); 135 } 136 137 public static void jdbLocals() 138 { 139 command("locals"); 140 } 141 142 public static void jdbNext() 143 { 144 command("next"); 145 } 146 147 public static void jdbQuit() 148 { 149 command("quit"); 150 } 151 152 public static void jdbRestart() 153 { 154 command("restart"); 155 } 156 157 public static void jdbStep() 158 { 159 command("step"); 160 } 161 162 public static void jdbSuspend() 163 { 164 command("suspend"); 165 } 166 167 public static void command(String s) 168 { 169 Jdb jdb = Jdb.findJdb(); 170 if (jdb != null) 171 jdb.doCommand(s); 172 } 173 } 174 | Popular Tags |