Exemplo n.º 1
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.");
     }
   }
 }
Exemplo n.º 2
0
 private void commandWhere(StringTokenizer t, boolean showPC) throws NoSessionException {
   ThreadReference current = context.getCurrentThread();
   if (!t.hasMoreTokens()) {
     if (current == null) {
       env.error("No thread specified.");
       return;
     }
     dumpStack(current, showPC);
   } else {
     String token = t.nextToken();
     if (token.toLowerCase().equals("all")) {
       ThreadIterator it = allThreads();
       while (it.hasNext()) {
         ThreadReference thread = it.next();
         out.println(thread.name() + ": ");
         dumpStack(thread, showPC);
       }
     } else {
       ThreadReference thread = findThread(t.nextToken());
       // ### Do we want to set current thread here?
       // ### Should notify user of change.
       if (thread != null) {
         context.setCurrentThread(thread);
       }
       dumpStack(thread, showPC);
     }
   }
 }
Exemplo n.º 3
0
 private ThreadReference[] threads() throws NoSessionException {
   if (threads == null) {
     ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup());
     List<ThreadReference> tlist = new ArrayList<ThreadReference>();
     while (ti.hasNext()) {
       tlist.add(ti.nextThread());
     }
     threads = tlist.toArray(new ThreadReference[tlist.size()]);
   }
   return threads;
 }
Exemplo n.º 4
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);
       }
     }
   }
 }