Search in sources :

Example 6 with BreakpointRequest

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

the class VMTargetStarter method installHaltPoint.

private void installHaltPoint(VirtualMachine vm) {
    List<ReferenceType> targetClasses = vm.classesByName(VMLocalTarget.class.getName());
    ReferenceType classRef = targetClasses.get(0);
    Method meth = classRef.methodsByName("haltPoint").get(0);
    BreakpointRequest req = vm.eventRequestManager().createBreakpointRequest(meth.location());
    req.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
    req.enable();
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) Method(com.sun.jdi.Method) ReferenceType(com.sun.jdi.ReferenceType)

Example 7 with BreakpointRequest

use of com.sun.jdi.request.BreakpointRequest 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 8 with BreakpointRequest

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

the class VirtualMachineImpl method redefineClasses.

public void redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes) {
    int cnt = classToBytes.size();
    JDWP.VirtualMachine.RedefineClasses.ClassDef[] defs = new JDWP.VirtualMachine.RedefineClasses.ClassDef[cnt];
    validateVM();
    if (!canRedefineClasses()) {
        throw new UnsupportedOperationException();
    }
    Iterator<?> it = classToBytes.entrySet().iterator();
    for (int i = 0; it.hasNext(); i++) {
        Map.Entry<?, ?> entry = (Map.Entry) it.next();
        ReferenceTypeImpl refType = (ReferenceTypeImpl) entry.getKey();
        validateMirror(refType);
        defs[i] = new JDWP.VirtualMachine.RedefineClasses.ClassDef(refType, (byte[]) entry.getValue());
    }
    // flush caches and disable caching until the next suspend
    vm.state().thaw();
    try {
        JDWP.VirtualMachine.RedefineClasses.process(vm, defs);
    } catch (JDWPException exc) {
        switch(exc.errorCode()) {
            case JDWP.Error.INVALID_CLASS_FORMAT:
                throw new ClassFormatError("class not in class file format");
            case JDWP.Error.CIRCULAR_CLASS_DEFINITION:
                throw new ClassCircularityError("circularity has been detected while initializing a class");
            case JDWP.Error.FAILS_VERIFICATION:
                throw new VerifyError("verifier detected internal inconsistency or security problem");
            case JDWP.Error.UNSUPPORTED_VERSION:
                throw new UnsupportedClassVersionError("version numbers of class are not supported");
            case JDWP.Error.ADD_METHOD_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("add method not implemented");
            case JDWP.Error.SCHEMA_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("schema change not implemented");
            case JDWP.Error.HIERARCHY_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("hierarchy change not implemented");
            case JDWP.Error.DELETE_METHOD_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("delete method not implemented");
            case JDWP.Error.CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("changes to class modifiers not implemented");
            case JDWP.Error.METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("changes to method modifiers not implemented");
            case JDWP.Error.NAMES_DONT_MATCH:
                throw new NoClassDefFoundError("class names do not match");
            default:
                throw exc.toJDIException();
        }
    }
    // Delete any record of the breakpoints
    List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
    EventRequestManager erm = eventRequestManager();
    it = erm.breakpointRequests().iterator();
    while (it.hasNext()) {
        BreakpointRequest req = (BreakpointRequest) it.next();
        if (classToBytes.containsKey(req.location().declaringType())) {
            toDelete.add(req);
        }
    }
    erm.deleteEventRequests(toDelete);
    // Invalidate any information cached for the classes just redefined.
    it = classToBytes.keySet().iterator();
    while (it.hasNext()) {
        ReferenceTypeImpl rti = (ReferenceTypeImpl) it.next();
        rti.noticeRedefineClass();
    }
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Aggregations

BreakpointRequest (com.sun.jdi.request.BreakpointRequest)8 EventRequestManager (com.sun.jdi.request.EventRequestManager)4 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)3 Location (com.sun.jdi.Location)2 Method (com.sun.jdi.Method)2 ReferenceType (com.sun.jdi.ReferenceType)2 ArrayList (java.util.ArrayList)2 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)2 AbsentInformationException (com.sun.jdi.AbsentInformationException)1 ClassNotPreparedException (com.sun.jdi.ClassNotPreparedException)1 NativeMethodException (com.sun.jdi.NativeMethodException)1 VMCannotBeModifiedException (com.sun.jdi.VMCannotBeModifiedException)1 EventRequest (com.sun.jdi.request.EventRequest)1 InvalidRequestStateException (com.sun.jdi.request.InvalidRequestStateException)1 BreakpointDto (org.eclipse.che.api.debug.shared.dto.BreakpointDto)1 Location (org.eclipse.che.api.debug.shared.model.Location)1 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)1 BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)1 DebuggerAbsentInformationException (org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException)1 ExpressionParser (org.eclipse.che.plugin.jdb.server.expression.ExpressionParser)1