示例#1
0
  private void commandClear(StringTokenizer t) throws NoSessionException {
    if (!t.hasMoreTokens()) {
      // Print set breakpoints
      listEventRequests();
      return;
    }
    // ### need 'clear all'
    BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
    if (bpSpec != null) {
      List<EventRequestSpec> specs = runtime.eventRequestSpecs();

      if (specs.isEmpty()) {
        env.notice("No breakpoints set.");
      } else {
        List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
        for (EventRequestSpec spec : specs) {
          if (spec.equals(bpSpec)) {
            toDelete.add(spec);
          }
        }
        // The request used for matching should be found
        if (toDelete.size() <= 1) {
          env.notice("No matching breakpoint set.");
        }
        for (EventRequestSpec spec : toDelete) {
          runtime.delete(spec);
        }
      }
    } else {
      env.error("Ill-formed breakpoint specification.");
    }
  }
示例#2
0
 private void commandFrame(StringTokenizer t) throws NoSessionException {
   ThreadReference current = context.getCurrentThread();
   if (current == null) {
     env.failure("No current thread.");
     return;
   }
   if (!t.hasMoreTokens()) {
     env.error("usage: frame <frame-index>");
     return;
   }
   String idToken = t.nextToken();
   int n;
   try {
     n = Integer.valueOf(idToken).intValue();
   } catch (NumberFormatException e) {
     n = 0;
   }
   if (n <= 0) {
     env.error("use positive frame index");
     return;
   }
   try {
     int delta = context.setCurrentFrameIndex(current, n);
     if (delta == 0) {
       env.notice("Frame unchanged.");
     } else if (delta < 0) {
       env.notice("Moved up " + -delta + " frames.");
     } else {
       env.notice("Moved down " + delta + " frames.");
     }
   } catch (VMNotInterruptedException e) {
     env.failure("Target VM must be in interrupted state.");
   }
 }
示例#3
0
 private void commandKill(StringTokenizer t) throws NoSessionException {
   // ### Should change the way in which thread ids and threadgroup names
   // ### are distinguished.
   if (!t.hasMoreTokens()) {
     env.error("Usage: kill <threadgroup name> or <thread id>");
     return;
   }
   while (t.hasMoreTokens()) {
     String idToken = t.nextToken();
     ThreadReference thread = findThread(idToken);
     if (thread != null) {
       runtime.stopThread(thread);
       env.notice("Thread " + thread.name() + " killed.");
       return;
     } else {
       /* Check for threadgroup name, NOT skipping "system". */
       // ### Should skip "system"?  Classic 'jdb' does this.
       // ### Should deal with possible non-uniqueness of threadgroup names.
       ThreadGroupIterator itg = allThreadGroups();
       while (itg.hasNext()) {
         ThreadGroupReference tg = itg.nextThreadGroup();
         if (tg.name().equals(idToken)) {
           ThreadIterator it = new ThreadIterator(tg);
           while (it.hasNext()) {
             runtime.stopThread(it.nextThread());
           }
           env.notice("Threadgroup " + tg.name() + "killed.");
           return;
         }
       }
       env.failure("\"" + idToken + "\" is not a valid threadgroup or id.");
     }
   }
 }
示例#4
0
 private void commandCont() throws NoSessionException {
   try {
     runtime.go();
   } catch (VMNotInterruptedException e) {
     // ### failure?
     env.notice("Target VM is already running.");
   }
 }
示例#5
0
 private void commandDown(StringTokenizer t) throws NoSessionException {
   ThreadReference current = context.getCurrentThread();
   if (current == null) {
     env.failure("No current thread.");
     return;
   }
   int nLevels = readCount(t);
   if (nLevels <= 0) {
     env.error("usage: down [n frames]");
     return;
   }
   try {
     int delta = context.moveCurrentFrameIndex(current, nLevels);
     if (delta == 0) {
       env.notice("Already at bottom of stack.");
     } else if (delta < nLevels) {
       env.notice("Moved down " + delta + " frames to bottom of stack.");
     }
   } catch (VMNotInterruptedException e) {
     env.failure("Target VM must be in interrupted state.");
   }
 }
示例#6
0
 private void listEventRequests() throws NoSessionException {
   // Print set breakpoints
   List<EventRequestSpec> specs = runtime.eventRequestSpecs();
   if (specs.isEmpty()) {
     env.notice("No breakpoints/watchpoints/exceptions set.");
   } else {
     OutputSink out = env.getOutputSink();
     out.println("Current breakpoints/watchpoints/exceptions set:");
     for (EventRequestSpec bp : specs) {
       out.println("\t" + bp);
     }
     out.show();
   }
 }
示例#7
0
 private void commandResume(StringTokenizer t) throws NoSessionException {
   if (!t.hasMoreTokens()) {
     // Suspend all threads in the current thread group.
     // ### Issue: help message says default is all threads.
     // ### Behavior here agrees with 'jdb', however.
     ThreadIterator ti = currentThreadGroupThreads();
     while (ti.hasNext()) {
       // TODO - don't suspend debugger threads
       ti.nextThread().resume();
     }
     env.notice("All threads resumed.");
   } else {
     while (t.hasMoreTokens()) {
       ThreadReference thread = findThread(t.nextToken());
       if (thread != null) {
         // thread.resume();
         runtime.resumeThread(thread);
       }
     }
   }
 }
示例#8
0
 private void commandRun(StringTokenizer t) throws NoSessionException {
   if (doLoad(false, t)) {
     env.notice("Running ...");
   }
 }