Package org.apache.harmony.jpda.tests.framework.jdwp

Examples of org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket


        if ( combinedEventsLocation == null ) {
            String failureMessage = "## FAILURE: Can NOT get MethodEntryLocation for method '"
                + methodForEvents + "'";
            printErrorAndFail(failureMessage);
        }
        ReplyPacket reply = debuggeeWrapper.vmMirror.setBreakpoint(combinedEventsLocation);
        int breakpointRequestID = reply.getNextValueAsInt();
        logWriter.println("=> Breakpoint requestID = " + breakpointRequestID);


        logWriter.println("=> Set request for METHOD_ENTRY event in debuggee: "
                + getDebuggeeClassName() + ", method: " + methodForEvents);
        reply = debuggeeWrapper.vmMirror
                .setMethodEntry(methodEntryClassNameRegexp);
        checkReplyPacket(reply, "Set METHOD_ENTRY event");
        int methodEntryRequestID = reply.getNextValueAsInt();
        logWriter.println("=> METHOD_ENTRY requestID = " + methodEntryRequestID);

        logWriter.println("");
//        logWriter.println("=> Resume debuggee");
//        debuggeeWrapper.vmMirror.resume();
        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);

        // receive and check combined METHOD_ENTRY, BREAKPOINT events
        logWriter
                .println("=> Try to receive and check combined events: METHOD_ENTRY, BREAKPOINT events");
        EventPacket event = debuggeeWrapper.vmMirror.receiveEvent();
        ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
        // print all received events
        logWriter.println("=> Events received: " + parsedEvents.length);
        for (int i = 0; i < parsedEvents.length; i++) {
            logWriter.println("");
            logWriter.println("=> Event #" + i + ";");
            logWriter.println("=> EventKind: "
                    + parsedEvents[i].getEventKind()
                    + "["
                    + JDWPConstants.EventKind.getName(parsedEvents[i]
                            .getEventKind()) + "]");
            logWriter
                    .println("=> RequestID: " + parsedEvents[i].getRequestID());
        }
        boolean success = true;
        boolean locationsOK = checkEventsLocation(parsedEvents, combinedEventsLocation);
        if (parsedEvents.length == EXPECTED_EVENTS_COUNT) {
            logWriter.println("");
            logWriter
                    .println("=> Combined events are received. Check events..");
            for (int i = 0; i < parsedEvents.length; i++) {
                boolean isFound = false;
                for (int j = 0; j < EXPECTED_EVENTS_COUNT; j++) {
                    if (parsedEvents[i].getEventKind() == EXPECTED_EVENTS_ARRAY[j]) {
                        EXPECTED_EVENTS_ARRAY[j] = 0;
                        isFound = true;
                        break;
                    }
                }
                if (!isFound) {
                    logWriter
                            .println("##FAILURE: received unexpected event: "
                                    + parsedEvents[i].getEventKind()
                                    + "["
                                    + JDWPConstants.EventKind
                                            .getName(parsedEvents[0]
                                                    .getEventKind()) + "]");
                    success = false;
                }
            }
            if (!success) {
                logWriter.println("");
                logWriter
                        .println("##FAILURE: the following events were not received: ");
                for (int k = 0; k < EXPECTED_EVENTS_COUNT; k++) {
                    if (EXPECTED_EVENTS_ARRAY[k] != 0)
                        logWriter.println("  #"
                                + k
                                + ": "
                                + EXPECTED_EVENTS_ARRAY[k]
                                + "["
                                + JDWPConstants.EventKind
                                        .getName(EXPECTED_EVENTS_ARRAY[k])
                                + "]");
                }
                //DBG__fail("not all expected events were received");
            }
        } else {
            logWriter.println("##FAILURE: received unexpected number of events: "
                    + parsedEvents.length
                    + " instead of "
                    + EXPECTED_EVENTS_COUNT);
            //DBG__fail("received unexpected number of events: " + parsedEvents.length);
               
        }
        if ( (! success) || (! locationsOK) ) {
            String failureMessage = "## FAILURE during checking events! !";
            //DBG__printErrorAndFail(failureMessage);
        }
        logWriter.println("");
        logWriter.println("=> Clean request for METHOD_ENTRY event...");
        ReplyPacket clearReply = debuggeeWrapper.vmMirror.clearEvent(
                JDWPConstants.EventKind.METHOD_ENTRY, methodEntryRequestID);
        checkReplyPacket(clearReply, "EventRequest::Clear");

        logWriter.println("=> Resume debuggee");
        debuggeeWrapper.vmMirror.resume();
View Full Code Here


        if ( combinedEventsLocation == null ) {
            String failureMessage = "## FAILURE: Can NOT get MethodEndLocation for method '"
                + methodForEvents + "'";
            printErrorAndFail(failureMessage);
        }
        ReplyPacket reply = debuggeeWrapper.vmMirror.setBreakpoint(combinedEventsLocation);
        int breakpointRequestID = reply.getNextValueAsInt();
        logWriter.println("=> Breakpoint requestID = " + breakpointRequestID);


        logWriter.println("=> Set request for METHOD_EXIT event in debuggee: "
                + getDebuggeeClassName() + ", method: " + methodForEvents);
        reply = debuggeeWrapper.vmMirror
                .setMethodExit(methodEntryClassNameRegexp);
        checkReplyPacket(reply, "Set METHOD_EXIT event");
        int methodExitRequestID = reply.getNextValueAsInt();
        logWriter.println("=> METHOD_EXIT requestID = " + methodExitRequestID);

        logWriter.println("");
        logWriter.println("Send SGNL_CONTINUE signal to debuggee...");
        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);

        // receive and check combined METHOD_EXIT, BREAKPOINT events
        logWriter
                .println("=> Try to receive and check combined events: METHOD_EXIT, BREAKPOINT events");
        EventPacket event = debuggeeWrapper.vmMirror.receiveEvent();
        ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
        // print all received events
        logWriter.println("=> Events received: " + parsedEvents.length);
        for (int i = 0; i < parsedEvents.length; i++) {
            logWriter.println("");
            logWriter.println("=> Event #" + i + ";");
            logWriter.println("=> EventKind: "
                    + parsedEvents[i].getEventKind()
                    + "["
                    + JDWPConstants.EventKind.getName(parsedEvents[i]
                            .getEventKind()) + "]");
            logWriter
                    .println("=> RequestID: " + parsedEvents[i].getRequestID());
            if ( parsedEvents[i].getEventKind() == JDWPConstants.EventKind.METHOD_EXIT ) {
                eventMethodExitReceived = true;
            }
        }
        boolean success = true;
        boolean locationsOK = checkEventsLocation(parsedEvents, combinedEventsLocation);
        if (parsedEvents.length == EXPECTED_EVENTS_COUNT) {
            logWriter.println("");
            logWriter
                    .println("=> Combined events are received. Check events..");
            for (int i = 0; i < parsedEvents.length; i++) {
                boolean isFound = false;
                for (int j = 0; j < EXPECTED_EVENTS_COUNT; j++) {
                    if (parsedEvents[i].getEventKind() == EXPECTED_EVENTS_ARRAY[j]) {
                        EXPECTED_EVENTS_ARRAY[j] = 0;
                        isFound = true;
                        break;
                    }
                }
                if (!isFound) {
                    logWriter
                            .println("##FAILURE: received unexpected event: "
                                    + parsedEvents[i].getEventKind()
                                    + "["
                                    + JDWPConstants.EventKind
                                            .getName(parsedEvents[0]
                                                    .getEventKind()) + "]");
                    success = false;
                }
            }
            if (!success) {
                logWriter.println("");
                logWriter
                        .println("##FAILURE: the following events were not received: ");
                for (int k = 0; k < EXPECTED_EVENTS_COUNT; k++) {
                    if (EXPECTED_EVENTS_ARRAY[k] != 0)
                        logWriter.println("  #"
                                + k
                                + ": "
                                + EXPECTED_EVENTS_ARRAY[k]
                                + "["
                                + JDWPConstants.EventKind
                                        .getName(EXPECTED_EVENTS_ARRAY[k])
                                + "]");
                }
                //DBG__fail("not all expected events were received");
            }
        } else {
            logWriter.println("##FAILURE: received unexpected number of events: "
                    + parsedEvents.length
                    + " instead of "
                    + EXPECTED_EVENTS_COUNT);
            //DBG__fail("received unexpected number of events: " + parsedEvents.length);
               
        }
        if ( (! success) || (! locationsOK) ) {
            String failureMessage = "## FAILURE during checking events !";
            //DBG__printErrorAndFail(failureMessage);
        }
        if ( eventMethodExitReceived ) {
            logWriter.println("");
            logWriter.println("=> Clean request for METHOD_EXIT event...");
            ReplyPacket clearReply = debuggeeWrapper.vmMirror.clearEvent(
                    JDWPConstants.EventKind.METHOD_EXIT, methodExitRequestID);
            checkReplyPacket(clearReply, "EventRequest::Clear");
        }

        logWriter.println("=> Resume debuggee");
View Full Code Here

        CommandPacket packet = new CommandPacket(
                JDWPCommands.MethodCommandSet.CommandSetID,
                JDWPCommands.MethodCommandSet.LineTableCommand);
        packet.setNextValueAsClassID(classID);
        packet.setNextValueAsMethodID(methodID);
        ReplyPacket lineTableReply = debuggeeWrapper.vmMirror.performCommand(packet);
        if ( ! checkReplyPacketWithoutFail(lineTableReply,  "printMethodLineTable(): Method.LineTable command") ) {
            return;
        }
        if ( className == null ) {
            logWriter.println("=== Line Table for method: " + methodName + " ===");
        } else {
            logWriter.println("=== Line Table for method: " + methodName + " of class: "
                    + className + " ===");
        }
        long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
        logWriter.println("==> Method Start Code Index = " + methodStartCodeIndex);
        long methodEndCodeIndex = lineTableReply.getNextValueAsLong();
        logWriter.println("==> Method End Code Index = " + methodEndCodeIndex);
       
        int linesNumber = lineTableReply.getNextValueAsInt();
        logWriter.println("==> Number of lines = " + linesNumber);
        for (int i=0; i < linesNumber; i++) {
            long lineCodeIndex = lineTableReply.getNextValueAsLong();
            int lineNumber = lineTableReply.getNextValueAsInt();
            logWriter.println("====> Line Number " + lineNumber + " : Initial code index = " + lineCodeIndex);
        }
        logWriter.println("=== End of Line Table " + methodName + " ===");
    }
View Full Code Here

        CommandPacket packet = new CommandPacket(
                JDWPCommands.MethodCommandSet.CommandSetID,
                JDWPCommands.MethodCommandSet.LineTableCommand);
        packet.setNextValueAsClassID(classID);
        packet.setNextValueAsMethodID(methodID);
        ReplyPacket lineTableReply = debuggeeWrapper.vmMirror.performCommand(packet);
        if ( ! checkReplyPacketWithoutFail
                (lineTableReply,  "getMethodStartCodeIndex(): Method.LineTable command") ) {
            return -1;
        }
        long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
        return methodStartCodeIndex;
    }
View Full Code Here

        CommandPacket packet = new CommandPacket(
                JDWPCommands.MethodCommandSet.CommandSetID,
                JDWPCommands.MethodCommandSet.LineTableCommand);
        packet.setNextValueAsClassID(classID);
        packet.setNextValueAsMethodID(methodID);
        ReplyPacket lineTableReply = debuggeeWrapper.vmMirror.performCommand(packet);
        if ( ! checkReplyPacketWithoutFail
                (lineTableReply,  "getMethodEndCodeIndex(): Method.LineTable command") ) {
            return -1;
        }
        long methodStartCodeIndex = lineTableReply.getNextValueAsLong();
        long methodEndCodeIndex = lineTableReply.getNextValueAsLong();
        return methodEndCodeIndex;
    }
View Full Code Here

        CommandPacket packet = new CommandPacket(
                JDWPCommands.MethodCommandSet.CommandSetID,
                JDWPCommands.MethodCommandSet.LineTableCommand);
        packet.setNextValueAsClassID(classID);
        packet.setNextValueAsMethodID(methodID);
        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
        if ( ! checkReplyPacketWithoutFail
                (reply,  "getMethodEntryLocation(): Method.LineTable command") ) {
            return null;
        }
        long methodStartCodeIndex = reply.getNextValueAsLong();
        Location location = new Location();
        location.tag = JDWPConstants.TypeTag.CLASS;
        location.classID =  classID;
        location.methodID = methodID;
        location.index = methodStartCodeIndex;
View Full Code Here

        CommandPacket packet = new CommandPacket(
                JDWPCommands.MethodCommandSet.CommandSetID,
                JDWPCommands.MethodCommandSet.LineTableCommand);
        packet.setNextValueAsClassID(classID);
        packet.setNextValueAsMethodID(methodID);
        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
        if ( ! checkReplyPacketWithoutFail
                (reply,  "getMethodEndLocation(): Method.LineTable command") ) {
            return null;
        }
        long methodStartCodeIndex = reply.getNextValueAsLong();
        long methodEndCodeIndex = reply.getNextValueAsLong();
        Location location = new Location();
        location.tag = JDWPConstants.TypeTag.CLASS;
        location.classID =  classID;
        location.methodID = methodID;
        location.index = methodEndCodeIndex;
View Full Code Here

                JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
                JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
        packet.setNextValueAsThreadID(threadID);
        packet.setNextValueAsInt(startFrame);
        packet.setNextValueAsInt(length);
        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
        err = reply.getErrorCode();
        if ( err != JDWPConstants.Error.NONE) {
            logWriter.println("\tthreadID=" + threadID
                    + " - " + JDWPConstants.Error.getName(err));
            return null;
        }
        int framesCount = reply.getNextValueAsInt();
        long frameID;
        Location loc;
        logWriter.println("framesCount=" + framesCount);
        for (int j = 0; j < framesCount; j++) {
               frameID = reply.getNextValueAsFrameID();
               loc = reply.getNextValueAsLocation();
               frames.add(new FrameStruct(frameID, loc));
           }
        return frames;
    }
View Full Code Here

        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

        String class2prepareRegexp = "org.apache.harmony.jpda.tests.jdwp.Events.Class2Prepare";
        String class2prepareSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/Class2Prepare;";
       
        ReplyPacket reply = debuggeeWrapper.vmMirror.setClassPrepared(class2prepareRegexp);
        checkReplyPacket(reply, "Set CLASS_PREPARE event");
       
        // start loading Class2Prepare class
        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
       
View Full Code Here

        logWriter.println("==> Send VirtualMachine::AllClassesWithGeneric command...");
        CommandPacket packet = new CommandPacket(
                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
                JDWPCommands.VirtualMachineCommandSet.AllClassesWithGenericCommand);
        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
        checkReplyPacket(reply, "VirtualMachine::AllClassesWithGeneric command");

        long typeID;  
        String signature, genericSignature;
        int status;

        int classes = reply.getNextValueAsInt();
        assertTrue(classes > 0);

        int count = 0;
        for (int i = 0; i < classes; i++) {

            reply.getNextValueAsByte();
            typeID = reply.getNextValueAsReferenceTypeID();
            signature = reply.getNextValueAsString();
            genericSignature = reply.getNextValueAsString();
            status = reply.getNextValueAsInt();

            if ( (status & JDWPConstants.ClassStatus.ARRAY) != 0 ){
                logWriter.println("## FAILURE: Unexpected status is returned:");
                logWriter.println("##          ReferenceTypeId = " + typeID);
                logWriter.println("##          Class signature: " + signature);
View Full Code Here

TOP

Related Classes of org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.