Search in sources :

Example 1 with ClassPrepareRequest

use of com.sun.jdi.request.ClassPrepareRequest in project che by eclipse.

the class JavaDebugger method deferBreakpoint.

private void deferBreakpoint(Breakpoint breakpoint) throws DebuggerException {
    final String className = breakpoint.getLocation().getTarget();
    List<Breakpoint> newList = new ArrayList<>();
    List<Breakpoint> list = deferredBreakpoints.putIfAbsent(className, newList);
    if (list == null) {
        list = newList;
    }
    list.add(breakpoint);
    // start listening for the load of the type
    if (!classPrepareRequests.containsKey(className)) {
        ClassPrepareRequest request = getEventManager().createClassPrepareRequest();
        // set class filter in order to reduce the amount of event traffic sent from the target VM to the debugger VM
        request.addClassFilter(className);
        request.enable();
        classPrepareRequests.put(className, request);
    }
    LOG.debug("Deferred breakpoint: {}", breakpoint.getLocation().toString());
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) ArrayList(java.util.ArrayList) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 2 with ClassPrepareRequest

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

the class PatternReferenceTypeSpec method createPrepareRequest.

@Override
public ClassPrepareRequest createPrepareRequest() {
    ClassPrepareRequest request = Env.vm().eventRequestManager().createClassPrepareRequest();
    request.addClassFilter(classId);
    request.addCountFilter(1);
    return request;
}
Also used : ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 3 with ClassPrepareRequest

use of com.sun.jdi.request.ClassPrepareRequest in project che by eclipse.

the class JavaDebugger method processClassPrepareEvent.

private boolean processClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent event) throws DebuggerException {
    setCurrentThread(event.thread());
    final String className = event.referenceType().name();
    // add deferred breakpoints
    List<Breakpoint> breakpointsToAdd = deferredBreakpoints.get(className);
    if (breakpointsToAdd != null) {
        for (Breakpoint b : breakpointsToAdd) {
            addBreakpoint(b);
        }
        deferredBreakpoints.remove(className);
        // All deferred breakpoints for className have been already added,
        // so no need to listen for an appropriate ClassPrepareRequests any more.
        ClassPrepareRequest request = classPrepareRequests.remove(className);
        if (request != null) {
            getEventManager().deleteEventRequest(request);
        }
    }
    return true;
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 4 with ClassPrepareRequest

use of com.sun.jdi.request.ClassPrepareRequest in project gravel by gravel-st.

the class VMTargetStarter method createJVM.

public VMRemoteTarget createJVM() throws IOException, InterruptedException, IncompatibleThreadStateException {
    Process process = startSecondJVM(VMLocalTarget.class);
    sleep(90);
    // connect
    VirtualMachine vm = new VMAcquirer().connect(debugPort);
    ClassPrepareRequest createClassPrepareRequest = vm.eventRequestManager().createClassPrepareRequest();
    createClassPrepareRequest.addClassFilter(VMLocalTarget.class.getName());
    createClassPrepareRequest.enable();
    vm.resume();
    List<ThreadReference> allThreads = vm.allThreads();
    for (ThreadReference threadReference : allThreads) {
        System.out.println(threadReference + " isSuspended: " + threadReference.isSuspended() + " suspendCount: " + threadReference.suspendCount());
    }
    // process events
    EventQueue eventQueue = vm.eventQueue();
    while (true) {
        EventSet eventSet = eventQueue.remove();
        for (Event event : eventSet) {
            if (event instanceof ClassPrepareEvent) {
                event.request().disable();
                installHaltPoint(vm);
            }
            if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
                return null;
            }
            if (event instanceof BreakpointEvent) {
                event.request().disable();
                ThreadReference thread = ((BreakpointEvent) event).thread();
                return new VMRemoteTarget(process, vm, thread, debugPort);
            }
        }
        eventSet.resume();
    }
}
Also used : VMDeathEvent(com.sun.jdi.event.VMDeathEvent) EventSet(com.sun.jdi.event.EventSet) ThreadReference(com.sun.jdi.ThreadReference) EventQueue(com.sun.jdi.event.EventQueue) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest) BreakpointEvent(com.sun.jdi.event.BreakpointEvent) ClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) BreakpointEvent(com.sun.jdi.event.BreakpointEvent) ClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) VirtualMachine(com.sun.jdi.VirtualMachine)

Example 5 with ClassPrepareRequest

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

the class MethodBreakpoint method createRequestForSubClasses.

private static void createRequestForSubClasses(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType baseType) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
    ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
        if (instanceOf(referenceType, baseType)) {
            createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
        }
    }, null);
    if (request != null) {
        requestsManager.registerRequest(breakpoint, request);
        request.enable();
        // to force reload classes available so far
        debugProcess.getVirtualMachineProxy().clearCaches();
    }
    AtomicReference<ProgressIndicator> indicatorRef = new AtomicReference<>();
    ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, false, debugProcess.getProject(), "Cancel emulation")));
    ProgressIndicator indicator = indicatorRef.get();
    ProgressManager.getInstance().executeProcessUnderProgress(() -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(breakpoint, debugProcess, subType, false), indicator), indicator);
    if (indicator.isCanceled()) {
        breakpoint.disableEmulation();
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) JVMNameUtil(com.intellij.debugger.engine.JVMNameUtil) AllIcons(com.intellij.icons.AllIcons) Document(com.intellij.openapi.editor.Document) Opcodes(org.jetbrains.org.objectweb.asm.Opcodes) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx) EventRequest(com.sun.jdi.request.EventRequest) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) StringBuilderSpinAllocator(com.intellij.util.StringBuilderSpinAllocator) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) Logger(com.intellij.openapi.diagnostic.Logger) MultiMap(com.intellij.util.containers.MultiMap) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) DebuggerManagerThreadImpl(com.intellij.debugger.engine.DebuggerManagerThreadImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ProgressManager(com.intellij.openapi.progress.ProgressManager) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) MethodExitRequest(com.sun.jdi.request.MethodExitRequest) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) PositionUtil(com.intellij.debugger.impl.PositionUtil) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) Stream(java.util.stream.Stream) StreamEx(one.util.streamex.StreamEx) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Requestor(com.intellij.debugger.requests.Requestor) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) SourcePosition(com.intellij.debugger.SourcePosition) LocatableEvent(com.sun.jdi.event.LocatableEvent) Label(org.jetbrains.org.objectweb.asm.Label) NonNls(org.jetbrains.annotations.NonNls) MethodBytecodeUtil(com.intellij.debugger.jdi.MethodBytecodeUtil) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) JavaMethodBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties) MethodVisitor(org.jetbrains.org.objectweb.asm.MethodVisitor) JVMName(com.intellij.debugger.engine.JVMName) Consumer(java.util.function.Consumer) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) com.sun.jdi(com.sun.jdi) Element(org.jdom.Element) javax.swing(javax.swing) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) AtomicReference(java.util.concurrent.atomic.AtomicReference) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Aggregations

ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)5 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1 SourcePosition (com.intellij.debugger.SourcePosition)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 DebuggerManagerThreadImpl (com.intellij.debugger.engine.DebuggerManagerThreadImpl)1 JVMName (com.intellij.debugger.engine.JVMName)1 JVMNameUtil (com.intellij.debugger.engine.JVMNameUtil)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)1 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)1 DebuggerUtilsEx (com.intellij.debugger.impl.DebuggerUtilsEx)1 PositionUtil (com.intellij.debugger.impl.PositionUtil)1 MethodBytecodeUtil (com.intellij.debugger.jdi.MethodBytecodeUtil)1 Requestor (com.intellij.debugger.requests.Requestor)1 AllIcons (com.intellij.icons.AllIcons)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Document (com.intellij.openapi.editor.Document)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1