Search in sources :

Example 1 with MethodEntryRequest

use of com.sun.jdi.request.MethodEntryRequest in project HotswapAgent by HotswapProjects.

the class HotSwapperJpda method methodEntryRequests.

private static MethodEntryRequest methodEntryRequests(EventRequestManager manager, String classpattern) {
    MethodEntryRequest mereq = manager.createMethodEntryRequest();
    mereq.addClassFilter(classpattern);
    mereq.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
    return mereq;
}
Also used : MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest)

Example 2 with MethodEntryRequest

use of com.sun.jdi.request.MethodEntryRequest in project warn-report by saaavsaaa.

the class debugger method rTest.

@Test
public void rTest() throws Exception {
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    List<AttachingConnector> connectors = vmm.attachingConnectors();
    SocketAttachingConnector sac = null;
    for (AttachingConnector ac : connectors) {
        if (ac instanceof SocketAttachingConnector) {
            sac = (SocketAttachingConnector) ac;
            break;
        }
    }
    if (sac == null) {
        System.out.println("JDI error");
        return;
    }
    Map arguments = sac.defaultArguments();
    Connector.Argument hostArg = (Connector.Argument) arguments.get(HOST);
    Connector.Argument portArg = (Connector.Argument) arguments.get(PORT);
    hostArg.setValue("127.0.0.1");
    portArg.setValue(String.valueOf(9999));
    vm = sac.attach(arguments);
    List<ReferenceType> classesByName = vm.classesByName("cn.tellwhy.DailyTest");
    if (classesByName == null || classesByName.size() == 0) {
        System.out.println("No class found");
        return;
    }
    ReferenceType rt = classesByName.get(0);
    List<Method> methodsByName = rt.methodsByName("daily");
    if (methodsByName == null || methodsByName.size() == 0) {
        System.out.println("No method found");
        return;
    }
    Method method = methodsByName.get(0);
    vm.setDebugTraceMode(VirtualMachine.TRACE_EVENTS);
    vm.resume();
    EventRequestManager erm = vm.eventRequestManager();
    MethodEntryRequest methodEntryRequest = erm.createMethodEntryRequest();
    methodEntryRequest.addClassFilter(rt);
    methodEntryRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    methodEntryRequest.enable();
    BreakpointRequest breakpointRequest = erm.createBreakpointRequest(method.location());
    breakpointRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
    breakpointRequest.enable();
    eventLoop();
}
Also used : SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) AttachingConnector(com.sun.jdi.connect.AttachingConnector) Connector(com.sun.jdi.connect.Connector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) AttachingConnector(com.sun.jdi.connect.AttachingConnector) BreakpointRequest(com.sun.jdi.request.BreakpointRequest) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) Method(com.sun.jdi.Method) SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) EventRequestManager(com.sun.jdi.request.EventRequestManager) ReferenceType(com.sun.jdi.ReferenceType) VirtualMachineManager(com.sun.jdi.VirtualMachineManager) Map(java.util.Map) Test(org.junit.Test)

Example 3 with MethodEntryRequest

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

the class MethodBreakpoint method createRequestForPreparedClassOriginal.

private void createRequestForPreparedClassOriginal(@NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType) {
    try {
        boolean hasMethod = false;
        for (Method method : classType.allMethods()) {
            String signature = method.signature();
            String name = method.name();
            if (getMethodName().equals(name) && mySignature.getName(debugProcess).equals(signature)) {
                hasMethod = true;
                break;
            }
        }
        if (!hasMethod) {
            debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.method.not.found", classType.name()));
            return;
        }
        RequestManagerImpl requestManager = debugProcess.getRequestsManager();
        if (isWatchEntry()) {
            MethodEntryRequest entryRequest = findRequest(debugProcess, MethodEntryRequest.class, this);
            if (entryRequest == null) {
                entryRequest = requestManager.createMethodEntryRequest(this);
            } else {
                entryRequest.disable();
            }
            //entryRequest.addClassFilter(myClassQualifiedName);
            // use addClassFilter(ReferenceType) in order to stop on subclasses also!
            entryRequest.addClassFilter(classType);
            debugProcess.getRequestsManager().enableRequest(entryRequest);
        }
        if (isWatchExit()) {
            MethodExitRequest exitRequest = findRequest(debugProcess, MethodExitRequest.class, this);
            if (exitRequest == null) {
                exitRequest = requestManager.createMethodExitRequest(this);
            } else {
                exitRequest.disable();
            }
            //exitRequest.addClassFilter(myClassQualifiedName);
            exitRequest.addClassFilter(classType);
            debugProcess.getRequestsManager().enableRequest(exitRequest);
        }
    } catch (Exception e) {
        LOG.debug(e);
    }
}
Also used : MethodExitRequest(com.sun.jdi.request.MethodExitRequest) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException)

Example 4 with MethodEntryRequest

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

the class WildcardMethodBreakpoint method createRequest.

public void createRequest(DebugProcessImpl debugProcess) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    if (!shouldCreateRequest(debugProcess)) {
        return;
    }
    if (isEmulated()) {
        createOrWaitPrepare(debugProcess, getClassPattern());
    } else {
        try {
            RequestManagerImpl requestManager = debugProcess.getRequestsManager();
            if (isWatchEntry()) {
                MethodEntryRequest entryRequest = MethodBreakpoint.findRequest(debugProcess, MethodEntryRequest.class, this);
                if (entryRequest == null) {
                    entryRequest = requestManager.createMethodEntryRequest(this);
                } else {
                    entryRequest.disable();
                }
                entryRequest.addClassFilter(getClassPattern());
                debugProcess.getRequestsManager().enableRequest(entryRequest);
            }
            if (isWatchExit()) {
                MethodExitRequest exitRequest = MethodBreakpoint.findRequest(debugProcess, MethodExitRequest.class, this);
                if (exitRequest == null) {
                    exitRequest = requestManager.createMethodExitRequest(this);
                } else {
                    exitRequest.disable();
                }
                exitRequest.addClassFilter(getClassPattern());
                debugProcess.getRequestsManager().enableRequest(exitRequest);
            }
        } catch (Exception e) {
            LOG.debug(e);
        }
    }
}
Also used : MethodExitRequest(com.sun.jdi.request.MethodExitRequest) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) InvalidDataException(com.intellij.openapi.util.InvalidDataException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) PatternSyntaxException(java.util.regex.PatternSyntaxException) AbsentInformationException(com.sun.jdi.AbsentInformationException)

Aggregations

MethodEntryRequest (com.sun.jdi.request.MethodEntryRequest)4 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)2 MethodExitRequest (com.sun.jdi.request.MethodExitRequest)2 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 AbsentInformationException (com.sun.jdi.AbsentInformationException)1 Method (com.sun.jdi.Method)1 ReferenceType (com.sun.jdi.ReferenceType)1 VirtualMachineManager (com.sun.jdi.VirtualMachineManager)1 AttachingConnector (com.sun.jdi.connect.AttachingConnector)1 Connector (com.sun.jdi.connect.Connector)1 LaunchingConnector (com.sun.jdi.connect.LaunchingConnector)1 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)1 EventRequestManager (com.sun.jdi.request.EventRequestManager)1 SocketAttachingConnector (com.sun.tools.jdi.SocketAttachingConnector)1 Map (java.util.Map)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Test (org.junit.Test)1