8203393: com/sun/jdi/JdbMethodExitTest.sh and JdbExprTest.sh fail due to timeout

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Alex Menkov 2018-08-27 16:45:18 -07:00
parent d739f1d6de
commit 1e6c19b381
7 changed files with 494 additions and 470 deletions

View File

@ -838,10 +838,6 @@ com/sun/jdi/BasicJDWPConnectionTest.java 8195703 generic-
com/sun/jdi/RedefineImplementor.sh 8004127 generic-all
com/sun/jdi/JdbExprTest.sh 8203393 solaris-all
com/sun/jdi/JdbMethodExitTest.sh 8203393 solaris-all
com/sun/jdi/RepStep.java 8043571 generic-all
com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4660158
* @summary javac produces the inconsistent variable debug in while loops.
* @comment converted from test/jdk/com/sun/jdi/JdbExprTest.sh
*
* @library /test/lib
* @compile -g JdbExprTest.java
* @run main/othervm JdbExprTest
*/
import lib.jdb.JdbCommand;
import lib.jdb.JdbTest;
import java.util.*;
import java.net.URLClassLoader;
import java.net.URL;
class JdbExprTestTarg {
static Long lMax = new Long(java.lang.Long.MAX_VALUE); // force initialization of Long class
static long aLong;
static int anInt;
static boolean aBoolean;
public static void bkpt() {
int i = 0; //@1 breakpoint
}
public static void main(String[] args) {
bkpt();
}
}
public class JdbExprTest extends JdbTest {
public static void main(String argv[]) {
new JdbExprTest().run();
}
private JdbExprTest() {
super(DEBUGGEE_CLASS);
}
private static final String DEBUGGEE_CLASS = JdbExprTestTarg.class.getName();
@Override
protected void runCases() {
setBreakpoints(System.getProperty("test.src") + "/JdbExprTest.java", 1);
// Run to breakpoint #1
execCommand(JdbCommand.run())
.shouldContain("Breakpoint hit");
execCommand(JdbCommand.print("java.lang.Long.MAX_VALUE"))
.shouldContain(" = 9223372036854775807");
execCommand(JdbCommand.print("java.lang.Long.MIN_VALUE"))
.shouldContain(" = -9223372036854775808");
execCommand(JdbCommand.print("9223372036854775807L"))
.shouldContain("9223372036854775807L = 9223372036854775807");
execCommand(JdbCommand.print("9223372036854775807"))
.shouldContain("9223372036854775807 = 9223372036854775807");
execCommand(JdbCommand.print("-9223372036854775807L"))
.shouldContain("-9223372036854775807L = -9223372036854775807");
execCommand(JdbCommand.print("-9223372036854775807"))
.shouldContain("-9223372036854775807 = -9223372036854775807");
execCommand(JdbCommand.print("-1"))
.shouldContain("-1 = -1");
execCommand(JdbCommand.print("1L"))
.shouldContain("1L = 1");
execCommand(JdbCommand.print("-1L"))
.shouldContain("-1L = -1");
execCommand(JdbCommand.print("0x1"))
.shouldContain("0x1 = 1");
jdb.command(JdbCommand.set("JdbExprTestTarg.aLong", "9223372036854775807L"));
execCommand(JdbCommand.print("JdbExprTestTarg.aLong"))
.shouldContain("JdbExprTestTarg.aLong = 9223372036854775807");
jdb.command(JdbCommand.set("JdbExprTestTarg.anInt", "java.lang.Integer.MAX_VALUE + 1"));
execCommand(JdbCommand.print("JdbExprTestTarg.anInt"))
.shouldContain("JdbExprTestTarg.anInt = -2147483648");
jdb.command(JdbCommand.set("JdbExprTestTarg.aLong", "java.lang.Integer.MAX_VALUE + 1L"));
execCommand(JdbCommand.print("JdbExprTestTarg.aLong"))
.shouldContain("JdbExprTestTarg.aLong = 2147483648");
execCommand(JdbCommand.set("JdbExprTestTarg.anInt", "0x80000000"))
.shouldMatch("InvalidTypeException: .* convert 2147483648 to int");
execCommand(JdbCommand.set("JdbExprTestTarg.anInt", "0x8000000000000000L"))
.shouldContain("java.lang.NumberFormatException: For input string: \"8000000000000000\"");
execCommand(JdbCommand.set("JdbExprTestTarg.anInt", "0x7fffffff"))
.shouldContain("0x7fffffff = 2147483647");
execCommand(JdbCommand.set("JdbExprTestTarg.aLong", "0x7fffffffffffffff"))
.shouldContain("0x7fffffffffffffff = 9223372036854775807");
execCommand(JdbCommand.print("3.1415"))
.shouldContain("3.1415 = 3.1415");
execCommand(JdbCommand.print("-3.1415"))
.shouldContain("-3.1415 = -3.1415");
execCommand(JdbCommand.print("011"))
.shouldContain("011 = 9");
execCommand(JdbCommand.set("JdbExprTestTarg.aBoolean", "false"))
.shouldContain("JdbExprTestTarg.aBoolean = false = false");
execCommand(JdbCommand.print("JdbExprTestTarg.aBoolean"))
.shouldContain("JdbExprTestTarg.aBoolean = false");
execCommand(JdbCommand.print("!JdbExprTestTarg.aBoolean"))
.shouldContain("JdbExprTestTarg.aBoolean = true");
execCommand(JdbCommand.print("~1"))
.shouldContain("~1 = -2");
}
}

View File

@ -1,158 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4660158
# @author Staffan Larsen
# @key intermittent
# @run shell JdbExprTest.sh
# These are variables that can be set to control execution
#pkg=untitled7
classname=JdbExprTest
compileOptions=-g
#java="java_g"
#set -x
createJavaFile()
{
cat <<EOF > $classname.java.1
import java.util.*;
import java.net.URLClassLoader;
import java.net.URL;
class $classname {
static Long lMax = new Long(java.lang.Long.MAX_VALUE); // force initialization of Long class
static long aLong;
static int anInt;
static boolean aBoolean;
public static void bkpt() {
int i = 0; //@1 breakpoint
}
public static void main(String[] args) {
bkpt();
}
}
EOF
}
# drive jdb by sending cmds to it and examining its output
dojdbCmds()
{
setBkpts @1
runToBkpt @1
cmd print java.lang.Long.MAX_VALUE
jdbFailIfNotPresent " \= 9223372036854775807" 3
cmd print java.lang.Long.MIN_VALUE
jdbFailIfNotPresent " \= \-9223372036854775808" 3
cmd print 9223372036854775807L
jdbFailIfNotPresent "9223372036854775807L = 9223372036854775807" 3
cmd print 9223372036854775807
jdbFailIfNotPresent "9223372036854775807 = 9223372036854775807" 3
cmd print -9223372036854775807L
jdbFailIfNotPresent "\-9223372036854775807L = \-9223372036854775807" 3
cmd print -9223372036854775807
jdbFailIfNotPresent "\-9223372036854775807 = \-9223372036854775807" 3
cmd print -1
jdbFailIfNotPresent "\-1 = \-1" 3
cmd print 1L
jdbFailIfNotPresent "1L = 1" 3
cmd print -1L
jdbFailIfNotPresent "\-1L = \-1" 3
cmd print 0x1
jdbFailIfNotPresent "0x1 = 1" 3
cmd set $classname.aLong = 9223372036854775807L
cmd print $classname.aLong
jdbFailIfNotPresent "$classname.aLong = 9223372036854775807" 3
cmd set $classname.anInt = java.lang.Integer.MAX_VALUE + 1
cmd print $classname.anInt
jdbFailIfNotPresent "$classname.anInt = \-2147483648" 3
cmd set $classname.aLong = java.lang.Integer.MAX_VALUE + 1L
cmd print $classname.aLong
jdbFailIfNotPresent "$classname.aLong = 2147483648" 3
cmd set $classname.anInt = 0x80000000
jdbFailIfNotPresent "InvalidTypeException: .* convert 2147483648 to int" 3
cmd set $classname.anInt = 0x8000000000000000L
jdbFailIfNotPresent "java.lang.NumberFormatException: For input string: \"8000000000000000\"" 3
cmd set $classname.anInt = 0x7fffffff
jdbFailIfNotPresent "0x7fffffff = 2147483647" 3
cmd set $classname.aLong = 0x7fffffffffffffff
jdbFailIfNotPresent "0x7fffffffffffffff = 9223372036854775807" 3
cmd print 3.1415
jdbFailIfNotPresent "3.1415 = 3.1415" 3
cmd print -3.1415
jdbFailIfNotPresent "\-3.1415 = \-3.1415" 3
cmd print 011
jdbFailIfNotPresent "011 = 9" 3
cmd set $classname.aBoolean = false
jdbFailIfNotPresent "JdbExprTest.aBoolean = false = false" 3
cmd print $classname.aBoolean
jdbFailIfNotPresent "JdbExprTest.aBoolean = false" 3
cmd print !$classname.aBoolean
jdbFailIfNotPresent "JdbExprTest.aBoolean = true" 3
cmd print ~1
jdbFailIfNotPresent "~1 = -2" 3
}
mysetup()
{
if [ -z "$TESTSRC" ] ; then
TESTSRC=.
fi
for ii in . $TESTSRC $TESTSRC/.. ; do
if [ -r "$ii/ShellScaffold.sh" ] ; then
. $ii/ShellScaffold.sh
break
fi
done
}
# You could replace this next line with the contents
# of ShellScaffold.sh and this script will run just the same.
mysetup
runit
jdbFailIfNotPresent "Breakpoint hit"
pass

View File

@ -0,0 +1,305 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6202891
* @summary TTY: Add support for method exit event return values to jdb
* @comment converted from test/jdk/com/sun/jdi/JdbMethodExitTest.sh
*
* @library /test/lib
* @compile -g JdbMethodExitTest.java
* @run main/othervm JdbMethodExitTest
*/
import jdk.test.lib.process.OutputAnalyzer;
import lib.jdb.JdbCommand;
import lib.jdb.JdbTest;
import java.util.*;
import java.net.URLClassLoader;
import java.net.URL;
import java.util.stream.Collectors;
/*
* This tests the jdb trace command
*/
class JdbMethodExitTestTarg {
// These are the values that will be returned by the methods
static URL[] urls = new URL[1];
public static byte byteValue = 89;
public static char charValue = 'x';
public static double doubleValue = 2.2;
public static float floatValue = 3.3f;
public static int intValue = 1;
public static short shortValue = 8;
public static boolean booleanValue = false;
public static Class classValue = Object.class;
public static ClassLoader classLoaderValue;
{
try {
urls[0] = new URL("file:/foo");
} catch (java.net.MalformedURLException ee) {
}
classLoaderValue = new URLClassLoader(urls);
}
public static Thread threadValue;
public static ThreadGroup threadGroupValue;
public static String stringValue = "abc";
public static int[] intArrayValue = new int[] {1, 2, 3};
public static JdbMethodExitTestTarg objectValue =
new JdbMethodExitTestTarg();
public String ivar = stringValue;
// These are the instance methods
public byte i_bytef() { return byteValue; }
public char i_charf() { return charValue; }
public double i_doublef() { return doubleValue; }
public float i_floatf() { return floatValue; }
public int i_intf() { return intValue; }
public short i_shortf() { return shortValue; }
public boolean i_booleanf() { return booleanValue; }
public String i_stringf() { return stringValue; }
public Class i_classf() { return classValue; }
public ClassLoader i_classLoaderf()
{ return classLoaderValue; }
public Thread i_threadf() { return threadValue = Thread.currentThread(); }
public ThreadGroup i_threadGroupf()
{ return threadGroupValue = threadValue.getThreadGroup(); }
public int[] i_intArrayf() { return intArrayValue; }
public Object i_nullObjectf() { return null; }
public Object i_objectf() { return objectValue; }
public void i_voidf() {}
static void doit(JdbMethodExitTestTarg xx) {
xx.i_bytef();
xx.i_charf();
xx.i_doublef();
xx.i_floatf();
xx.i_intf();
xx.i_shortf();
xx.i_booleanf();
xx.i_stringf();
xx.i_intArrayf();
xx.i_classf();
xx.i_classLoaderf();
xx.i_threadf();
xx.i_threadGroupf();
xx.i_nullObjectf();
xx.i_objectf();
xx.i_voidf();
// Prove it works for native methods too
StrictMath.sin(doubleValue);
stringValue.intern();
}
public static void bkpt() {
int i = 0; //@1 breakpoint
}
public static String traceMethods() {
return "traceMethods";
}
public static String traceMethods1() {
return "traceMethods1";
}
public static String traceExits() {
return "traceExits";
}
public static String traceExits1() {
return "traceExits1";
}
public static String traceExit() {
return "traceExit";
}
public static String traceExit1() {
return "traceExit1";
}
public static void main(String[] args) {
// The debugger will stop at the start of main,
// enable method exit events, and then do
// a resume.
JdbMethodExitTestTarg xx = new JdbMethodExitTestTarg();
System.out.println("threadid="+Thread.currentThread().getId());
bkpt();
// test all possible return types
doit(xx);
bkpt();
// test trace methods
traceMethods();
// test trace go methods
traceMethods1();
bkpt();
// test trace method exits
traceExits();
// test trace method exits
traceExits1();
bkpt();
// test trace method exit
traceExit();
// test trace method exit
traceExit1();
bkpt();
}
}
public class JdbMethodExitTest extends JdbTest {
public static void main(String argv[]) {
new JdbMethodExitTest().run();
}
private JdbMethodExitTest() {
super(DEBUGGEE_CLASS);
}
private static final String DEBUGGEE_CLASS = JdbMethodExitTestTarg.class.getName();
@Override
protected void runCases() {
setBreakpoints(System.getProperty("test.src") + "/JdbMethodExitTest.java", 1);
// test all possible return types
execCommand(JdbCommand.run())
.shouldContain("Breakpoint hit");
Integer threadId = Integer.parseInt(
new OutputAnalyzer(jdb.getDebuggeeOutput())
.firstMatch("^threadid=(.*)$", 1));
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.traceMethods(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace methods in effect");
jdb.command(JdbCommand.traceMethods(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go methods in effect");
jdb.command(JdbCommand.traceMethodExits(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace method exits in effect");
jdb.command(JdbCommand.traceMethodExits(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go method exits in effect");
jdb.command(JdbCommand.traceMethodExit(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace method exit in effect for JdbMethodExitTestTarg.bkpt");
jdb.command(JdbCommand.traceMethodExit(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go method exit in effect for JdbMethodExitTestTarg.bkpt");
// trace exit of methods with all the return values
// (but just check a couple of them)
jdb.command(JdbCommand.traceMethodExits(true, threadId));
execCommand(JdbCommand.cont())
.shouldContain("instance of JdbMethodExitTestTarg")
.shouldContain("return value = 8");
// Get out of bkpt back to the call to traceMethods
jdb.command(JdbCommand.stepUp());
jdb.command(JdbCommand.traceMethods(false, threadId));
execCommand(JdbCommand.cont())
.shouldContain("Method entered:");
execCommand(JdbCommand.cont())
.shouldContain("Method exited: return value = \"traceMethods\"");
jdb.command(JdbCommand.stepUp());
List<String> reply = new LinkedList<>();
reply.addAll(jdb.command(JdbCommand.traceMethods(true, threadId)));
reply.addAll(jdb.command(JdbCommand.cont()));
reply.addAll(jdb.command(JdbCommand.cont()));
reply.addAll(jdb.command(JdbCommand.cont()));
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldContain("Method entered: \"thread=main\", JdbMethodExitTestTarg.traceMethods1")
.shouldMatch("Method exited: .* JdbMethodExitTestTarg.traceMethods1");
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.traceMethodExits(false, threadId)));
reply.addAll(jdb.command(JdbCommand.cont()));
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldContain("Method exited: return value = \"traceExits\"");
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.traceMethodExits(true, threadId)));
reply.addAll(jdb.command(JdbCommand.cont()));
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldMatch("Method exited: .* JdbMethodExitTestTarg.traceExits1");
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.step())); // step into traceExit()
reply.addAll(jdb.command(JdbCommand.traceMethodExit(false, threadId)));
reply.addAll(jdb.command(JdbCommand.cont()));
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldContain("Method exited: return value = \"traceExit\"");
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.step()));
reply.addAll(jdb.command(JdbCommand.step())); // skip over setting return value in caller :-(
reply.addAll(jdb.command(JdbCommand.traceMethodExit(true, threadId)));
reply.addAll(jdb.command(JdbCommand.cont()));
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldMatch("Method exited: .*JdbMethodExitTestTarg.traceExit1");
new OutputAnalyzer(jdb.getJdbOutput())
.shouldContain("Breakpoint hit");
}
}

View File

@ -1,308 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 6202891
# @summary TTY: Add support for method exit event return values to jdb
# @author Jim Holmlund
# @run shell JdbMethodExitTest.sh
# These are variables that can be set to control execution
#pkg=untitled7
classname=JdbMethodExitTest
compileOptions=-g
#java="java_g"
#set -x
createJavaFile()
{
cat <<EOF > $classname.java.1
import java.util.*;
import java.net.URLClassLoader;
import java.net.URL;
/*
* This tests the jdb trace command
*/
class $classname {
// These are the values that will be returned by the methods
static URL[] urls = new URL[1];
public static byte byteValue = 89;
public static char charValue = 'x';
public static double doubleValue = 2.2;
public static float floatValue = 3.3f;
public static int intValue = 1;
public static short shortValue = 8;
public static boolean booleanValue = false;
public static Class classValue = Object.class;
public static ClassLoader classLoaderValue;
{
try {
urls[0] = new URL("file:/foo");
} catch (java.net.MalformedURLException ee) {
}
classLoaderValue = new URLClassLoader(urls);
}
public static Thread threadValue;
public static ThreadGroup threadGroupValue;
public static String stringValue = "abc";
public static int[] intArrayValue = new int[] {1, 2, 3};
public static $classname objectValue =
new $classname();
public String ivar = stringValue;
// These are the instance methods
public byte i_bytef() { return byteValue; }
public char i_charf() { return charValue; }
public double i_doublef() { return doubleValue; }
public float i_floatf() { return floatValue; }
public int i_intf() { return intValue; }
public short i_shortf() { return shortValue; }
public boolean i_booleanf() { return booleanValue; }
public String i_stringf() { return stringValue; }
public Class i_classf() { return classValue; }
public ClassLoader i_classLoaderf()
{ return classLoaderValue; }
public Thread i_threadf() { return threadValue = Thread.currentThread(); }
public ThreadGroup i_threadGroupf()
{ return threadGroupValue = threadValue.getThreadGroup(); }
public int[] i_intArrayf() { return intArrayValue; }
public Object i_nullObjectf() { return null; }
public Object i_objectf() { return objectValue; }
public void i_voidf() {}
static void doit($classname xx) {
xx.i_bytef();
xx.i_charf();
xx.i_doublef();
xx.i_floatf();
xx.i_intf();
xx.i_shortf();
xx.i_booleanf();
xx.i_stringf();
xx.i_intArrayf();
xx.i_classf();
xx.i_classLoaderf();
xx.i_threadf();
xx.i_threadGroupf();
xx.i_nullObjectf();
xx.i_objectf();
xx.i_voidf();
// Prove it works for native methods too
StrictMath.sin(doubleValue);
stringValue.intern();
}
public static void bkpt() {
int i = 0; //@1 breakpoint
}
public static String traceMethods() {
return "traceMethods";
}
public static String traceMethods1() {
return "traceMethods1";
}
public static String traceExits() {
return "traceExits";
}
public static String traceExits1() {
return "traceExits1";
}
public static String traceExit() {
return "traceExit";
}
public static String traceExit1() {
return "traceExit1";
}
public static void main(String[] args) {
// The debugger will stop at the start of main,
// enable method exit events, and then do
// a resume.
$classname xx = new $classname();
System.out.println("threadid="+Thread.currentThread().getId());
bkpt();
// test all possible return types
doit(xx);
bkpt();
// test trace methods
traceMethods();
// test trace go methods
traceMethods1();
bkpt();
// test trace method exits
traceExits();
// test trace method exits
traceExits1();
bkpt();
// test trace method exit
traceExit();
// test trace method exit
traceExit1();
bkpt();
}
}
EOF
}
# drive jdb by sending cmds to it and examining its output
dojdbCmds()
{
setBkpts @1
# test all possible return types
runToBkpt @1
debuggeeMatchRegexp "s/threadid=\(.*\)/\1/g"
threadid=$?
cmd untrace
cmd trace methods
cmd trace
jdbFailIfNotPresent "trace methods in effect"
cmd trace go methods
cmd trace
jdbFailIfNotPresent "trace go methods in effect"
cmd trace method exits
cmd trace
jdbFailIfNotPresent "trace method exits in effect"
cmd trace go method exits
cmd trace
jdbFailIfNotPresent "trace go method exits in effect"
cmd trace method exit
cmd trace
jdbFailIfNotPresent "trace method exit in effect for JdbMethodExitTest.bkpt"
cmd trace go method exit
cmd trace
jdbFailIfNotPresent "trace go method exit in effect for JdbMethodExitTest.bkpt"
# trace exit of methods with all the return values
# (but just check a couple of them)
cmd trace go method exits $threadid
cmd cont
jdbFailIfNotPresent "instance of JdbMethodExitTest"
jdbFailIfNotPresent "return value = 8"
# Get out of bkpt back to the call to traceMethods
cmd step up
cmd trace methods $threadid
cmd cont
jdbFailIfNotPresent "Method entered:"
cmd cont
jdbFailIfNotPresent "Method exited: return value = \"traceMethods\""
cmd step up
cmd trace go methods $threadid
cmd cont
cmd cont
cmd cont
jdbFailIfNotPresent "Method entered: \"thread=main\", JdbMethodExitTest.traceMethods1"
jdbFailIfNotPresent 'Method exited: .* JdbMethodExitTest.traceMethods1'
cmd untrace
cmd step up
cmd trace method exits $threadid
cmd cont
jdbFailIfNotPresent "Method exited: return value = \"traceExits\""
cmd untrace
cmd step up
cmd trace go method exits $threadid
cmd cont
jdbFailIfNotPresent 'Method exited: .* JdbMethodExitTest.traceExits1'
cmd untrace
cmd step up
cmd step # step into traceExit()
cmd trace method exit $threadid
cmd cont
jdbFailIfNotPresent "Method exited: return value = \"traceExit\""
cmd untrace
cmd step up
cmd step
cmd step # skip over setting return value in caller :-(
cmd trace go method exit $threadid
cmd cont
jdbFailIfNotPresent 'Method exited: .*JdbMethodExitTest.traceExit1'
}
mysetup()
{
if [ -z "$TESTSRC" ] ; then
TESTSRC=.
fi
for ii in . $TESTSRC $TESTSRC/.. ; do
if [ -r "$ii/ShellScaffold.sh" ] ; then
. $ii/ShellScaffold.sh
break
fi
done
}
# You could replace this next line with the contents
# of ShellScaffold.sh and this script will run just the same.
mysetup
runit
jdbFailIfNotPresent "Breakpoint hit"
pass

View File

@ -148,4 +148,48 @@ public class JdbCommand {
return new JdbCommand("stop at " + targetClass + ":" + lineNum);
}
public static JdbCommand step() {
return new JdbCommand("step");
}
public static JdbCommand stepUp() {
return new JdbCommand("step up");
}
public static JdbCommand print(String expr) {
return new JdbCommand("print " + expr);
}
public static JdbCommand set(String lvalue, String expr) {
return new JdbCommand("set " + lvalue + " = " + expr);
}
// trace [go] methods [thread]
// -- trace method entries and exits.
// -- All threads are suspended unless 'go' is specified
// trace [go] method exit | exits [thread]
// -- trace the current method's exit, or all methods' exits
// -- All threads are suspended unless 'go' is specified
// untrace [methods] -- stop tracing method entrys and/or exits
public static JdbCommand trace(boolean go, String mode, Integer threadId) {
return new JdbCommand(" trace"
+ (go ? " go" : "")
+ (mode != null ? " " + mode : "")
+ (threadId != null ? " " + threadId.toString() : ""));
}
// prints trace status
public static JdbCommand trace() {
return trace(false, null, null);
}
public static JdbCommand traceMethods(boolean go, Integer threadId) {
return trace(go, "methods", threadId);
}
public static JdbCommand traceMethodExit(boolean go, Integer threadId) {
return trace(go, "method exit", threadId);
}
public static JdbCommand traceMethodExits(boolean go, Integer threadId) {
return trace(go, "method exits", threadId);
}
public static JdbCommand untrace() {
return new JdbCommand("untrace");
}
}

View File

@ -23,6 +23,8 @@
package lib.jdb;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@ -111,4 +113,8 @@ public abstract class JdbTest {
return setBreakpoints(jdb, debuggeeClass, debuggeeSourcePath, id);
}
protected OutputAnalyzer execCommand(JdbCommand cmd) {
List<String> reply = jdb.command(cmd);
return new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)));
}
}