Search in sources :

Example 6 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project intellij-community by JetBrains.

the class DebugProcessImpl method deleteStepRequests.

void deleteStepRequests(@Nullable final ThreadReference stepThread) {
    EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager();
    List<StepRequest> stepRequests = requestManager.stepRequests();
    if (!stepRequests.isEmpty()) {
        final List<StepRequest> toDelete = new ArrayList<>(stepRequests.size());
        for (final StepRequest request : stepRequests) {
            ThreadReference threadReference = request.thread();
            // [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occurs
            try {
                if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) {
                    toDelete.add(request);
                }
            } catch (IllegalThreadStateException e) {
                // undocumented by JDI: may be thrown when querying thread status
                LOG.info(e);
            } catch (ObjectCollectedException ignored) {
            }
        }
        requestManager.deleteEventRequests(toDelete);
    }
}
Also used : StepRequest(com.sun.jdi.request.StepRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Example 7 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project jdk8u_jdk by JetBrains.

the class ModificationWatchpointSpec method resolveEventRequest.

/**
     * 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;
}
Also used : EventRequest(com.sun.jdi.request.EventRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Example 8 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project jdk8u_jdk by JetBrains.

the class VMConnection method setEventRequests.

private void setEventRequests(VirtualMachine vm) {
    EventRequestManager erm = vm.eventRequestManager();
    // Normally, we want all uncaught exceptions.  We request them
    // via the same mechanism as Commands.commandCatchException()
    // so the user can ignore them later if they are not
    // interested.
    // FIXME: this works but generates spurious messages on stdout
    //        during startup:
    //          Set uncaught java.lang.Throwable
    //          Set deferred uncaught java.lang.Throwable
    Commands evaluator = new Commands();
    evaluator.commandCatchException(new StringTokenizer("uncaught java.lang.Throwable"));
    ThreadStartRequest tsr = erm.createThreadStartRequest();
    tsr.enable();
    ThreadDeathRequest tdr = erm.createThreadDeathRequest();
    tdr.enable();
}
Also used : ThreadStartRequest(com.sun.jdi.request.ThreadStartRequest) ThreadDeathRequest(com.sun.jdi.request.ThreadDeathRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Example 9 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project otertool by wuntee.

the class Testing method addIntentBreakpoints.

@SuppressWarnings("restriction")
public static void addIntentBreakpoints(VirtualMachine vm) {
    EventRequestManager mgr = vm.eventRequestManager();
    com.sun.jdi.ReferenceType intentClass = vm.classesByName("android.content.Intent").get(0);
    for (Method m : intentClass.methodsByName("<init>")) {
        System.out.println("Breakpoint: " + m.toString());
        Location location = m.location();
        BreakpointRequest bpr = mgr.createBreakpointRequest(location);
        bpr.enable();
    }
    for (Method m : intentClass.methodsByName("putExtra")) {
        System.out.println("Breakpoint: " + m.toString());
        Location location = m.location();
        BreakpointRequest bpr = mgr.createBreakpointRequest(location);
        bpr.enable();
    }
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) Method(com.sun.jdi.Method) EventRequestManager(com.sun.jdi.request.EventRequestManager) Location(com.sun.jdi.Location)

Example 10 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project intellij-community by JetBrains.

the class DebugProcessEvents method vmAttached.

private void vmAttached() {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    LOG.assertTrue(!isAttached());
    if (myState.compareAndSet(State.INITIAL, State.ATTACHED)) {
        final VirtualMachineProxyImpl machineProxy = getVirtualMachineProxy();
        final EventRequestManager requestManager = machineProxy.eventRequestManager();
        if (machineProxy.canGetMethodReturnValues()) {
            myReturnValueWatcher = new MethodReturnValueWatcher(requestManager);
        }
        final ThreadStartRequest threadStartRequest = requestManager.createThreadStartRequest();
        threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
        threadStartRequest.enable();
        final ThreadDeathRequest threadDeathRequest = requestManager.createThreadDeathRequest();
        threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
        threadDeathRequest.enable();
        // fill position managers
        ((DebuggerManagerImpl) DebuggerManager.getInstance(getProject())).getCustomPositionManagerFactories().map(factory -> factory.fun(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
        Stream.of(Extensions.getExtensions(PositionManagerFactory.EP_NAME, getProject())).map(factory -> factory.createPositionManager(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
        myDebugProcessDispatcher.getMulticaster().processAttached(this);
        createStackCapturingBreakpoints();
        // breakpoints should be initialized after all processAttached listeners work
        ApplicationManager.getApplication().runReadAction(() -> {
            XDebugSession session = getSession().getXDebugSession();
            if (session != null) {
                session.initBreakpoints();
            }
        });
        final String addressDisplayName = DebuggerBundle.getAddressDisplayName(getConnection());
        final String transportName = DebuggerBundle.getTransportName(getConnection());
        showStatusText(DebuggerBundle.message("status.connected", addressDisplayName, transportName));
        LOG.debug("leave: processVMStartEvent()");
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) ThreadStartRequest(com.sun.jdi.request.ThreadStartRequest) ThreadDeathRequest(com.sun.jdi.request.ThreadDeathRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager) MethodReturnValueWatcher(com.intellij.debugger.engine.requests.MethodReturnValueWatcher)

Aggregations

EventRequestManager (com.sun.jdi.request.EventRequestManager)11 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)4 EventRequest (com.sun.jdi.request.EventRequest)3 MethodReturnValueWatcher (com.intellij.debugger.engine.requests.MethodReturnValueWatcher)2 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 AbsentInformationException (com.sun.jdi.AbsentInformationException)2 StepRequest (com.sun.jdi.request.StepRequest)2 IOException (java.io.IOException)2 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)1 com.intellij.debugger.impl (com.intellij.debugger.impl)1