test/hotspot/jtreg/vmTestbase/nsk/jdwp/Event/METHOD_ENTRY/methentry001.java
changeset 50317 cf71bff5f533
equal deleted inserted replaced
50316:60ebcc705421 50317:cf71bff5f533
       
     1 /*
       
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 package nsk.jdwp.Event.METHOD_ENTRY;
       
    25 
       
    26 import java.io.*;
       
    27 
       
    28 import nsk.share.*;
       
    29 import nsk.share.jpda.*;
       
    30 import nsk.share.jdwp.*;
       
    31 
       
    32 /**
       
    33  * Test for JDWP event: METHOD_ENTRY.
       
    34  *
       
    35  * See methentry001.README for description of test execution.
       
    36  *
       
    37  * This class represents debugger part of the test.
       
    38  * Test is executed by invoking method runIt().
       
    39  * JDWP event is tested in the method waitForTestedEvent().
       
    40  *
       
    41  * @see #runIt()
       
    42  * @see #waitForTestedEvent()
       
    43  */
       
    44 public class methentry001 {
       
    45 
       
    46     // exit status constants
       
    47     static final int JCK_STATUS_BASE = 95;
       
    48     static final int PASSED = 0;
       
    49     static final int FAILED = 2;
       
    50 
       
    51     // package and classes names constants
       
    52     static final String PACKAGE_NAME = "nsk.jdwp.Event.METHOD_ENTRY";
       
    53     static final String TEST_CLASS_NAME = PACKAGE_NAME + "." + "methentry001";
       
    54     static final String DEBUGEE_CLASS_NAME = TEST_CLASS_NAME + "a";
       
    55 
       
    56     // tested JDWP event constants
       
    57     static final byte TESTED_EVENT_KIND = JDWP.EventKind.METHOD_ENTRY;
       
    58     static final byte TESTED_EVENT_SUSPEND_POLICY = JDWP.SuspendPolicy.ALL;
       
    59 
       
    60     // name and signature of the tested class
       
    61     static final String TESTED_CLASS_NAME = DEBUGEE_CLASS_NAME + "$" + "TestedClass";
       
    62     static final String TESTED_CLASS_SIGNATURE = "L" + TESTED_CLASS_NAME.replace('.', '/') + ";";
       
    63     static final String TESTED_THREAD_NAME = "TestedThread";
       
    64 
       
    65     // name of field and method of tested class
       
    66     static final String THREAD_FIELD_NAME = "thread";
       
    67     static final String TESTED_METHOD_NAME = "testedMethod";
       
    68     static final String BREAKPOINT_METHOD_NAME = "run";
       
    69     static final int BREAKPOINT_LINE = methentry001a.BREAKPOINT_LINE;
       
    70     static final int METHOD_ENTRY_LINE = methentry001a.METHOD_ENTRY_LINE;
       
    71 
       
    72     // usual scaffold objects
       
    73     ArgumentHandler argumentHandler = null;
       
    74     Log log = null;
       
    75     Binder binder = null;
       
    76     Debugee debugee = null;
       
    77     Transport transport = null;
       
    78     int waitTime = 0;  // minutes
       
    79     long timeout = 0;  // milliseconds
       
    80     boolean dead = false;
       
    81     boolean success = true;
       
    82 
       
    83     // obtained data
       
    84     long testedClassID = 0;
       
    85     long testedThreadID = 0;
       
    86     long testedMethodID = 0;
       
    87     JDWP.Location testedLocation = null;
       
    88     int eventRequestID = 0;
       
    89 
       
    90     // -------------------------------------------------------------------
       
    91 
       
    92     /**
       
    93      * Start test from command line.
       
    94      */
       
    95     public static void main(String argv[]) {
       
    96         System.exit(run(argv,System.out) + JCK_STATUS_BASE);
       
    97     }
       
    98 
       
    99     /**
       
   100      * Start test from JCK-compilant environment.
       
   101      */
       
   102     public static int run(String argv[], PrintStream out) {
       
   103         return new methentry001().runIt(argv, out);
       
   104     }
       
   105 
       
   106     // -------------------------------------------------------------------
       
   107 
       
   108     /**
       
   109      * Perform test execution.
       
   110      */
       
   111     public int runIt(String argv[], PrintStream out) {
       
   112 
       
   113         // make log for debugger messages
       
   114         argumentHandler = new ArgumentHandler(argv);
       
   115         log = new Log(out, argumentHandler);
       
   116         waitTime = argumentHandler.getWaitTime();
       
   117         timeout = waitTime * 60 * 1000;
       
   118 
       
   119         // execute test and display results
       
   120         try {
       
   121             log.display("\n>>> Starting debugee \n");
       
   122 
       
   123             // launch debuggee
       
   124             binder = new Binder(argumentHandler, log);
       
   125             log.display("Launching debugee");
       
   126             debugee = binder.bindToDebugee(DEBUGEE_CLASS_NAME);
       
   127             transport = debugee.getTransport();
       
   128             log.display("  ... debugee launched");
       
   129             log.display("");
       
   130 
       
   131             // set timeout for debuggee responces
       
   132             log.display("Setting timeout for debuggee responces: " + waitTime + " minute(s)");
       
   133             transport.setReadTimeout(timeout);
       
   134             log.display("  ... timeout set");
       
   135 
       
   136             // wait for debuggee started
       
   137             log.display("Waiting for VM_INIT event");
       
   138             debugee.waitForVMInit();
       
   139             log.display("  ... VM_INIT event received");
       
   140 
       
   141             // query debugee for VM-dependent ID sizes
       
   142             log.display("Querying for IDSizes");
       
   143             debugee.queryForIDSizes();
       
   144             log.display("  ... size of VM-dependent types adjusted");
       
   145 
       
   146             // prepare debuggee
       
   147             log.display("\n>>> Getting prepared for testing \n");
       
   148             prepareForTest();
       
   149 
       
   150             // test JDWP event
       
   151             log.display("\n>>> Testing JDWP event \n");
       
   152             log.display("Making request for METHOD_ENTRY event for class:\n\t"
       
   153                     + TESTED_CLASS_NAME);
       
   154             requestTestedEvent();
       
   155             log.display("  ... got requestID: " + eventRequestID);
       
   156             log.display("");
       
   157 
       
   158             // resume debuggee
       
   159             log.display("Resumindg debuggee");
       
   160             debugee.resume();
       
   161             log.display("  ... debuggee resumed");
       
   162             log.display("");
       
   163 
       
   164             // wait for tested METHOD_ENTRY event
       
   165             log.display("Waiting for METHOD_ENTRY event received");
       
   166             waitForTestedEvent();
       
   167             log.display("  ... event received");
       
   168             log.display("");
       
   169 
       
   170             // clear tested request for METHOD_ENTRY event
       
   171             log.display("Clearing request for tested event");
       
   172             clearTestedRequest();
       
   173             log.display("  ... request removed");
       
   174 
       
   175             // finish debuggee after testing
       
   176             log.display("\n>>> Finishing debuggee \n");
       
   177 
       
   178             // resume debuggee
       
   179             log.display("Resuming debuggee");
       
   180             debugee.resume();
       
   181             log.display("  ... debuggee resumed");
       
   182 
       
   183             // wait for debuggee exited
       
   184             log.display("Waiting for VM_DEATH event");
       
   185             debugee.waitForVMDeath();
       
   186             dead = true;
       
   187             log.display("  ... VM_DEATH event received");
       
   188 
       
   189         } catch (Failure e) {
       
   190             log.complain("TEST FAILED: " + e.getMessage());
       
   191             success = false;
       
   192         } catch (Exception e) {
       
   193             e.printStackTrace(out);
       
   194             log.complain("Caught unexpected exception while running the test:\n\t" + e);
       
   195             success = false;
       
   196         } finally {
       
   197             // quit debugee
       
   198             log.display("\n>>> Finishing test \n");
       
   199             quitDebugee();
       
   200         }
       
   201 
       
   202         // check test results
       
   203         if (!success) {
       
   204             log.complain("TEST FAILED");
       
   205             return FAILED;
       
   206         }
       
   207 
       
   208         out.println("TEST PASSED");
       
   209         return PASSED;
       
   210 
       
   211     }
       
   212 
       
   213     /**
       
   214      * Get debuggee prepared for testing and obtain required data.
       
   215      */
       
   216     void prepareForTest() {
       
   217         // wait for tested class loaded
       
   218         log.display("Waiting for tested class loaded");
       
   219         testedClassID = debugee.waitForClassLoaded(TESTED_CLASS_NAME, JDWP.SuspendPolicy.ALL);
       
   220         log.display("  ... got classID: " + testedClassID);
       
   221         log.display("");
       
   222 
       
   223         // get methodID for the tested method
       
   224         log.display("Getting tested methodID for method name: " + TESTED_METHOD_NAME);
       
   225         testedMethodID = debugee.getMethodID(testedClassID, TESTED_METHOD_NAME, true);
       
   226         log.display("  ... got methodID: " + testedMethodID);
       
   227 
       
   228         // get codeIndex for method entry line
       
   229         log.display("Getting codeIndex for method entry line: " + METHOD_ENTRY_LINE);
       
   230         long codeIndex = debugee.getCodeIndex(testedClassID, testedMethodID, METHOD_ENTRY_LINE);
       
   231         log.display("  ... got index: " + codeIndex);
       
   232 
       
   233         // create location for method entry line
       
   234         log.display("Creating location for method entry");
       
   235         testedLocation = new JDWP.Location(JDWP.TypeTag.CLASS, testedClassID,
       
   236                                                         testedMethodID, codeIndex);
       
   237         log.display("  ... got location: " + testedLocation);
       
   238         log.display("");
       
   239 
       
   240         // wait for breakpoint reached
       
   241         log.display("Waiting for breakpoint reached at: "
       
   242                         + BREAKPOINT_METHOD_NAME + ":" + BREAKPOINT_LINE);
       
   243         testedThreadID = debugee.waitForBreakpointReached(testedClassID,
       
   244                                                         BREAKPOINT_METHOD_NAME,
       
   245                                                         BREAKPOINT_LINE,
       
   246                                                         JDWP.SuspendPolicy.ALL);
       
   247         log.display("  ... breakpoint reached with threadID: " + testedThreadID);
       
   248         log.display("");
       
   249     }
       
   250 
       
   251     /**
       
   252      * Make request for tested METHOD_ENTRY event.
       
   253      */
       
   254     void requestTestedEvent() {
       
   255         Failure failure = new Failure("Error occured while makind request for tested event");
       
   256 
       
   257         // create command packet and fill requred out data
       
   258         log.display("Create command packet: " + "EventRequest.Set");
       
   259         CommandPacket command = new CommandPacket(JDWP.Command.EventRequest.Set);
       
   260         log.display("    eventKind: " + TESTED_EVENT_KIND);
       
   261         command.addByte(TESTED_EVENT_KIND);
       
   262         log.display("    eventPolicy: " + TESTED_EVENT_SUSPEND_POLICY);
       
   263         command.addByte(TESTED_EVENT_SUSPEND_POLICY);
       
   264         log.display("    modifiers: " + 1);
       
   265         command.addInt(1);
       
   266         log.display("      modKind: " + JDWP.EventModifierKind.CLASS_ONLY);
       
   267         command.addByte(JDWP.EventModifierKind.CLASS_ONLY);
       
   268         log.display("      classID: " + testedClassID);
       
   269         command.addReferenceTypeID(testedClassID);
       
   270         command.setLength();
       
   271         log.display("  ... command packet composed");
       
   272         log.display("");
       
   273 
       
   274         // send command packet to debugee
       
   275         try {
       
   276             log.display("Sending command packet:\n" + command);
       
   277             transport.write(command);
       
   278             log.display("  ... command packet sent");
       
   279         } catch (IOException e) {
       
   280             log.complain("Unable to send command packet:\n\t" + e);
       
   281             success = false;
       
   282             throw failure;
       
   283         }
       
   284         log.display("");
       
   285 
       
   286         ReplyPacket reply = new ReplyPacket();
       
   287 
       
   288         // receive reply packet from debugee
       
   289         try {
       
   290             log.display("Waiting for reply packet");
       
   291             transport.read(reply);
       
   292             log.display("  ... packet received:\n" + reply);
       
   293         } catch (IOException e) {
       
   294             log.complain("Unable to read reply packet:\n\t" + e);
       
   295             success = false;
       
   296             throw failure;
       
   297         }
       
   298         log.display("");
       
   299 
       
   300         // check reply packet header
       
   301         try{
       
   302             log.display("Checking header of reply packet");
       
   303             reply.checkHeader(command.getPacketID());
       
   304             log.display("  .. packet header is correct");
       
   305         } catch (BoundException e) {
       
   306             log.complain("Bad header of reply packet:\n\t" + e.getMessage());
       
   307             success = false;
       
   308             throw failure;
       
   309         }
       
   310 
       
   311         // start parsing reply packet data
       
   312         log.display("Parsing reply packet:");
       
   313         reply.resetPosition();
       
   314 
       
   315         // extract requestID
       
   316         int requestID = 0;
       
   317         try {
       
   318             requestID = reply.getInt();
       
   319             log.display("    requestID: " + requestID);
       
   320         } catch (BoundException e) {
       
   321             log.complain("Unable to extract requestID from request reply packet:\n\t"
       
   322                         + e.getMessage());
       
   323             success = false;
       
   324             throw failure;
       
   325         }
       
   326 
       
   327         // check requestID
       
   328         if (requestID == 0) {
       
   329             log.complain("Unexpected null requestID returned: " + requestID);
       
   330             success = false;
       
   331             throw failure;
       
   332         }
       
   333 
       
   334         eventRequestID = requestID;
       
   335 
       
   336         // check for extra data in reply packet
       
   337         if (!reply.isParsed()) {
       
   338             log.complain("Extra trailing bytes found in request reply packet at: "
       
   339                         + reply.offsetString());
       
   340             success = false;
       
   341         }
       
   342 
       
   343         log.display("  ... reply packet parsed");
       
   344     }
       
   345 
       
   346     /**
       
   347      * Clear request for tested METHOD_ENTRY event.
       
   348      */
       
   349     void clearTestedRequest() {
       
   350         Failure failure = new Failure("Error occured while clearing request for tested event");
       
   351 
       
   352         // create command packet and fill requred out data
       
   353         log.display("Create command packet: " + "EventRequest.Clear");
       
   354         CommandPacket command = new CommandPacket(JDWP.Command.EventRequest.Clear);
       
   355         log.display("    event: " + TESTED_EVENT_KIND);
       
   356         command.addByte(TESTED_EVENT_KIND);
       
   357         log.display("    requestID: " + eventRequestID);
       
   358         command.addInt(eventRequestID);
       
   359         log.display("  ... command packet composed");
       
   360         log.display("");
       
   361 
       
   362         // send command packet to debugee
       
   363         try {
       
   364             log.display("Sending command packet:\n" + command);
       
   365             transport.write(command);
       
   366             log.display("  ... command packet sent");
       
   367         } catch (IOException e) {
       
   368             log.complain("Unable to send command packet:\n\t" + e);
       
   369             success = false;
       
   370             throw failure;
       
   371         }
       
   372         log.display("");
       
   373 
       
   374         ReplyPacket reply = new ReplyPacket();
       
   375 
       
   376         // receive reply packet from debugee
       
   377         try {
       
   378             log.display("Waiting for reply packet");
       
   379             transport.read(reply);
       
   380             log.display("  ... packet received:\n" + reply);
       
   381         } catch (IOException e) {
       
   382             log.complain("Unable to read reply packet:\n\t" + e);
       
   383             success = false;
       
   384             throw failure;
       
   385         }
       
   386 
       
   387         // check reply packet header
       
   388         try{
       
   389             log.display("Checking header of reply packet");
       
   390             reply.checkHeader(command.getPacketID());
       
   391             log.display("  .. packet header is correct");
       
   392         } catch (BoundException e) {
       
   393             log.complain("Bad header of reply packet:\n\t" + e.getMessage());
       
   394             success = false;
       
   395             throw failure;
       
   396         }
       
   397 
       
   398         // start parsing reply packet data
       
   399         log.display("Parsing reply packet:");
       
   400         reply.resetPosition();
       
   401 
       
   402         log.display("    no data");
       
   403 
       
   404         // check for extra data in reply packet
       
   405         if (!reply.isParsed()) {
       
   406             log.complain("Extra trailing bytes found in request reply packet at: "
       
   407                         + reply.offsetString());
       
   408             success = false;
       
   409         }
       
   410 
       
   411         log.display("  ... reply packet parsed");
       
   412     }
       
   413 
       
   414     /**
       
   415      * Wait for tested METHOD_ENTRY event.
       
   416      */
       
   417     void waitForTestedEvent() {
       
   418 
       
   419         EventPacket eventPacket = null;
       
   420 
       
   421         // receive reply packet from debugee
       
   422         try {
       
   423             log.display("Waiting for event packet");
       
   424             eventPacket = debugee.getEventPacket(timeout);
       
   425             log.display("  ... event packet received:\n" + eventPacket);
       
   426         } catch (IOException e) {
       
   427             log.complain("Unable to read tested event packet:\n\t" + e);
       
   428             success = false;
       
   429             return;
       
   430         }
       
   431         log.display("");
       
   432 
       
   433         // check reply packet header
       
   434         try{
       
   435             log.display("Checking header of event packet");
       
   436             eventPacket.checkHeader();
       
   437             log.display("  ... packet header is correct");
       
   438         } catch (BoundException e) {
       
   439             log.complain("Bad header of tested event packet:\n\t"
       
   440                         + e.getMessage());
       
   441             success = false;
       
   442             return;
       
   443         }
       
   444 
       
   445         // start parsing reply packet data
       
   446         log.display("Parsing event packet:");
       
   447         eventPacket.resetPosition();
       
   448 
       
   449         // get suspendPolicy value
       
   450         byte suspendPolicy = 0;
       
   451         try {
       
   452             suspendPolicy = eventPacket.getByte();
       
   453             log.display("    suspendPolicy: " + suspendPolicy);
       
   454         } catch (BoundException e) {
       
   455             log.complain("Unable to get suspendPolicy value from tested event packet:\n\t"
       
   456                         + e.getMessage());
       
   457             success = false;
       
   458             return;
       
   459         }
       
   460 
       
   461         // check suspendPolicy value
       
   462         if (suspendPolicy != TESTED_EVENT_SUSPEND_POLICY) {
       
   463             log.complain("Unexpected SuspendPolicy in tested event packet: " +
       
   464                         suspendPolicy + " (expected: " + TESTED_EVENT_SUSPEND_POLICY + ")");
       
   465             success = false;
       
   466         }
       
   467 
       
   468         // get events count
       
   469         int events = 0;
       
   470         try {
       
   471             events = eventPacket.getInt();
       
   472             log.display("    events: " + events);
       
   473         } catch (BoundException e) {
       
   474             log.complain("Unable to get events count from tested event packet:\n\t"
       
   475                         + e.getMessage());
       
   476             success = false;
       
   477             return;
       
   478         }
       
   479 
       
   480         // check events count
       
   481         if (events < 0) {
       
   482             log.complain("Negative value of events number in tested event packet: " +
       
   483                         events + " (expected: " + 1 + ")");
       
   484             success = false;
       
   485         } else if (events != 1) {
       
   486             log.complain("Invalid number of events in tested event packet: " +
       
   487                         events + " (expected: " + 1 + ")");
       
   488             success = false;
       
   489         }
       
   490 
       
   491         // extract each event
       
   492         long eventThreadID = 0;
       
   493         for (int i = 0; i < events; i++) {
       
   494             log.display("    event #" + i + ":");
       
   495 
       
   496             // get eventKind
       
   497             byte eventKind = 0;
       
   498             try {
       
   499                 eventKind = eventPacket.getByte();
       
   500                 log.display("      eventKind: " + eventKind);
       
   501             } catch (BoundException e) {
       
   502                 log.complain("Unable to get eventKind of event #" + i + " from tested event packet:\n\t"
       
   503                             + e.getMessage());
       
   504                 success = false;
       
   505                 return;
       
   506             }
       
   507 
       
   508             // check eventKind
       
   509             if (eventKind == JDWP.EventKind.VM_DEATH) {
       
   510                 log.complain("Unexpected VM_DEATH event received: " +
       
   511                             eventKind + " (expected: " + JDWP.EventKind.METHOD_ENTRY + ")");
       
   512                 dead = true;
       
   513                 success = false;
       
   514                 return;
       
   515             }  else if (eventKind != JDWP.EventKind.METHOD_ENTRY) {
       
   516                 log.complain("Unexpected eventKind of event " + i + " in tested event packet: " +
       
   517                             eventKind + " (expected: " + JDWP.EventKind.METHOD_ENTRY + ")");
       
   518                 success = false;
       
   519                 return;
       
   520             }
       
   521 
       
   522             // get requestID
       
   523             int requestID = 0;
       
   524             try {
       
   525                 requestID = eventPacket.getInt();
       
   526                 log.display("      requestID: " + requestID);
       
   527             } catch (BoundException e) {
       
   528                 log.complain("Unable to get requestID of event #" + i + " from tested event packet:\n\t"
       
   529                             + e.getMessage());
       
   530                 success = false;
       
   531                 return;
       
   532             }
       
   533 
       
   534             // check requestID
       
   535             if (requestID != eventRequestID) {
       
   536                 log.complain("Unexpected requestID of event " + i + " in tested event packet: " +
       
   537                             requestID + " (expected: " + eventRequestID + ")");
       
   538                 success = false;
       
   539             }
       
   540 
       
   541             // get threadID
       
   542             long threadID = 0;
       
   543             try {
       
   544                 threadID = eventPacket.getObjectID();
       
   545                 log.display("      threadID: " + threadID);
       
   546             } catch (BoundException e) {
       
   547                 log.complain("Unable to get threadID of event #" + i + " from tested event packet:\n\t"
       
   548                             + e.getMessage());
       
   549                 success = false;
       
   550                 return;
       
   551             }
       
   552 
       
   553             // check threadID
       
   554             if (threadID != testedThreadID) {
       
   555                 log.complain("Unexpected threadID of event " + i + " in tested event packet: " +
       
   556                             threadID + " (expected: " + testedThreadID + ")");
       
   557                 success = false;
       
   558             }
       
   559 
       
   560             // get location
       
   561             JDWP.Location location = null;
       
   562             try {
       
   563                 location = eventPacket.getLocation();
       
   564                 log.display("      location: " + location);
       
   565             } catch (BoundException e) {
       
   566                 log.complain("Unable to get location of event #" + i + " from tested event packet:\n\t"
       
   567                             + e.getMessage());
       
   568                 success = false;
       
   569                 return;
       
   570             }
       
   571 
       
   572             // check location
       
   573             if (location.getTag() != testedLocation.getTag()) {
       
   574                 log.complain("Unexpected class tag of location of event " + i
       
   575                             + " in tested event packet: " + location.getTag()
       
   576                             + " (expected: " + testedLocation.getTag() + ")");
       
   577                 success = false;
       
   578             }
       
   579             if (location.getClassID() != testedLocation.getClassID()) {
       
   580                 log.complain("Unexpected classID of location of event " + i
       
   581                             + " in tested event packet: " + location.getClassID()
       
   582                             + " (expected: " + testedLocation.getClassID() + ")");
       
   583                 success = false;
       
   584             }
       
   585             if (location.getMethodID() != testedLocation.getMethodID()) {
       
   586                 log.complain("Unexpected methodID of location of event " + i
       
   587                             + " in tested event packet: " + location.getMethodID()
       
   588                             + " (expected: " + testedLocation.getMethodID() + ")");
       
   589                 success = false;
       
   590             }
       
   591             if (location.getIndex() != testedLocation.getIndex()) {
       
   592                 log.complain("Unexpected codeIndex of location of event " + i
       
   593                             + " in tested event packet: " + location.getIndex()
       
   594                             + " (expected: " + testedLocation.getIndex() + ")");
       
   595                 success = false;
       
   596             }
       
   597         }
       
   598 
       
   599         // check for extra data in event packet
       
   600         if (!eventPacket.isParsed()) {
       
   601             log.complain("Extra trailing bytes found in event packet at: "
       
   602                         + eventPacket.offsetString());
       
   603             success = false;
       
   604         }
       
   605 
       
   606         log.display("  ... event packet parsed");
       
   607     }
       
   608 
       
   609     /**
       
   610      * Disconnect debuggee and wait for it exited.
       
   611      */
       
   612     void quitDebugee() {
       
   613         if (debugee == null)
       
   614             return;
       
   615 
       
   616         // disconnect debugee
       
   617         if (!dead) {
       
   618             try {
       
   619                 log.display("Disconnecting debuggee");
       
   620                 debugee.dispose();
       
   621                 log.display("  ... debuggee disconnected");
       
   622             } catch (Failure e) {
       
   623                 log.display("Failed to finally disconnect debuggee:\n\t"
       
   624                             + e.getMessage());
       
   625             }
       
   626         }
       
   627 
       
   628         // wait for debugee exited
       
   629         log.display("Waiting for debuggee exit");
       
   630         int code = debugee.waitFor();
       
   631         log.display("  ... debuggee exited with exit code: " + code);
       
   632 
       
   633         // analize debugee exit status code
       
   634         if (code != JCK_STATUS_BASE + PASSED) {
       
   635             log.complain("Debuggee FAILED with exit code: " + code);
       
   636             success = false;
       
   637         }
       
   638     }
       
   639 
       
   640 }