jdk/test/com/sun/jdi/BreakpointWithFullGC.sh
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 5506 202f599c92aa
child 21666 918ef08589ee
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3851
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     1
#!/bin/sh
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     2
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     3
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3851
diff changeset
     4
# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3851
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     6
#
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
     9
# published by the Free Software Foundation.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    10
#
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    15
# accompanied this code).
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    16
#
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3851
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3851
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3851
diff changeset
    23
# questions.
3851
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    24
#
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    25
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    26
#  @test
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    27
#  @bug 6862295
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    28
#  @summary Verify breakpoints still work after a full GC.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    29
#  @author dcubed (based on the test program posted to the following
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    30
#  Eclipse thread https://bugs.eclipse.org/bugs/show_bug.cgi?id=279137)
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    31
#
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    32
#  @run shell BreakpointWithFullGC.sh
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    33
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    34
compileOptions=-g
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    35
# Hijacking the mode parameter to make sure we use a small amount
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    36
# of memory and can see what GC is doing.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    37
mode="-Xmx32m -verbose:gc"
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    38
# Force use of a GC framework collector to see the original failure.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    39
#mode="$mode -XX:+UseSerialGC"
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    40
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    41
# Uncomment this to see the JDI trace
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    42
#jdbOptions=-dbgtrace
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    43
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    44
createJavaFile()
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    45
{
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    46
    cat <<EOF > $1.java.1
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    47
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    48
import java.util.ArrayList;
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    49
import java.util.List;
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    50
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    51
public class $1 {
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    52
    public static List<Object> objList = new ArrayList<Object>();
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    53
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    54
    private static void init(int numObjs) {
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    55
        for (int i = 0; i < numObjs; i++) {
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    56
            objList.add(new Object());
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    57
        }
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    58
    }
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    59
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    60
    public static void main(String[] args) {
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    61
        for (int i = 0; i < 10; i++) {
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    62
            System.out.println("top of loop");     // @1 breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    63
            init(1000000);
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    64
            objList.clear();
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    65
            System.out.println("bottom of loop");  // @1 breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    66
        }
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    67
        System.out.println("end of test");         // @1 breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    68
    }
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    69
}
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    70
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    71
EOF
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    72
}
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    73
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    74
# This is called to feed cmds to jdb.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    75
dojdbCmds()
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    76
{
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    77
    setBkpts @1
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    78
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    79
    # get to the first loop breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    80
    runToBkpt
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    81
    # 19 "cont" commands gets us through all the loop breakpoints.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    82
    # Use for-loop instead of while-loop to avoid creating processes
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    83
    # for '[' and 'expr'.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    84
    for ii in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    85
        contToBkpt
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    86
    done
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    87
    # get to the last breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    88
    contToBkpt
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    89
}
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    90
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    91
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    92
mysetup()
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    93
{
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    94
    if [ -z "$TESTSRC" ] ; then
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    95
        TESTSRC=.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    96
    fi
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    97
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    98
    for ii in . $TESTSRC $TESTSRC/.. ; do
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
    99
        if [ -r "$ii/ShellScaffold.sh" ] ; then
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   100
            . $ii/ShellScaffold.sh
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   101
            break
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   102
        fi
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   103
    done
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   104
}
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   105
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   106
# You could replace this next line with the contents
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   107
# of ShellScaffold.sh and this script will run just the same.
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   108
mysetup
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   109
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   110
runit
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   111
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   112
# make sure we hit the first breakpoint at least once
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   113
jdbFailIfNotPresent 'System\..*top of loop'
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   114
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   115
# make sure we hit the second breakpoint at least once
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   116
jdbFailIfNotPresent 'System\..*bottom of loop'
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   117
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   118
# make sure we hit the last breakpoint
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   119
jdbFailIfNotPresent 'System\..*end of test'
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   120
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   121
# make sure we had at least one full GC
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   122
debuggeeFailIfNotPresent 'Full GC'
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   123
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   124
# check for error message due to thread ID change
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   125
debuggeeFailIfPresent \
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   126
    'Exception in thread "event-handler" java.lang.NullPointerException'
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   127
42033ba29ec8 6862295: JDWP threadid changes during debugging session (leading to ingored breakpoints)
dcubed
parents:
diff changeset
   128
pass