Search in sources :

Example 1 with FieldRef

use of com.oracle.truffle.espresso.jdwp.api.FieldRef in project graal by oracle.

the class RequestedJDWPEvents method handleModKind.

private void handleModKind(RequestFilter filter, PacketStream input, byte modKind, JDWPContext context) {
    switch(modKind) {
        case 1:
            int count = input.readInt();
            JDWP.LOGGER.fine(() -> "adding count limit: " + count + " to filter");
            filter.addEventCount(count);
            break;
        case 2:
            JDWP.LOGGER.fine(() -> "unhandled modKind 2");
            break;
        case // limit to specific thread
        3:
            long threadId = input.readLong();
            Object thread = ids.fromId((int) threadId);
            filter.addThread(thread);
            JDWP.LOGGER.fine(() -> "limiting to thread: " + context.getThreadName(thread));
            break;
        case 4:
            long refTypeId = input.readLong();
            final KlassRef finalKlass = (KlassRef) ids.fromId((int) refTypeId);
            filter.addRefTypeLimit(finalKlass);
            JDWP.LOGGER.fine(() -> "RefType limit: " + finalKlass);
            break;
        case // class positive pattern
        5:
            String classPattern = Pattern.quote(input.readString()).replace("*", "\\E.*\\Q");
            try {
                Pattern pattern = Pattern.compile(classPattern);
                filter.addPositivePattern(pattern);
                JDWP.LOGGER.fine(() -> "adding positive refType pattern: " + pattern.pattern());
            } catch (PatternSyntaxException ex) {
                // wrong input pattern
                throw new RuntimeException("should not reach here");
            }
            break;
        case 6:
            classPattern = Pattern.quote(input.readString()).replace("*", "\\E.*\\Q");
            try {
                Pattern pattern = Pattern.compile(classPattern);
                filter.addExcludePattern(pattern);
                JDWP.LOGGER.fine(() -> "adding negative refType pattern: " + pattern.pattern());
            } catch (PatternSyntaxException ex) {
                // wrong input pattern
                throw new RuntimeException("should not reach here");
            }
            break;
        case // location-specific
        7:
            byte typeTag = input.readByte();
            long classId = input.readLong();
            long methodId = input.readLong();
            long bci = input.readLong();
            final KlassRef finalKlass2 = (KlassRef) ids.fromId((int) classId);
            String slashName = finalKlass2.getTypeAsString();
            MethodRef method = (MethodRef) ids.fromId((int) methodId);
            int line = method.bciToLineNumber((int) bci);
            LineBreakpointInfo info = new LineBreakpointInfo(filter, typeTag, classId, methodId, bci, slashName, line);
            filter.addBreakpointInfo(info);
            JDWP.LOGGER.fine(() -> "Adding breakpoint info for location: " + finalKlass2.getNameAsString() + "." + method.getNameAsString() + "." + line);
            break;
        case 8:
            refTypeId = input.readLong();
            KlassRef klass = null;
            if (refTypeId != 0) {
                klass = (KlassRef) ids.fromId((int) refTypeId);
            }
            boolean caught = input.readBoolean();
            boolean unCaught = input.readBoolean();
            ExceptionBreakpointInfo exceptionBreakpointInfo = new ExceptionBreakpointInfo(filter, klass, caught, unCaught);
            filter.addBreakpointInfo(exceptionBreakpointInfo);
            JDWP.LOGGER.fine(() -> "adding exception filter: caught=" + caught + ", uncaught=" + unCaught);
            break;
        case // limit to specific field
        9:
            refTypeId = input.readLong();
            long fieldId = input.readLong();
            klass = (KlassRef) ids.fromId((int) refTypeId);
            FieldRef field = (FieldRef) ids.fromId((int) fieldId);
            FieldBreakpointInfo fieldBreakpointInfo = new FieldBreakpointInfo(filter, klass, field);
            filter.addBreakpointInfo(fieldBreakpointInfo);
            JDWP.LOGGER.fine(() -> "limiting to field: " + field.getNameAsString());
            break;
        case 10:
            threadId = input.readLong();
            thread = ids.fromId((int) threadId);
            int size = input.readInt();
            int depth = input.readInt();
            StepInfo stepInfo = new StepInfo(size, depth, thread);
            filter.setStepInfo(stepInfo);
            JDWP.LOGGER.fine(() -> "Step command: size= " + size + ", depth=" + depth);
            break;
        case 11:
            long thisId = input.readLong();
            JDWP.LOGGER.fine(() -> "adding instance filter for object ID: " + thisId);
            filter.addThisFilterId(thisId);
            break;
        case 12:
            JDWP.LOGGER.fine(() -> "unhandled modKind 12");
            break;
        default:
            break;
    }
}
Also used : Pattern(java.util.regex.Pattern) FieldRef(com.oracle.truffle.espresso.jdwp.api.FieldRef) MethodRef(com.oracle.truffle.espresso.jdwp.api.MethodRef) KlassRef(com.oracle.truffle.espresso.jdwp.api.KlassRef) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Aggregations

FieldRef (com.oracle.truffle.espresso.jdwp.api.FieldRef)1 KlassRef (com.oracle.truffle.espresso.jdwp.api.KlassRef)1 MethodRef (com.oracle.truffle.espresso.jdwp.api.MethodRef)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1