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