Beispiel #1
0
 public void resume() {
   switch (suspendPolicy()) {
     case EventRequest.SUSPEND_ALL:
       vm.resume();
       break;
     case EventRequest.SUSPEND_EVENT_THREAD:
       ThreadReference thread = eventThread();
       if (thread == null) {
         throw new InternalException("Inconsistent suspend policy");
       }
       thread.resume();
       break;
     case EventRequest.SUSPEND_NONE:
       // Do nothing
       break;
     default:
       throw new InternalException("Invalid suspend policy");
   }
 }
Beispiel #2
0
  /*
   * Complete the construction of an EventSet.  This is called from
   * an event handler thread.  It upacks the JDWP events inside
   * the packet and creates EventImpls for them.  The EventSet is already
   * on EventQueues when this is called, so it has to be synch.
   */
  synchronized void build() {
    if (pkt == null) {
      return;
    }
    PacketStream ps = new PacketStream(vm, pkt);
    JDWP.Event.Composite compEvt = new JDWP.Event.Composite(vm, ps);
    suspendPolicy = compEvt.suspendPolicy;
    if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) {
      switch (suspendPolicy) {
        case JDWP.SuspendPolicy.ALL:
          vm.printTrace("EventSet: SUSPEND_ALL");
          break;

        case JDWP.SuspendPolicy.EVENT_THREAD:
          vm.printTrace("EventSet: SUSPEND_EVENT_THREAD");
          break;

        case JDWP.SuspendPolicy.NONE:
          vm.printTrace("EventSet: SUSPEND_NONE");
          break;
      }
    }

    ThreadReference fix6485605 = null;
    for (int i = 0; i < compEvt.events.length; i++) {
      EventImpl evt = createEvent(compEvt.events[i]);
      if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) {
        try {
          vm.printTrace("Event: " + evt);
        } catch (VMDisconnectedException ee) {
          // ignore - see bug 6502716
        }
      }

      switch (evt.destination()) {
        case UNKNOWN_EVENT:
          // Ignore disabled, deleted, unknown events, but
          // save the thread if there is one since we might
          // have to resume it.  Note that events for different
          // threads can't be in the same event set.
          if (evt instanceof ThreadedEventImpl
              && suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
            fix6485605 = ((ThreadedEventImpl) evt).thread();
          }
          continue;
        case CLIENT_EVENT:
          addEvent(evt);
          break;
        case INTERNAL_EVENT:
          if (internalEventSet == null) {
            internalEventSet = new EventSetImpl(this.vm, null);
          }
          internalEventSet.addEvent(evt);
          break;
        default:
          throw new InternalException("Invalid event destination");
      }
    }
    pkt = null; // No longer needed - free it up

    // Avoid hangs described in 6296125, 6293795
    if (super.size() == 0) {
      // This set has no client events.  If we don't do
      // needed resumes, no one else is going to.
      if (suspendPolicy == JDWP.SuspendPolicy.ALL) {
        vm.resume();
      } else if (suspendPolicy == JDWP.SuspendPolicy.EVENT_THREAD) {
        // See bug 6485605.
        if (fix6485605 != null) {
          fix6485605.resume();
        } else {
          // apparently, there is nothing to resume.
        }
      }
      suspendPolicy = JDWP.SuspendPolicy.NONE;
    }
  }