com.sun.jdi.request.EventRequest Java Examples

The following examples show how to use com.sun.jdi.request.EventRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventRequestSpecList.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Resolve all deferred eventRequests waiting for 'refType'.
 * @return true if it completes successfully, false on error.
 */
boolean resolve(ClassPrepareEvent event) {
    boolean failure = false;
    synchronized(eventRequestSpecs) {
        for (EventRequestSpec spec : eventRequestSpecs) {
            if (!spec.isResolved()) {
                try {
                    EventRequest eventRequest = spec.resolve(event);
                    if (eventRequest != null) {
                        MessageOutput.println("Set deferred", spec.toString());
                    }
                } catch (Exception e) {
                    MessageOutput.println("Unable to set deferred",
                                          new Object [] {spec.toString(),
                                                         spec.errorMessageFor(e)});
                    failure = true;
                }
            }
        }
    }
    return !failure;
}
 
Example #2
Source File: EventRequestSpecList.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Resolve all deferred eventRequests waiting for 'refType'.
 * @return true if it completes successfully, false on error.
 */
boolean resolve(ClassPrepareEvent event) {
    boolean failure = false;
    synchronized(eventRequestSpecs) {
        for (EventRequestSpec spec : eventRequestSpecs) {
            if (!spec.isResolved()) {
                try {
                    EventRequest eventRequest = spec.resolve(event);
                    if (eventRequest != null) {
                        MessageOutput.println("Set deferred", spec.toString());
                    }
                } catch (Exception e) {
                    MessageOutput.println("Unable to set deferred",
                                          new Object [] {spec.toString(),
                                                         spec.errorMessageFor(e)});
                    failure = true;
                }
            }
        }
    }
    return !failure;
}
 
Example #3
Source File: DebugUtility.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
private static StepRequest createStepRequest(ThreadReference thread, int stepSize, int stepDepth, String[] classFilters, String[] classExclusionFilters) {
    StepRequest request = thread.virtualMachine().eventRequestManager().createStepRequest(thread, stepSize, stepDepth);
    if (classFilters != null) {
        for (String classFilter : classFilters) {
            request.addClassFilter(classFilter);
        }
    }
    if (classExclusionFilters != null) {
        for (String exclusionFilter : classExclusionFilters) {
            request.addClassExclusionFilter(exclusionFilter);
        }
    }
    request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
    request.addCountFilter(1);

    return request;
}
 
Example #4
Source File: EventRequestSpec.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #5
Source File: DebugSession.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start() {
    // request thread events by default
    EventRequest threadStartRequest = vm.eventRequestManager().createThreadStartRequest();
    threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    threadStartRequest.enable();

    EventRequest threadDeathRequest = vm.eventRequestManager().createThreadDeathRequest();
    threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    threadDeathRequest.enable();

    eventHub.start(vm);
}
 
Example #6
Source File: ModificationWatchpointSpec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The 'refType' is known to match, return the EventRequest.
 */
@Override
EventRequest resolveEventRequest(ReferenceType refType)
                                  throws NoSuchFieldException {
    Field field = refType.fieldByName(fieldId);
    EventRequestManager em = refType.virtualMachine().eventRequestManager();
    EventRequest wp = em.createModificationWatchpointRequest(field);
    wp.setSuspendPolicy(suspendPolicy);
    wp.enable();
    return wp;
}
 
Example #7
Source File: FieldMonitor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example #8
Source File: EventRequestSpecList.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void resolveAll() {
    for (EventRequestSpec spec : eventRequestSpecs) {
        try {
            EventRequest eventRequest = spec.resolveEagerly();
            if (eventRequest != null) {
                MessageOutput.println("Set deferred", spec.toString());
            }
        } catch (Exception e) {
        }
    }
}
 
Example #9
Source File: ModificationWatchpointSpec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The 'refType' is known to match, return the EventRequest.
 */
@Override
EventRequest resolveEventRequest(ReferenceType refType)
                                  throws NoSuchFieldException {
    Field field = refType.fieldByName(fieldId);
    EventRequestManager em = refType.virtualMachine().eventRequestManager();
    EventRequest wp = em.createModificationWatchpointRequest(field);
    wp.setSuspendPolicy(suspendPolicy);
    wp.enable();
    return wp;
}
 
Example #10
Source File: EventRequestSpec.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return If this EventRequestSpec matches the 'refType'
 * return the cooresponding EventRequest.  Otherwise
 * return null.
 */
synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception {
    if ((resolved == null) &&
        (prepareRequest != null) &&
        prepareRequest.equals(event.request())) {

        resolved = resolveEventRequest(event.referenceType());
        prepareRequest.disable();
        Env.vm().eventRequestManager().deleteEventRequest(prepareRequest);
        prepareRequest = null;

        if (refSpec instanceof PatternReferenceTypeSpec) {
            PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec;
            if (! prs.isUnique()){
                /*
                 * Class pattern event requests are never
                 * considered "resolved", since future class loads
                 * might also match.
                 * Create and enable a new ClassPrepareRequest to
                 * keep trying to resolve.
                 */
                resolved = null;
                prepareRequest = refSpec.createPrepareRequest();
                prepareRequest.enable();
            }
        }
    }
    return resolved;
}
 
Example #11
Source File: EventRequestSpec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return If this EventRequestSpec matches the 'refType'
 * return the cooresponding EventRequest.  Otherwise
 * return null.
 */
synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception {
    if ((resolved == null) &&
        (prepareRequest != null) &&
        prepareRequest.equals(event.request())) {

        resolved = resolveEventRequest(event.referenceType());
        prepareRequest.disable();
        Env.vm().eventRequestManager().deleteEventRequest(prepareRequest);
        prepareRequest = null;

        if (refSpec instanceof PatternReferenceTypeSpec) {
            PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec;
            if (! prs.isUnique()){
                /*
                 * Class pattern event requests are never
                 * considered "resolved", since future class loads
                 * might also match.
                 * Create and enable a new ClassPrepareRequest to
                 * keep trying to resolve.
                 */
                resolved = null;
                prepareRequest = refSpec.createPrepareRequest();
                prepareRequest.enable();
            }
        }
    }
    return resolved;
}
 
Example #12
Source File: LineBreakpointImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the list of reference types are new types (the breakpoint
 * was not submitted anywhere yet), or are some of the types for which the
 * breakpoint was submitted already.
 * @param referenceTypes The types to check
 */
private boolean areNewOrSubmittedTypes(List<ReferenceType> referenceTypes) {
    List<EventRequest> eventRequests = getEventRequests();
    List<BreakpointRequest> brs = new LinkedList<BreakpointRequest>();
    for (EventRequest er : eventRequests) {
        if (er instanceof BreakpointRequest) {
            brs.add((BreakpointRequest) er);
        }
    }
    if (brs.isEmpty()) {
        return true;
    }
    for (ReferenceType rt : referenceTypes) {
        // Check whether breakpoint requests' types contains rt:
        boolean contains = false;
        for (BreakpointRequest br : brs) {
            ReferenceType brt = br.location().declaringType();
            if (rt.equals(brt)) {
                contains = true;
                break;
            }
        }
        if (!contains) {
            return false;
        }
    }
    return true;
}
 
Example #13
Source File: EventRequestSpec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #14
Source File: EventRequestSpecList.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
void resolveAll() {
    for (EventRequestSpec spec : eventRequestSpecs) {
        try {
            EventRequest eventRequest = spec.resolveEagerly();
            if (eventRequest != null) {
                MessageOutput.println("Set deferred", spec.toString());
            }
        } catch (Exception e) {
        }
    }
}
 
Example #15
Source File: EventRequestSpec.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #16
Source File: FieldMonitor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void addFieldWatch(VirtualMachine vm,
    ReferenceType refType) {
  EventRequestManager erm = vm.eventRequestManager();
  Field field = refType.fieldByName(FIELD_NAME);
  ModificationWatchpointRequest modificationWatchpointRequest = erm
      .createModificationWatchpointRequest(field);
  modificationWatchpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  modificationWatchpointRequest.setEnabled(true);
}
 
Example #17
Source File: EventRequestSpecList.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void resolveAll() {
    for (EventRequestSpec spec : eventRequestSpecs) {
        try {
            EventRequest eventRequest = spec.resolveEagerly();
            if (eventRequest != null) {
                MessageOutput.println("Set deferred", spec.toString());
            }
        } catch (Exception e) {
        }
    }
}
 
Example #18
Source File: EventHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    EventQueue queue = Env.vm().eventQueue();
    while (connected) {
        try {
            EventSet eventSet = queue.remove();
            boolean resumeStoppedApp = false;
            EventIterator it = eventSet.eventIterator();
            while (it.hasNext()) {
                resumeStoppedApp |= !handleEvent(it.nextEvent());
            }

            if (resumeStoppedApp) {
                eventSet.resume();
            } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
                setCurrentThread(eventSet);
                notifier.vmInterrupted();
            }
        } catch (InterruptedException exc) {
            // Do nothing. Any changes will be seen at top of loop.
        } catch (VMDisconnectedException discExc) {
            handleDisconnectedException();
            break;
        }
    }
    synchronized (this) {
        completed = true;
        notifyAll();
    }
}
 
Example #19
Source File: EventRequestSpec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #20
Source File: EventRequestSpec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return If this EventRequestSpec matches the 'refType'
 * return the cooresponding EventRequest.  Otherwise
 * return null.
 */
synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception {
    if ((resolved == null) &&
        (prepareRequest != null) &&
        prepareRequest.equals(event.request())) {

        resolved = resolveEventRequest(event.referenceType());
        prepareRequest.disable();
        Env.vm().eventRequestManager().deleteEventRequest(prepareRequest);
        prepareRequest = null;

        if (refSpec instanceof PatternReferenceTypeSpec) {
            PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec;
            if (! prs.isUnique()){
                /*
                 * Class pattern event requests are never
                 * considered "resolved", since future class loads
                 * might also match.
                 * Create and enable a new ClassPrepareRequest to
                 * keep trying to resolve.
                 */
                resolved = null;
                prepareRequest = refSpec.createPrepareRequest();
                prepareRequest.enable();
            }
        }
    }
    return resolved;
}
 
Example #21
Source File: EventHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    EventQueue queue = Env.vm().eventQueue();
    while (connected) {
        try {
            EventSet eventSet = queue.remove();
            boolean resumeStoppedApp = false;
            EventIterator it = eventSet.eventIterator();
            while (it.hasNext()) {
                resumeStoppedApp |= !handleEvent(it.nextEvent());
            }

            if (resumeStoppedApp) {
                eventSet.resume();
            } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
                setCurrentThread(eventSet);
                notifier.vmInterrupted();
            }
        } catch (InterruptedException exc) {
            // Do nothing. Any changes will be seen at top of loop.
        } catch (VMDisconnectedException discExc) {
            handleDisconnectedException();
            break;
        }
    }
    synchronized (this) {
        completed = true;
        notifyAll();
    }
}
 
Example #22
Source File: EventHandler.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    EventQueue queue = Env.vm().eventQueue();
    while (connected) {
        try {
            EventSet eventSet = queue.remove();
            boolean resumeStoppedApp = false;
            EventIterator it = eventSet.eventIterator();
            while (it.hasNext()) {
                resumeStoppedApp |= !handleEvent(it.nextEvent());
            }

            if (resumeStoppedApp) {
                eventSet.resume();
            } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
                setCurrentThread(eventSet);
                notifier.vmInterrupted();
            }
        } catch (InterruptedException exc) {
            // Do nothing. Any changes will be seen at top of loop.
        } catch (VMDisconnectedException discExc) {
            handleDisconnectedException();
            break;
        }
    }
    synchronized (this) {
        completed = true;
        notifyAll();
    }
}
 
Example #23
Source File: EventRequestSpec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #24
Source File: EventRequestSpecList.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
boolean addEagerlyResolve(EventRequestSpec spec) {
    try {
        eventRequestSpecs.add(spec);
        EventRequest eventRequest = spec.resolveEagerly();
        if (eventRequest != null) {
            MessageOutput.println("Set", spec.toString());
        }
        return true;
    } catch (Exception exc) {
        MessageOutput.println("Unable to set",
                              new Object [] {spec.toString(),
                                             spec.errorMessageFor(exc)});
        return false;
    }
}
 
Example #25
Source File: EventRequestSpecList.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
boolean addEagerlyResolve(EventRequestSpec spec) {
    try {
        eventRequestSpecs.add(spec);
        EventRequest eventRequest = spec.resolveEagerly();
        if (eventRequest != null) {
            MessageOutput.println("Set", spec.toString());
        }
        return true;
    } catch (Exception exc) {
        MessageOutput.println("Unable to set",
                              new Object [] {spec.toString(),
                                             spec.errorMessageFor(exc)});
        return false;
    }
}
 
Example #26
Source File: EventRequestSpec.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private EventRequest resolveAgainstPreparedClasses() throws Exception {
    for (ReferenceType refType : Env.vm().allClasses()) {
        if (refType.isPrepared() && refSpec.matches(refType)) {
            resolved = resolveEventRequest(refType);
        }
    }
    return resolved;
}
 
Example #27
Source File: EventHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    EventQueue queue = Env.vm().eventQueue();
    while (connected) {
        try {
            EventSet eventSet = queue.remove();
            boolean resumeStoppedApp = false;
            EventIterator it = eventSet.eventIterator();
            while (it.hasNext()) {
                resumeStoppedApp |= !handleEvent(it.nextEvent());
            }

            if (resumeStoppedApp) {
                eventSet.resume();
            } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
                setCurrentThread(eventSet);
                notifier.vmInterrupted();
            }
        } catch (InterruptedException exc) {
            // Do nothing. Any changes will be seen at top of loop.
        } catch (VMDisconnectedException discExc) {
            handleDisconnectedException();
            break;
        }
    }
    synchronized (this) {
        completed = true;
        notifyAll();
    }
}
 
Example #28
Source File: EventHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    EventQueue queue = Env.vm().eventQueue();
    while (connected) {
        try {
            EventSet eventSet = queue.remove();
            boolean resumeStoppedApp = false;
            EventIterator it = eventSet.eventIterator();
            while (it.hasNext()) {
                resumeStoppedApp |= !handleEvent(it.nextEvent());
            }

            if (resumeStoppedApp) {
                eventSet.resume();
            } else if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL) {
                setCurrentThread(eventSet);
                notifier.vmInterrupted();
            }
        } catch (InterruptedException exc) {
            // Do nothing. Any changes will be seen at top of loop.
        } catch (VMDisconnectedException discExc) {
            handleDisconnectedException();
            break;
        }
    }
    synchronized (this) {
        completed = true;
        notifyAll();
    }
}
 
Example #29
Source File: ModificationWatchpointSpec.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The 'refType' is known to match, return the EventRequest.
 */
@Override
EventRequest resolveEventRequest(ReferenceType refType)
                                  throws NoSuchFieldException {
    Field field = refType.fieldByName(fieldId);
    EventRequestManager em = refType.virtualMachine().eventRequestManager();
    EventRequest wp = em.createModificationWatchpointRequest(field);
    wp.setSuspendPolicy(suspendPolicy);
    wp.enable();
    return wp;
}
 
Example #30
Source File: EventRequestSpec.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return If this EventRequestSpec matches the 'refType'
 * return the cooresponding EventRequest.  Otherwise
 * return null.
 */
synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception {
    if ((resolved == null) &&
        (prepareRequest != null) &&
        prepareRequest.equals(event.request())) {

        resolved = resolveEventRequest(event.referenceType());
        prepareRequest.disable();
        Env.vm().eventRequestManager().deleteEventRequest(prepareRequest);
        prepareRequest = null;

        if (refSpec instanceof PatternReferenceTypeSpec) {
            PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec;
            if (! prs.isUnique()){
                /*
                 * Class pattern event requests are never
                 * considered "resolved", since future class loads
                 * might also match.
                 * Create and enable a new ClassPrepareRequest to
                 * keep trying to resolve.
                 */
                resolved = null;
                prepareRequest = refSpec.createPrepareRequest();
                prepareRequest.enable();
            }
        }
    }
    return resolved;
}