Пример #1
0
 private void commandDetach(StringTokenizer t) throws NoSessionException {
   runtime.detach();
 }
Пример #2
0
 public void executeCommand(String command) {
   // ### Treatment of 'out' here is dirty...
   out = env.getOutputSink();
   if (echo) {
     out.println(">>> " + command);
   }
   StringTokenizer t = new StringTokenizer(command);
   try {
     String cmd;
     if (t.hasMoreTokens()) {
       cmd = t.nextToken().toLowerCase();
       lastCommand = cmd;
     } else {
       cmd = lastCommand;
     }
     if (cmd.equals("print")) {
       commandPrint(t, false);
     } else if (cmd.equals("eval")) {
       commandPrint(t, false);
     } else if (cmd.equals("dump")) {
       commandPrint(t, true);
     } else if (cmd.equals("locals")) {
       commandLocals();
     } else if (cmd.equals("classes")) {
       commandClasses();
     } else if (cmd.equals("methods")) {
       commandMethods(t);
     } else if (cmd.equals("threads")) {
       commandThreads(t);
     } else if (cmd.equals("thread")) {
       commandThread(t);
     } else if (cmd.equals("suspend")) {
       commandSuspend(t);
     } else if (cmd.equals("resume")) {
       commandResume(t);
     } else if (cmd.equals("cont")) {
       commandCont();
     } else if (cmd.equals("threadgroups")) {
       commandThreadGroups();
     } else if (cmd.equals("threadgroup")) {
       commandThreadGroup(t);
     } else if (cmd.equals("run")) {
       commandRun(t);
     } else if (cmd.equals("load")) {
       commandLoad(t);
     } else if (cmd.equals("connect")) {
       commandConnect(t);
     } else if (cmd.equals("attach")) {
       commandAttach(t);
     } else if (cmd.equals("detach")) {
       commandDetach(t);
     } else if (cmd.equals("interrupt")) {
       commandInterrupt(t);
       // ### Not implemented.
       //          } else if (cmd.equals("catch")) {
       //              commandCatchException(t);
       // ### Not implemented.
       //          } else if (cmd.equals("ignore")) {
       //              commandIgnoreException(t);
     } else if (cmd.equals("step")) {
       commandStep(t);
     } else if (cmd.equals("stepi")) {
       commandStepi();
     } else if (cmd.equals("next")) {
       commandNext();
     } else if (cmd.equals("nexti")) {
       commandNexti();
     } else if (cmd.equals("kill")) {
       commandKill(t);
     } else if (cmd.equals("where")) {
       commandWhere(t, false);
     } else if (cmd.equals("wherei")) {
       commandWhere(t, true);
     } else if (cmd.equals("up")) {
       commandUp(t);
     } else if (cmd.equals("down")) {
       commandDown(t);
     } else if (cmd.equals("frame")) {
       commandFrame(t);
     } else if (cmd.equals("stop")) {
       commandStop(t);
     } else if (cmd.equals("clear")) {
       commandClear(t);
     } else if (cmd.equals("list")) {
       commandList(t);
     } else if (cmd.equals("use")) {
       commandUse(t);
     } else if (cmd.equals("sourcepath")) {
       commandSourcepath(t);
     } else if (cmd.equals("classpath")) {
       commandClasspath(t);
     } else if (cmd.equals("monitor")) {
       commandMonitor(t);
     } else if (cmd.equals("unmonitor")) {
       commandUnmonitor(t);
     } else if (cmd.equals("view")) {
       commandView(t);
       //          } else if (cmd.equals("read")) {
       //              readCommand(t);
     } else if (cmd.equals("help") || cmd.equals("?")) {
       help();
     } else if (cmd.equals("quit") || cmd.equals("exit")) {
       try {
         runtime.detach();
       } catch (NoSessionException e) {
         // ignore
       }
       env.terminate();
     } else {
       // ### Dubious repeat-count feature inherited from 'jdb'
       if (t.hasMoreTokens()) {
         try {
           int repeat = Integer.parseInt(cmd);
           String subcom = t.nextToken("");
           while (repeat-- > 0) {
             executeCommand(subcom);
           }
           return;
         } catch (NumberFormatException exc) {
         }
       }
       out.println("huh? Try help...");
       out.flush();
     }
   } catch (NoSessionException e) {
     out.println("There is no currently attached VM session.");
     out.flush();
   } catch (Exception e) {
     out.println("Internal exception: " + e.toString());
     out.flush();
     System.out.println("JDB internal exception: " + e.toString());
     e.printStackTrace();
   }
   out.show();
 }