jdk/test/com/sun/jdi/DeferredStepTest.sh
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 # Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
       
     5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     6 #
       
     7 # This code is free software; you can redistribute it and/or modify it
       
     8 # under the terms of the GNU General Public License version 2 only, as
       
     9 # published by the Free Software Foundation.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
       
    23 # have any questions.
       
    24 #
       
    25 
       
    26 #  @ test
       
    27 #  This is a manual test.  The script isn't smart enough
       
    28 #  to detect the correct ordering of the output since it
       
    29 #  is produced by multiple threads and can be interleaved
       
    30 #  in many different ways.
       
    31 #
       
    32 #  @bug 4629548
       
    33 #  @summary Deferred StepRequests are lost in multithreaded debuggee
       
    34 #  @author Jim Holmlund
       
    35 #
       
    36 #  @run shell/manual DeferredStepTest.sh
       
    37 
       
    38 #  Run this script to see the bug.  See comments at the end
       
    39 #  of the .java file for info on what the bug looks like.
       
    40 
       
    41 # These are variables that can be set to control execution
       
    42 
       
    43 #pkg=untitled7
       
    44 classname=DeferredStepTest
       
    45 #compileOptions=-g
       
    46 #java=java_g
       
    47 #mode=-Xcomp
       
    48 
       
    49 createJavaFile()
       
    50 {
       
    51     cat <<EOF > $classname.java.1
       
    52 public class $classname {
       
    53   static class  jj1 implements Runnable {
       
    54     public void  run() {
       
    55         int count = 0;
       
    56         
       
    57         for ( int ii = 0; ii < 10; ii++) {  // line 6
       
    58             int intInPotato04 = 666;        // line 7
       
    59             ++count;                        // line 8; @1 breakpoint
       
    60             System.out.println("Thread: " + Thread.currentThread().getName());  // line 9
       
    61         }
       
    62     }
       
    63   }
       
    64 
       
    65   static class jj2 implements Runnable {
       
    66     public void run() {
       
    67         int count2 = 0;
       
    68         
       
    69         for (int ii = 0; ii < 10; ii++) {      // line 18
       
    70             String StringInPotato05 = "I am";  // line 19
       
    71             ++count2;                          // line 20; @1 breakpoint
       
    72             System.out.println("Thread: " + Thread.currentThread().getName());  // line 21
       
    73         }
       
    74     }
       
    75   }
       
    76 
       
    77   public static void  main(String argv[]) {
       
    78       System.out.println("Version = " + System.getProperty("java.version"));
       
    79 
       
    80       jj1 aRP = new jj1();
       
    81       jj2 asRP = new jj2();
       
    82       new Thread(aRP,  "jj1 *").start();
       
    83       new Thread(asRP, "jj2 **").start();
       
    84 //    new Thread(aRP,  "jj3 ***").start();
       
    85 //    new Thread(asRP, "jj4 ****").start();
       
    86   }
       
    87 }
       
    88 
       
    89 /****************************
       
    90 To see this bug, do this
       
    91 
       
    92   jdb DeferredStep
       
    93   stop at DeferredStepTest$jj1:8
       
    94   stop at DeferredStepTest$jj2:20
       
    95   run
       
    96   next
       
    97   next
       
    98    :
       
    99 
       
   100 ********/
       
   101 
       
   102 EOF
       
   103 }
       
   104 
       
   105 #sleepcmd="sleep 2"
       
   106 
       
   107 # This is called to feed cmds to jdb.
       
   108 dojdbCmds()
       
   109 {
       
   110    #set -x
       
   111    # We can't use setBkpts because it can only set bkpts in one class :-(
       
   112    #setBkpts @1
       
   113    cmd stop at $classname'$jj1:8'
       
   114    cmd stop at $classname'$jj2:20'
       
   115    #cmd run; $sleepcmd
       
   116    runToBkpt @1
       
   117    cmd next; $sleepcmd
       
   118    cmd next; $sleepcmd
       
   119    cmd next; $sleepcmd
       
   120    cmd next; $sleepcmd
       
   121    cmd next; $sleepcmd
       
   122    cmd next; $sleepcmd
       
   123    cmd next; $sleepcmd
       
   124    cmd next; $sleepcmd
       
   125    cmd next; $sleepcmd
       
   126    cmd next; $sleepcmd
       
   127    cmd next; $sleepcmd
       
   128    cmd next; $sleepcmd
       
   129    cmd next; $sleepcmd
       
   130    cmd next; $sleepcmd
       
   131    cmd next; $sleepcmd
       
   132    cmd quit
       
   133 }
       
   134 
       
   135 mysetup()
       
   136 {
       
   137     if [ -z "$TESTSRC" ] ; then
       
   138         TESTSRC=.
       
   139     fi
       
   140 
       
   141     for ii in . $TESTSRC $TESTSRC/.. ; do
       
   142         if [ -r "$ii/ShellScaffold.sh" ] ; then
       
   143             . $ii/ShellScaffold.sh 
       
   144             break
       
   145         fi
       
   146     done
       
   147 }
       
   148 
       
   149 
       
   150 # You could replace this next line with the contents
       
   151 # of ShellScaffold.sh and this script will run just the same.
       
   152 mysetup
       
   153 
       
   154 cat <<EOF
       
   155 ****************************************************************
       
   156 This test should be run and checked manually.
       
   157 
       
   158 If this works right, you should see StepEvents/Breakpoint events for lines
       
   159    8, 9, 6, 7, 8, 9, 6, ....   for thread jj11
       
   160 and
       
   161   20, 21, 18, 19, 20, 21, 18, ... for thread jj2 
       
   162 
       
   163 Since both threads are running at the same time, these
       
   164 events can be intermixed.
       
   165 
       
   166 The bug is that you will frequently see step events missing.
       
   167 EG, you will see
       
   168   8, 9, 8
       
   169 or
       
   170   20, 21, 20, 21
       
   171 etc
       
   172 
       
   173 ============================================================
       
   174 At some point you might get the msg 'Nothing suspended'
       
   175 This is bug:
       
   176    4619349 Step Over fails in a multi threaded debuggee
       
   177 
       
   178 Kill the test and rerun it if this happens.
       
   179 ****************************************************************
       
   180 
       
   181 EOF
       
   182 runit
       
   183 #jdbFailIfPresent "Nothing suspended" 
       
   184 #pass