Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh
38855 views
#!/bin/sh12#3# Copyright (c) 2009, 2013 Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425# @test26# @bug 686229527# @summary Verify breakpoints still work after a full GC.28# @author dcubed (based on the test program posted to the following29# Eclipse thread https://bugs.eclipse.org/bugs/show_bug.cgi?id=279137)30#31# @run shell BreakpointWithFullGC.sh3233compileOptions=-g34# Hijacking the mode parameter to make sure we use a small amount35# of memory and can see what GC is doing.36mode="-Xmx32m -verbose:gc"37# Force use of a GC framework collector to see the original failure.38#mode="$mode -XX:+UseSerialGC"3940# Uncomment this to see the JDI trace41#jdbOptions=-dbgtrace4243createJavaFile()44{45cat <<EOF > $1.java.14647import java.util.ArrayList;48import java.util.List;4950public class $1 {51public static List<Object> objList = new ArrayList<Object>();5253private static void init(int numObjs) {54for (int i = 0; i < numObjs; i++) {55objList.add(new Object());56}57}5859public static void main(String[] args) {60for (int i = 0; i < 10; i++) {61System.out.println("top of loop"); // @1 breakpoint62init(500000);63objList.clear();64System.gc();65System.out.println("bottom of loop"); // @1 breakpoint66}67System.out.println("end of test"); // @1 breakpoint68}69}7071EOF72}7374# This is called to feed cmds to jdb.75dojdbCmds()76{77setBkpts @17879# get to the first loop breakpoint80runToBkpt81# 19 "cont" commands gets us through all the loop breakpoints.82# Use for-loop instead of while-loop to avoid creating processes83# for '[' and 'expr'.84for ii in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do85contToBkpt86done87# get to the last breakpoint88contToBkpt89}909192mysetup()93{94if [ -z "$TESTSRC" ] ; then95TESTSRC=.96fi9798for ii in . $TESTSRC $TESTSRC/.. ; do99if [ -r "$ii/ShellScaffold.sh" ] ; then100. $ii/ShellScaffold.sh101break102fi103done104}105106# You could replace this next line with the contents107# of ShellScaffold.sh and this script will run just the same.108mysetup109110runit111112# make sure we hit the first breakpoint at least once113jdbFailIfNotPresent 'System\..*top of loop'114115# make sure we hit the second breakpoint at least once116jdbFailIfNotPresent 'System\..*bottom of loop'117118# make sure we hit the last breakpoint119jdbFailIfNotPresent 'System\..*end of test'120121# make sure we had at least one full GC122debuggeeFailIfNotPresent 'Full GC'123124# check for error message due to thread ID change125debuggeeFailIfPresent \126'Exception in thread "event-handler" java.lang.NullPointerException'127128pass129130131