8199379: [TESTBUG] Open source vm testbase JDB tests
Reviewed-by: mseledtsov, sspitsyn
This commit is contained in:
parent
37e51f4074
commit
619bf3a01c
test/hotspot/jtreg
ProblemList-graal.txtProblemList.txtTEST.groups
vmTestbase/nsk/jdb
caught_exception/caught_exception002
classes/classes001
classpath/classpath001
clear
clear002
clear003
clear004
down/down002
dump/dump002
eval/eval001
exclude/exclude001
fields/fields001
ignore/ignore001
interrupt/interrupt001
kill
klass/class001
list/list002
locals/locals002
methods/methods002
monitor/monitor001
next/next001
options
connect
connect001
connect002
connect003
connect004
connect005
listconnectors/listconnectors001
pop/pop001
pop_exception/pop_exception001
print/print002
read/read001
redefine/redefine001
reenter/reenter001
regression/b4689395
resume/resume002
run/run002
set
step/step002
step_up/step_up001
stop_at
stop_in/stop_in002
suspend/suspend001
thread/thread002
threadgroup/threadgroup002
threadgroups/threadgroups002
@ -134,6 +134,7 @@ vmTestbase/nsk/jdi/VirtualMachine/setDefaultStratum/setDefaultStratum002/setDefa
|
||||
vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses026/TestDescription.java 8195627 generic-all
|
||||
vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses028/TestDescription.java 8195627 generic-all
|
||||
vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses030/TestDescription.java 8195627 generic-all
|
||||
vmTestbase/nsk/jdb/wherei/wherei001/wherei001.java 8195627 generic-all
|
||||
|
||||
vmTestbase/vm/mlvm/anonloader/stress/oome/heap/Test.java 8186299 generic-all
|
||||
vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.java 8186299 generic-all
|
||||
|
@ -144,6 +144,8 @@ vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2none_a/TestDescription.java 8013
|
||||
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_b/TestDescription.java 8013267 generic-all
|
||||
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manySame_b/TestDescription.java 8013267 generic-all
|
||||
|
||||
vmTestbase/nsk/jdb/exclude/exclude001/exclude001.java 8197938 windows-all
|
||||
|
||||
vmTestbase/heapdump/JMapHeapCore/TestDescription.java 8023376,8001227,8051445 generic-all
|
||||
vmTestbase/heapdump/JMapMetaspaceCore/TestDescription.java 8023376,8001227,8051445 generic-all
|
||||
|
||||
|
@ -1257,9 +1257,10 @@ vmTestbase_largepages = \
|
||||
# JSR292 tests (invokedynamic AKA Multi-Language VM AKA Da Vinci Machine)
|
||||
vmTestbase_vm_mlvm = \
|
||||
vmTestbase/vm/mlvm
|
||||
|
||||
# Heap dump tests
|
||||
vmTestbase_vm_heapdump = \
|
||||
vmTestbase/heapdump/
|
||||
vmTestbase/heapdump
|
||||
|
||||
vmTestbase_vm_heapdump_quick = \
|
||||
vmTestbase/heapdump/OnOOMToFile/TestDescription.java \
|
||||
@ -1267,3 +1268,8 @@ vmTestbase_vm_heapdump_quick = \
|
||||
vmTestbase/heapdump/OnOOMToPath/TestDescription.java \
|
||||
vmTestbase/heapdump/JMapHeapCore/TestDescription.java \
|
||||
vmTestbase/heapdump/JMapMetaspace/TestDescription.java
|
||||
|
||||
# JDB tests
|
||||
vmTestbase_nsk_jdb = \
|
||||
vmTestbase/nsk/jdb
|
||||
|
||||
|
131
test/hotspot/jtreg/vmTestbase/nsk/jdb/caught_exception/caught_exception002/caught_exception002.java
Normal file
131
test/hotspot/jtreg/vmTestbase/nsk/jdb/caught_exception/caught_exception002/caught_exception002.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/caught_exception/caught_exception002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'catch caught <exception>' command.
|
||||
* When the debugee throws an exception that is caught somewhere
|
||||
* up in the program stack, jdb does not halt execution at the point
|
||||
* the exception was thrown but continues to execute the code in the catch
|
||||
* clause and proceed on with the rest of the program.
|
||||
* To halt execution at the throw point for exceptions
|
||||
* that are being caught - the 'catch' command has to be used.
|
||||
* The test throws ten exceptions that are on jdb's catch list
|
||||
* and verifies that jdb halts execution at the throw point each
|
||||
* time an exception is thrown.
|
||||
* COMMENTS
|
||||
* This test functionally equals to
|
||||
* nsk/jdb/caught_exception/caught_exception001 test and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.caught_exception.caught_exception002.caught_exception002
|
||||
* nsk.jdb.caught_exception.caught_exception002.caught_exception002a
|
||||
* @run main/othervm PropertyResolvingWrapper
|
||||
* nsk.jdb.caught_exception.caught_exception002.caught_exception002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.caught_exception.caught_exception002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class caught_exception002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new caught_exception002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.caught_exception.caught_exception002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".caught_exception002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final int MAX = 10;
|
||||
|
||||
/* ------------------------------------- */
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand._catch + " caught " + PACKAGE_NAME + ".MyException" + i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
checkCatch(reply, i);
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private void checkCatch (String[] reply, int i) {
|
||||
Paragrep grep;
|
||||
int count;
|
||||
String found;
|
||||
Vector v = new Vector();
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
v.add("Exception occurred");
|
||||
v.add(PACKAGE_NAME + ".MyException" + i);
|
||||
count = grep.find(v);
|
||||
if (count != 1) {
|
||||
log.complain("Failed to report catch of MyException" + i + " : " + count);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
148
test/hotspot/jtreg/vmTestbase/nsk/jdb/caught_exception/caught_exception002/caught_exception002a.java
Normal file
148
test/hotspot/jtreg/vmTestbase/nsk/jdb/caught_exception/caught_exception002/caught_exception002a.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.caught_exception.caught_exception002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class caught_exception002a {
|
||||
|
||||
/* TEST DEPENDANT VARIABLES AND CONSTANTS */
|
||||
static final String PACKAGE_NAME = "nsk.jdb.caught_exception.caught_exception002";
|
||||
|
||||
public static void main(String args[]) {
|
||||
caught_exception002a _caught_exception002a = new caught_exception002a();
|
||||
System.exit(caught_exception002.JCK_STATUS_BASE + _caught_exception002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
lastBreak();
|
||||
|
||||
int result = -1;
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
result = a(i);
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return caught_exception002.PASSED;
|
||||
}
|
||||
|
||||
public static int a(int i) {
|
||||
int result = -1;
|
||||
try {
|
||||
result = b(i);
|
||||
} catch (MyException0 e) {
|
||||
System.out.println("debugee's main(): caught MyException0");
|
||||
} catch (MyException1 e) {
|
||||
System.out.println("debugee's main(): caught MyException1");
|
||||
} catch (MyException2 e) {
|
||||
System.out.println("debugee's main(): caught MyException2");
|
||||
} catch (MyException3 e) {
|
||||
System.out.println("debugee's main(): caught MyException3");
|
||||
} catch (MyException4 e) {
|
||||
System.out.println("debugee's main(): caught MyException4");
|
||||
} catch (MyException5 e) {
|
||||
System.out.println("debugee's main(): caught MyException5");
|
||||
} catch (MyException6 e) {
|
||||
System.out.println("debugee's main(): caught MyException6");
|
||||
} catch (MyException7 e) {
|
||||
System.out.println("debugee's main(): caught MyException7");
|
||||
} catch (MyException8 e) {
|
||||
System.out.println("debugee's main(): caught MyException8");
|
||||
} catch (MyException9 e) {
|
||||
System.out.println("debugee's main(): caught MyException9");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int b(int i) throws MyException0, MyException1,
|
||||
MyException2, MyException3, MyException4, MyException5, MyException6,
|
||||
MyException7, MyException8, MyException9 {
|
||||
|
||||
switch(i) {
|
||||
case 0:
|
||||
throw new MyException0("MyException0");
|
||||
case 1:
|
||||
throw new MyException1("MyException1");
|
||||
case 2:
|
||||
throw new MyException2("MyException2");
|
||||
case 3:
|
||||
throw new MyException3("MyException3");
|
||||
case 4:
|
||||
throw new MyException4("MyException4");
|
||||
case 5:
|
||||
throw new MyException5("MyException5");
|
||||
case 6:
|
||||
throw new MyException6("MyException6");
|
||||
case 7:
|
||||
throw new MyException7("MyException7");
|
||||
case 8:
|
||||
throw new MyException8("MyException8");
|
||||
case 9:
|
||||
throw new MyException9("MyException9");
|
||||
default:
|
||||
return i*i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyException0 extends Exception {
|
||||
public MyException0 (String s) {super(s);}
|
||||
}
|
||||
class MyException1 extends Exception {
|
||||
public MyException1 (String s) {super(s);}
|
||||
}
|
||||
class MyException2 extends Exception {
|
||||
public MyException2 (String s) {super(s);}
|
||||
}
|
||||
class MyException3 extends Exception {
|
||||
public MyException3 (String s) {super(s);}
|
||||
}
|
||||
class MyException4 extends Exception {
|
||||
public MyException4 (String s) {super(s);}
|
||||
}
|
||||
class MyException5 extends Exception {
|
||||
public MyException5 (String s) {super(s);}
|
||||
}
|
||||
class MyException6 extends Exception {
|
||||
public MyException6 (String s) {super(s);}
|
||||
}
|
||||
class MyException7 extends Exception {
|
||||
public MyException7 (String s) {super(s);}
|
||||
}
|
||||
class MyException8 extends Exception {
|
||||
public MyException8 (String s) {super(s);}
|
||||
}
|
||||
class MyException9 extends Exception {
|
||||
public MyException9 (String s) {super(s);}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/classes/classes001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'classes' command.
|
||||
* The test checks if jdb correctly replies on 'classes' command.
|
||||
* The test passes when reply contains full names of all checked classes.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.classes.classes001.classes001
|
||||
* nsk.jdb.classes.classes001.classes001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.classes.classes001.classes001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.classes.classes001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class classes001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new classes001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.classes.classes001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".classes001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String NOT_VALID_SAMPLE = "is not a valid";
|
||||
|
||||
static String[] checkedClasses = {
|
||||
DEBUGGEE_CLASS,
|
||||
DEBUGGEE_CLASS + "$Inner1",
|
||||
DEBUGGEE_CLASS + "$Inner2",
|
||||
DEBUGGEE_CLASS + "$Inner3",
|
||||
DEBUGGEE_CLASS + "$Inner4",
|
||||
DEBUGGEE_CLASS + "$Inner5",
|
||||
DEBUGGEE_CLASS + "$Inner6",
|
||||
DEBUGGEE_CLASS + "$Inner7",
|
||||
DEBUGGEE_CLASS + "$Inner8",
|
||||
DEBUGGEE_CLASS + "$InnerInt1",
|
||||
DEBUGGEE_CLASS + "$InnerInt2",
|
||||
DEBUGGEE_CLASS + "$InnerInt3",
|
||||
DEBUGGEE_CLASS + "$InnerInt4",
|
||||
DEBUGGEE_CLASS + "$InnerInt5",
|
||||
PACKAGE_NAME + ".Outer1",
|
||||
PACKAGE_NAME + ".Outer2",
|
||||
PACKAGE_NAME + ".Outer3",
|
||||
PACKAGE_NAME + ".OuterInt1",
|
||||
PACKAGE_NAME + ".OuterInt2"
|
||||
};
|
||||
|
||||
/* ------------------------------------- */
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.classes);
|
||||
|
||||
for (int i = 0; i < checkedClasses.length; i++) {
|
||||
if (!checkClass(checkedClasses[i], reply)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkClass (String className, String[] reply) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(className);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to report class " + className);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.classes.classes001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class classes001a {
|
||||
|
||||
/* TEST DEPENDANT VARIABLES AND CONSTANTS */
|
||||
static final String PACKAGE_NAME = "nsk.jdb.classes.classes001";
|
||||
|
||||
public static void main(String args[]) {
|
||||
classes001a _classes001a = new classes001a();
|
||||
System.exit(classes001.JCK_STATUS_BASE + _classes001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
init();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return classes001.PASSED;
|
||||
}
|
||||
|
||||
class Inner1 {}
|
||||
interface InnerInt1 {}
|
||||
|
||||
public class Inner2 {}
|
||||
public interface InnerInt2 {}
|
||||
|
||||
private class Inner3 {}
|
||||
private interface InnerInt3 {}
|
||||
|
||||
protected class Inner4 {}
|
||||
protected interface InnerInt4 {}
|
||||
|
||||
abstract class Inner5 {}
|
||||
abstract interface InnerInt5 {}
|
||||
|
||||
final class Inner6 extends Inner5{}
|
||||
|
||||
class Inner7 extends Outer2{}
|
||||
class Inner8 implements OuterInt1, OuterInt2, InnerInt1, InnerInt2, InnerInt3, InnerInt4, InnerInt5 {}
|
||||
|
||||
private void init () {
|
||||
Outer1 o1 = new Outer1();
|
||||
Outer3 o3 = new Outer3();
|
||||
Inner1 i1 = new Inner1();
|
||||
Inner2 i2 = new Inner2();
|
||||
Inner3 i3 = new Inner3();
|
||||
Inner4 i4 = new Inner4();
|
||||
Inner6 i6 = new Inner6();
|
||||
Inner7 i7 = new Inner7();
|
||||
Inner8 i8 = new Inner8();
|
||||
|
||||
lastBreak();
|
||||
}
|
||||
}
|
||||
|
||||
class Outer1 {}
|
||||
interface OuterInt1 {}
|
||||
|
||||
abstract class Outer2 {}
|
||||
abstract interface OuterInt2 {}
|
||||
|
||||
final class Outer3 {}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/classpath/classpath001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* An "is it alive & breathing" test for the 'classpath' command.
|
||||
* The test passes if reply on 'classpath' command is not empty.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.classpath.classpath001.classpath001
|
||||
* nsk.jdb.classpath.classpath001.classpath001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.classpath.classpath001.classpath001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.classpath.classpath001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class classpath001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new classpath001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.classpath.classpath001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".classpath001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.classpath);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst("lasspath");
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to report classpath");
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.classpath.classpath001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class classpath001a {
|
||||
public static void main(String args[]) {
|
||||
classpath001a _classpath001a = new classpath001a();
|
||||
lastBreak();
|
||||
System.exit(classpath001.JCK_STATUS_BASE + _classpath001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return classpath001.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/clear/clear002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'clear <class_id>.<method>' command.
|
||||
* The test sets 3 breakpoints and then clears two of them after the
|
||||
* first breakpoint is reached. The tests verifies that jdb does not
|
||||
* halt execution at the cleared breakpoint.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.clear.clear002.clear002
|
||||
* nsk.jdb.clear.clear002.clear002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.clear.clear002.clear002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.clear.clear002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class clear002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new clear002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.clear.clear002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".clear002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String METHOD_TO_STOP = DEBUGGEE_CLASS + ".func5";
|
||||
static final String METHOD1_TO_CLEAR = DEBUGGEE_CLASS + ".func4";
|
||||
static final String METHOD2_TO_CLEAR = DEBUGGEE_CLASS + "$A.func7";
|
||||
static final String REMOVED_SAMPLE = "Removed:";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
log.display("Setting breakpoint in method: " + METHOD1_TO_CLEAR);
|
||||
jdb.setBreakpointInMethod(METHOD1_TO_CLEAR);
|
||||
|
||||
log.display("Setting breakpoint in method: " + METHOD2_TO_CLEAR);
|
||||
jdb.setBreakpointInMethod(METHOD2_TO_CLEAR);
|
||||
|
||||
log.display("Setting breakpoint in method: " + METHOD_TO_STOP);
|
||||
jdb.setBreakpointInMethod(METHOD_TO_STOP);
|
||||
|
||||
if (!checkClear (METHOD1_TO_CLEAR)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkClear (METHOD2_TO_CLEAR)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
|
||||
grep = new Paragrep(jdb.getTotalReply());
|
||||
count = grep.find(Jdb.BREAKPOINT_HIT);
|
||||
if (count != 2) {
|
||||
log.complain("Should hit 2 breakpoints.");
|
||||
log.complain("Breakpoint hit count reported: " + count);
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkBreakpoint (METHOD1_TO_CLEAR, grep)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkBreakpoint (METHOD2_TO_CLEAR, grep)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBreakpoint (String methodName, Paragrep grep) {
|
||||
String found;
|
||||
boolean result = true;
|
||||
int count;
|
||||
Vector v;
|
||||
|
||||
v = new Vector();
|
||||
v.add(Jdb.BREAKPOINT_HIT);
|
||||
v.add(methodName);
|
||||
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() > 0) {
|
||||
log.complain("Wrong hit at removed breakpoint in method:" + methodName);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkClear (String methodName) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
String[] reply;
|
||||
boolean result = true;
|
||||
int count;
|
||||
Vector v;
|
||||
|
||||
v = new Vector();
|
||||
v.add(REMOVED_SAMPLE);
|
||||
v.add(methodName);
|
||||
|
||||
log.display("Clearing breakpoint in method:" + methodName);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.clear + methodName);
|
||||
grep = new Paragrep(reply);
|
||||
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to clear breakpoint in method: " + methodName);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.clear.clear002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class clear002a {
|
||||
public static void main(String args[]) {
|
||||
clear002a _clear002a = new clear002a();
|
||||
lastBreak();
|
||||
System.exit(clear002.JCK_STATUS_BASE + _clear002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int i = func1(0) + A.func7(0);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return clear002.PASSED;
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i) + 1;
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
return func3(i) + 1;
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
return func4(i) + 1;
|
||||
}
|
||||
|
||||
public int func4(int i) {
|
||||
return func5(i) + 1;
|
||||
}
|
||||
|
||||
public int func5(int i) {
|
||||
return func6(i) + 1;
|
||||
}
|
||||
|
||||
public int func6(int i) {
|
||||
return i-5;
|
||||
}
|
||||
|
||||
static class A {
|
||||
public static int func7 (int i) {
|
||||
return i++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/clear/clear003.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A negative test case for the 'clear <class_id>.<method>' command.
|
||||
* The test sets 2 breakpoints and then tries to clear non-existent
|
||||
* breakpoint after the first breakpoint is reached. The tests verifies
|
||||
* that jdb correctly reports about attempt to clear non-existent
|
||||
* breakpoint.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.clear.clear003.clear003
|
||||
* nsk.jdb.clear.clear003.clear003a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.clear.clear003.clear003
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.clear.clear003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class clear003 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new clear003().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.clear.clear003";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".clear003";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String METHOD4 = "func4";
|
||||
static final String METHOD5 = "func5";
|
||||
static final String METHOD_TO_CLEAR = DEBUGGEE_CLASS + "." + METHOD4;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
log.display("Setting breakpoint in method: " + METHOD5);
|
||||
jdb.setBreakpointInMethod(DEBUGGEE_CLASS + "." + METHOD5);
|
||||
|
||||
log.display("Clearing breakpoint.");
|
||||
reply = jdb.receiveReplyFor(JdbCommand.clear + METHOD_TO_CLEAR);
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find("Removed:");
|
||||
if (count > 0) {
|
||||
log.complain("Cleared non-existent breakpoint in method: " + METHOD_TO_CLEAR);
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
|
||||
grep = new Paragrep(jdb.getTotalReply());
|
||||
count = grep.find(Jdb.BREAKPOINT_HIT);
|
||||
if (count != 2) {
|
||||
log.complain("Should hit 2 breakpoints.");
|
||||
log.complain("Breakpoint hit count reported: " + count);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.clear.clear003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class clear003a {
|
||||
public static void main(String args[]) {
|
||||
clear003a _clear003a = new clear003a();
|
||||
lastBreak();
|
||||
System.exit(clear003.JCK_STATUS_BASE + _clear003a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int i = func1(0);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return clear003.PASSED;
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i) + 1;
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
return func3(i) + 1;
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
int value;
|
||||
value = func4(i) + 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
public int func4(int i) {
|
||||
int value;
|
||||
value = func5(i) + 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
public int func5(int i) {
|
||||
int value;
|
||||
value = func6(i) + 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
public int func6(int i) {
|
||||
return i-5;
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/clear/clear004.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'clear <class_id:line>' command.
|
||||
* The test sets 3 breakpoints and then clears one after the first
|
||||
* breakpoint is reached. The tests verifies that jdb does not
|
||||
* halt execution at the cleared breakpoint.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/clear/clear004 test and
|
||||
* replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.clear.clear004.clear004
|
||||
* nsk.jdb.clear.clear004.clear004a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.clear.clear004.clear004
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.clear.clear004;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class clear004 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new clear004().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.clear.clear004";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".clear004";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String[] BREAKPOINTS = new String[]
|
||||
{ DEBUGGEE_CLASS + ":63",
|
||||
DEBUGGEE_CLASS + ":67",
|
||||
DEBUGGEE_CLASS + ":71" };
|
||||
static final String REMOVED_SAMPLE = "Removed:";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
for (int i = 0; i < BREAKPOINTS.length; i++) {
|
||||
log.display("Setting breakpoint at " + BREAKPOINTS[i]);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + BREAKPOINTS[i]);
|
||||
}
|
||||
|
||||
if (!checkClear (BREAKPOINTS[1])) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(3);
|
||||
|
||||
grep = new Paragrep(jdb.getTotalReply());
|
||||
count = grep.find(Jdb.BREAKPOINT_HIT);
|
||||
if (count != 3) {
|
||||
log.complain("Should hit 3 breakpoints.");
|
||||
log.complain("Breakpoint hit count reported: " + count);
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkBreakpoint (BREAKPOINTS[1], grep)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkBreakpoint (String breakpoint, Paragrep grep) {
|
||||
String found;
|
||||
boolean result = true;
|
||||
int count;
|
||||
Vector v;
|
||||
|
||||
v = new Vector();
|
||||
v.add(Jdb.BREAKPOINT_HIT);
|
||||
v.add(breakpoint);
|
||||
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() > 0) {
|
||||
log.complain("Wrong hit at removed breakpoint at:" + breakpoint);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkClear (String breakpoint) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
String[] reply;
|
||||
boolean result = true;
|
||||
int count;
|
||||
Vector v;
|
||||
|
||||
v = new Vector();
|
||||
v.add(REMOVED_SAMPLE);
|
||||
v.add(breakpoint);
|
||||
|
||||
log.display("Clearing breakpoint at: " + breakpoint);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.clear + breakpoint);
|
||||
grep = new Paragrep(reply);
|
||||
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to clear breakpoint at: " + breakpoint);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
package nsk.jdb.clear.clear004;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class clear004a {
|
||||
public static void main(String args[]) {
|
||||
clear004a _clear004a = new clear004a();
|
||||
lastBreak();
|
||||
System.exit(clear004.JCK_STATUS_BASE + _clear004a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int i = func1(0) + A.func7(0);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return clear004.PASSED;
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i) + 1;
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
return func3(i) + 1;
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
return func4(i) + 1; // this is line for breakpoint // clear004.BREAKPOINTS[0]
|
||||
}
|
||||
|
||||
public int func4(int i) {
|
||||
return func5(i) + 1; // this is line for cleared breakpoint // clear004.BREAKPOINTS[1]
|
||||
}
|
||||
|
||||
public int func5(int i) {
|
||||
return func6(i) + 1; // this is line for breakpoint // clear004.BREAKPOINTS[2]
|
||||
}
|
||||
|
||||
public int func6(int i) {
|
||||
return i-5;
|
||||
}
|
||||
|
||||
static class A {
|
||||
public static int func7 (int i) {
|
||||
return i++;
|
||||
}
|
||||
}
|
||||
}
|
133
test/hotspot/jtreg/vmTestbase/nsk/jdb/down/down002/down002.java
Normal file
133
test/hotspot/jtreg/vmTestbase/nsk/jdb/down/down002/down002.java
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/down/down002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This tests the jdb 'down' command. The test sets a breakpoint
|
||||
* at 'func5' method in debugged 'nsk.jdb.down.down002a' class and then
|
||||
* runs the debugee. Once, an execution suspends at 'func5' method,
|
||||
* the 'down' command is issued to the debugger several times.
|
||||
* The output is processed by counting the number of times
|
||||
* each method name appears in the stack trace. The test passes
|
||||
* if the obtained count matches the expected one.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/down/down001 test and
|
||||
* replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.down.down002.down002
|
||||
* nsk.jdb.down.down002.down002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.down.down002.down002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.down.down002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class down002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new down002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.down.down002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".down002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String[][] FRAMES = new String[][] {
|
||||
{"[1]", DEBUGGEE_CLASS + ".func5"},
|
||||
{"[2]", DEBUGGEE_CLASS + ".func4"},
|
||||
{"[3]", DEBUGGEE_CLASS + ".func3"},
|
||||
{"[4]", DEBUGGEE_CLASS + ".func2"},
|
||||
{"[5]", DEBUGGEE_CLASS + ".func1"},
|
||||
{"[6]", DEBUGGEE_CLASS + ".runIt"},
|
||||
{"[7]", DEBUGGEE_CLASS + ".main"}
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand.stop_in + DEBUGGEE_CLASS + ".func5");
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
for (int i = 0; i < (FRAMES.length-1); i++) {
|
||||
jdb.receiveReplyFor(JdbCommand.up);
|
||||
}
|
||||
|
||||
for (int i = 0; i < (FRAMES.length-1); i++) {
|
||||
jdb.receiveReplyFor(JdbCommand.down);
|
||||
jdb.receiveReplyFor(JdbCommand.where);
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
|
||||
for (int i = 1; i < (FRAMES.length-1); i++) {
|
||||
v = new Vector();
|
||||
v.add(FRAMES[i][0]);
|
||||
v.add(FRAMES[i][1]);
|
||||
count = grep.find(v);
|
||||
if (count != (i+1)) {
|
||||
failure("Unexpected number of the stack frame: " + FRAMES[i][1] +
|
||||
"\n\texpected value : " + (i+1) + ", got : " + count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.down.down002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class down002a {
|
||||
public static void main(String args[]) {
|
||||
down002a _down002a = new down002a();
|
||||
lastBreak();
|
||||
System.exit(down002.JCK_STATUS_BASE + _down002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int i = func1(0);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return down002.PASSED;
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i) + 1;
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
return func3(i) + 1;
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
return func4(i) + 1;
|
||||
}
|
||||
|
||||
public int func4(int i) {
|
||||
return func5(i) + 1;
|
||||
}
|
||||
|
||||
public int func5(int i) {
|
||||
return func6(i) + 1;
|
||||
}
|
||||
|
||||
public int func6(int i) {
|
||||
return i-5;
|
||||
}
|
||||
}
|
164
test/hotspot/jtreg/vmTestbase/nsk/jdb/dump/dump002/dump002.java
Normal file
164
test/hotspot/jtreg/vmTestbase/nsk/jdb/dump/dump002/dump002.java
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/dump/dump002.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the 'dump' command.
|
||||
* The test works as follows. Upon the debuggee is suspended
|
||||
* on breakpoint, jdb issues 'dump' command for an object
|
||||
* of debugged class and for element in array fields.
|
||||
* The test passes if all checked fields with their values
|
||||
* are listed.
|
||||
* The test consists of two parts:
|
||||
* dump002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* dump002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test replaces the nsk/jdb/dump/dump001 one.
|
||||
* Test fixed according to test bug:
|
||||
* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.dump.dump002.dump002
|
||||
* nsk.jdb.dump.dump002.dump002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.dump.dump002.dump002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.dump.dump002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class dump002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
compoundPromptIdent = COMPOUND_PROMPT_IDENT;
|
||||
return new dump002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.dump.dump002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".dump002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String COMPOUND_PROMPT_IDENT = "main";
|
||||
|
||||
static final String[] CHECKED_FIELDS = {
|
||||
"_dump002a",
|
||||
"iStatic",
|
||||
"iPrivate",
|
||||
"iProtect",
|
||||
"iPublic",
|
||||
"iFinal",
|
||||
"iTransient",
|
||||
"iVolatile",
|
||||
"iArray",
|
||||
"sStatic",
|
||||
"sPrivate",
|
||||
"sProtected",
|
||||
"sPublic",
|
||||
"sFinal",
|
||||
"sTransient",
|
||||
"sVolatile",
|
||||
"sArray",
|
||||
"fBoolean",
|
||||
"fByte",
|
||||
"fChar",
|
||||
"fDouble",
|
||||
"fFloat",
|
||||
"fInt",
|
||||
"fLong",
|
||||
"fShort"
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v = new Vector();
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.dump + DEBUGGEE_CLASS + "._dump002a");
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < CHECKED_FIELDS.length; i++) {
|
||||
v.setSize(0);
|
||||
v.add(CHECKED_FIELDS[i]);
|
||||
v.add("null");
|
||||
if (grep.find(v) > 0) {
|
||||
failure("The field is not dumped : " + CHECKED_FIELDS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
String checkedField = DEBUGGEE_CLASS + ".iArray[0]";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);
|
||||
checkField(reply, checkedField);
|
||||
|
||||
checkedField = DEBUGGEE_CLASS + ".sArray[0]";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.dump + checkedField);
|
||||
checkField(reply, checkedField);
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
void checkField (String[] reply, String fieldName) {
|
||||
Paragrep grep;
|
||||
Vector v = new Vector();
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
v.setSize(0);
|
||||
v.add(fieldName);
|
||||
v.add("null");
|
||||
if (grep.find(v) > 0) {
|
||||
failure("The field is not dumped : " + fieldName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.dump.dump002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class dump002a {
|
||||
static dump002a _dump002a = new dump002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(dump002.JCK_STATUS_BASE + _dump002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return dump002.PASSED;
|
||||
}
|
||||
|
||||
static int iStatic = 0;
|
||||
private int iPrivate = 1;
|
||||
protected int iProtect = 2;
|
||||
public int iPublic = 3;
|
||||
final int iFinal = 4;
|
||||
transient int iTransient = 5;
|
||||
volatile int iVolatile = 6;
|
||||
|
||||
static int [] iArray = { 7 };
|
||||
|
||||
static String sStatic = "zero";
|
||||
private String sPrivate = "one";
|
||||
protected String sProtected = "two";
|
||||
public String sPublic = "three";
|
||||
final String sFinal = "four";
|
||||
transient String sTransient = "five";
|
||||
volatile String sVolatile = "six";
|
||||
|
||||
static String [] sArray = { "seven" };
|
||||
|
||||
boolean fBoolean = true;
|
||||
byte fByte = Byte.MAX_VALUE;
|
||||
char fChar = Character.MAX_VALUE;
|
||||
double fDouble = Double.MAX_VALUE;
|
||||
float fFloat = Float.MAX_VALUE;
|
||||
int fInt = Integer.MAX_VALUE;
|
||||
long fLong = Long.MAX_VALUE;
|
||||
short fShort = Short.MAX_VALUE;
|
||||
}
|
143
test/hotspot/jtreg/vmTestbase/nsk/jdb/eval/eval001/eval001.java
Normal file
143
test/hotspot/jtreg/vmTestbase/nsk/jdb/eval/eval001/eval001.java
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/eval/eval001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'eval <expr>' command.
|
||||
* The test checks if jdb correctly prints values for the following
|
||||
* expressions:
|
||||
* - static field,
|
||||
* - instance field,
|
||||
* - element of array field,
|
||||
* - return value of a method,
|
||||
* - arithmetic expression of local variables,
|
||||
* - return value of public method of the java.lang.String class.
|
||||
* The test passes when all printed values are equal to expected ones.
|
||||
* The test consists of two program:
|
||||
* eval001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* eval001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.eval.eval001.eval001
|
||||
*
|
||||
* @comment make sure eval001a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.eval.eval001.eval001a
|
||||
* @compile -g:lines,source,vars eval001a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.eval.eval001.eval001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.eval.eval001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class eval001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new eval001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.eval.eval001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".eval001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String[][] checkedExpr = {
|
||||
{ DEBUGGEE_CLASS + ".myStaticField", "-2147483648" },
|
||||
{ DEBUGGEE_CLASS + "._eval001a.myInstanceField", "9223372036854775807" },
|
||||
{ DEBUGGEE_CLASS + "._eval001a.myArrayField[0][0].toString()", "ABCDE" },
|
||||
{ DEBUGGEE_CLASS + "._eval001a.myMethod()", "2147483647" },
|
||||
{ "myClass.toString().equals(\"abcde\")", "true"},
|
||||
{ "i + j + k", "777"},
|
||||
{ "new java.lang.String(\"Hello, World\").length()", "12"}
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// to get out of lastBreak()
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
|
||||
for (int i = 0; i < checkedExpr.length; i++) {
|
||||
if (!checkValue(checkedExpr[i][0], checkedExpr[i][1])) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkValue (String expr, String value) {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
Vector v;
|
||||
boolean result = true;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + expr);
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(value);
|
||||
if (found.length() <= 0) {
|
||||
log.complain("jdb failed to report value of expression: " + expr);
|
||||
log.complain("expected : " + value + " ;\nreported: " + (reply.length > 0? reply[0]: ""));
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.eval.eval001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class eval001a {
|
||||
|
||||
static eval001a _eval001a = new eval001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(eval001.JCK_STATUS_BASE + _eval001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
MyClass myClass = new MyClass("abcde");
|
||||
int i = 111;
|
||||
int j = 222;
|
||||
int k = 444;
|
||||
|
||||
synchronized (this) {
|
||||
lastBreak();
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return eval001.PASSED;
|
||||
}
|
||||
|
||||
static private int myStaticField = Integer.MIN_VALUE;
|
||||
protected long myInstanceField;
|
||||
public MyClass[][] myArrayField;
|
||||
|
||||
private eval001a () {
|
||||
myArrayField = new MyClass[][] {new MyClass[] {new MyClass("ABCDE")}};
|
||||
myInstanceField = Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
synchronized private int myMethod() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
static class MyClass {
|
||||
String line;
|
||||
|
||||
public MyClass (String s) {
|
||||
line = s;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/exclude/exclude001.
|
||||
* VM Testbase keywords: [jpda, jdb, quarantine]
|
||||
* VM Testbase comments: JDK-8191037
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'exclude' command.
|
||||
* The debuggee program (exclude001a.java) starts three
|
||||
* addional threads of MyThread class. The 'run' method of these
|
||||
* threads invokes java.lang.System.currentTimeMillis() and
|
||||
* com.sun.jdi.Bootstrap.virtualMachineManager() methods.
|
||||
* There are three test cases:
|
||||
* - block all exclude filter;
|
||||
* - modified exclude filter allowing tracing events for java.* methods,
|
||||
* which is set with 'exclude javax.*,sun.*,com.sun.*,jdk.*' command;
|
||||
* - modified exclude filter allowing tracing events for com.sun.* methods,
|
||||
* which is set with 'exclude java.*,javax.*,sun.*,jdk.*' command.
|
||||
* - non-modified, predefined exclude filter;
|
||||
* - modified exclude filter allowing tracing events for java.* methods,
|
||||
* which is set with 'exclude javax.*,sun.*,com.sun.*' command;
|
||||
* - modified exclude filter allowing tracing events for all system methods,
|
||||
* which is set with 'exclude none' command.
|
||||
* For each test case the correspondent MyThread thread is started and
|
||||
* suspended at a breakpoint. Then method tracing is turned on with
|
||||
* 'trace methods <thread id>' command with correspondent exclude filtering.
|
||||
* The test passes if debuggee suspends on method enter/exit of only
|
||||
* filtered classes, i.e. in comply with exclude filter previously set.
|
||||
* The test consists of two program:
|
||||
* exclude001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* exclude001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.exclude.exclude001.exclude001
|
||||
* nsk.jdb.exclude.exclude001.exclude001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.exclude.exclude001.exclude001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.exclude.exclude001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class exclude001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new exclude001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.exclude.exclude001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".exclude001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
|
||||
static final String JAVA_CORE_METHOD = "java.lang.System.currentTimeMillis";
|
||||
static final String COM_SUN_METHOD = "com.sun.jdi.Bootstrap.virtualMachineManager";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
String oldExclude = "";
|
||||
boolean javaTraced = false;
|
||||
boolean comTraced = false;
|
||||
boolean nskTraced = false;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
|
||||
// getting predefined 'exclude' value
|
||||
reply = jdb.receiveReplyFor(JdbCommand.exclude);
|
||||
if (reply.length == 0) {
|
||||
log.complain("Predefined excluded lists of classes is empty");
|
||||
success = false;
|
||||
} else {
|
||||
|
||||
oldExclude = reply[0];
|
||||
|
||||
for (int testCase = 0; testCase < exclude001a.numThreads; testCase++) {
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) {
|
||||
|
||||
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
|
||||
if (threads.length != 1) {
|
||||
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
} else {
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak;
|
||||
|
||||
switch (testCase) {
|
||||
case 0: // block all
|
||||
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,sun.*,com.sun.*,jdk.*");
|
||||
|
||||
break;
|
||||
case 1: // allow java.*
|
||||
reply = jdb.receiveReplyFor(JdbCommand.exclude + "javax.*,sun.*,com.sun.*,jdk.*");
|
||||
break;
|
||||
case 2: // allow com.sun.*
|
||||
reply = jdb.receiveReplyFor(JdbCommand.exclude + "java.*,javax.*,sun.*,jdk.");
|
||||
break;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.trace + "methods " + threads[0]);
|
||||
|
||||
while (true) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find(JAVA_CORE_METHOD);
|
||||
if (count > 0) {
|
||||
if (testCase != 0) {
|
||||
javaTraced = true;
|
||||
} else {
|
||||
log.complain("Trace message for excluded method: " + JAVA_CORE_METHOD);
|
||||
}
|
||||
}
|
||||
|
||||
count = grep.find(COM_SUN_METHOD);
|
||||
if (count > 0) {
|
||||
if (testCase == 2) {
|
||||
comTraced = true;
|
||||
} else {
|
||||
log.complain("Trace message for excluded method: " + COM_SUN_METHOD);
|
||||
}
|
||||
}
|
||||
|
||||
count = grep.find(DEBUGGEE_THREAD + ".run");
|
||||
if (count > 0) {
|
||||
nskTraced = true;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.exclude + oldExclude);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.untrace + "methods "+ threads[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
|
||||
if (!javaTraced) {
|
||||
log.complain("There were no tracing events for " + JAVA_CORE_METHOD + "() method while turned off filter");
|
||||
success = false;
|
||||
}
|
||||
if (!comTraced) {
|
||||
log.complain("There were no tracing events for " + COM_SUN_METHOD + "() method while turned off filter");
|
||||
success = false;
|
||||
}
|
||||
if (!nskTraced) {
|
||||
log.complain("There were no tracing events for " + DEBUGGEE_THREAD + ".run() method ");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.exclude.exclude001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class exclude001a {
|
||||
public static void main(String args[]) {
|
||||
exclude001a _exclude001a = new exclude001a();
|
||||
System.exit(exclude001.JCK_STATUS_BASE + _exclude001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 3; // number of threads.
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static Object waitnotify = new Object();
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread(MYTHREAD + "-" + i);
|
||||
holder[i].start();
|
||||
try {
|
||||
holder[i].join();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for finish of " + MYTHREAD + "-" + i);
|
||||
return exclude001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return exclude001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyThread extends Thread {
|
||||
String name;
|
||||
|
||||
public MyThread (String s) {
|
||||
super(s);
|
||||
name = s;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
exclude001a.lastBreak();
|
||||
|
||||
long time = java.lang.System.currentTimeMillis();
|
||||
|
||||
VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
|
||||
}
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/fields/fields001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'fields <class id>' command.
|
||||
* There are three test cases:
|
||||
* - request for the fields defined in class,
|
||||
* - request for the fields defined in inner class,
|
||||
* - request for the fields inherited from super class.
|
||||
* The test passes when reply contains names of all checked fields
|
||||
* for a given debuggee's class.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.fields.fields001.fields001
|
||||
* nsk.jdb.fields.fields001.fields001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.fields.fields001.fields001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.fields.fields001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class fields001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new fields001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.fields.fields001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".fields001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String DEBUGGEE_CLASS1 = DEBUGGEE_CLASS + "$Inner";
|
||||
static final String DEBUGGEE_CLASS2 = DEBUGGEE_CLASS + "$Extender";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String NOT_VALID_SAMPLE = "is not a valid";
|
||||
|
||||
static String[] checkedFields1 = {
|
||||
"i_st", "o_st",
|
||||
"i_pv", "o_pv",
|
||||
"i_pt", "o_pt",
|
||||
"i_pb", "o_pb",
|
||||
"i_fn", "o_fn",
|
||||
"i_tr", "o_tr",
|
||||
"i_vl", "o_vl",
|
||||
"i_a", "o_a",
|
||||
"i_aa", "o_aa",
|
||||
"i_aaa", "o_aaa"
|
||||
};
|
||||
|
||||
static String[] checkedFields2 = {
|
||||
"ii_pv", "oi_pv",
|
||||
"ii_pt", "oi_pt",
|
||||
"ii_pb", "oi_pb",
|
||||
"ii_fn", "oi_fn",
|
||||
"ii_tr", "oi_tr",
|
||||
"ii_vl", "oi_vl",
|
||||
"ii_a", "oi_a",
|
||||
"ii_aa", "oi_aa",
|
||||
"ii_aaa", "oi_aaa"
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS);
|
||||
if (!checkFields(DEBUGGEE_CLASS, reply, checkedFields1)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS1);
|
||||
if (!checkFields(DEBUGGEE_CLASS1, reply, checkedFields2)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS2);
|
||||
if (!checkFields(DEBUGGEE_CLASS2, reply, checkedFields2)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkFields (String className, String[] reply, String[] checkedFields) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < checkedFields.length; i++) {
|
||||
count = grep.find(checkedFields[i]);
|
||||
if (count == 0) {
|
||||
log.complain("Failed to report field " + checkedFields[i] + " for class " + className);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.fields.fields001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class fields001a {
|
||||
|
||||
/* TEST DEPENDANT VARIABLES AND CONSTANTS */
|
||||
static final String PACKAGE_NAME = "nsk.jdb.fields.fields001";
|
||||
|
||||
public static void main(String args[]) {
|
||||
fields001a _fields001a = new fields001a();
|
||||
System.exit(fields001.JCK_STATUS_BASE + _fields001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return fields001.PASSED;
|
||||
}
|
||||
|
||||
static int i_st;
|
||||
private int i_pv;
|
||||
protected int i_pt;
|
||||
public int i_pb;
|
||||
final int i_fn = 0;;
|
||||
transient int i_tr;
|
||||
volatile int i_vl;
|
||||
int [] i_a;
|
||||
int [][] i_aa;
|
||||
int [][][] i_aaa;
|
||||
|
||||
static Object o_st;
|
||||
private Object o_pv;
|
||||
protected Object o_pt;
|
||||
public Object o_pb;
|
||||
final Object o_fn = new Object();
|
||||
transient Object o_tr;
|
||||
volatile Object o_vl;
|
||||
Object [] o_a;
|
||||
Object [][] o_aa;
|
||||
Object [][][] o_aaa;
|
||||
|
||||
class Inner {
|
||||
private int ii_pv;
|
||||
protected int ii_pt;
|
||||
public int ii_pb;
|
||||
final int ii_fn = 0;;
|
||||
transient int ii_tr;
|
||||
volatile int ii_vl;
|
||||
int [] ii_a;
|
||||
int [][] ii_aa;
|
||||
int [][][] ii_aaa;
|
||||
|
||||
private Object oi_pv;
|
||||
protected Object oi_pt;
|
||||
public Object oi_pb;
|
||||
final Object oi_fn = new Object();
|
||||
transient Object oi_tr;
|
||||
volatile Object oi_vl;
|
||||
Object [] oi_a;
|
||||
Object [][] oi_aa;
|
||||
Object [][][] oi_aaa;
|
||||
}
|
||||
|
||||
class Extender extends Inner {};
|
||||
|
||||
Inner inner;
|
||||
Extender extender;
|
||||
|
||||
public fields001a() {
|
||||
inner = new Inner();
|
||||
extender = new Extender();
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/ignore/ignore001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'ignore <class_id>' command.
|
||||
* The tests sets catch hooks for two different exception
|
||||
* which are thrown in the debuggee. Then these hooks are
|
||||
* removed by 'ignore' command. The test checks the jdb does
|
||||
* not halt execution on removed catch hooks.
|
||||
* COMMENTS
|
||||
* The test was updated due fix of the bug 4683795.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.ignore.ignore001.ignore001
|
||||
* nsk.jdb.ignore.ignore001.ignore001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.ignore.ignore001.ignore001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.ignore.ignore001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ignore001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new ignore001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.ignore.ignore001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".ignore001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String EXCEPTION_SAMPLE = "Exception occurred:";
|
||||
static final String REMOVED_SAMPLE = "Removed:";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
// jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
|
||||
log.display("Setting catch for: " + nsk.jdb.ignore.ignore001.ignore001a.JAVA_EXCEPTION);
|
||||
reply = jdb.receiveReplyFor(JdbCommand._catch + " caught " + nsk.jdb.ignore.ignore001.ignore001a.JAVA_EXCEPTION);
|
||||
|
||||
log.display("Setting catch for: " + nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION1);
|
||||
reply = jdb.receiveReplyFor(JdbCommand._catch + " caught " + nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION1);
|
||||
|
||||
log.display("Setting catch for: " + nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION2);
|
||||
reply = jdb.receiveReplyFor(JdbCommand._catch + " caught " + nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION2);
|
||||
|
||||
for (;;) {
|
||||
if (!checkCatch(nsk.jdb.ignore.ignore001.ignore001a.JAVA_EXCEPTION)) {
|
||||
success = false;
|
||||
}
|
||||
if (!checkCatch(nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION1)) {
|
||||
success = false;
|
||||
}
|
||||
if (!checkCatch(nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION2)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkIgnore(nsk.jdb.ignore.ignore001.ignore001a.JAVA_EXCEPTION)) {
|
||||
success = false;
|
||||
}
|
||||
if (!checkIgnore(nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION1)) {
|
||||
success = false;
|
||||
}
|
||||
if (!checkIgnore(nsk.jdb.ignore.ignore001.ignore001a.USER_EXCEPTION2)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(6);
|
||||
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find(EXCEPTION_SAMPLE);
|
||||
if (count != 3) {
|
||||
success = false;
|
||||
log.complain("Should report 3 catched exceptions.");
|
||||
log.complain("Reported catched exception count is " + count);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkCatch (String exceptionName) {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
// log.display("Resuming debuggee.");
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
v = new Vector();
|
||||
v.add(EXCEPTION_SAMPLE);
|
||||
v.add(exceptionName);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to catch " + exceptionName);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkIgnore (String exceptionName) {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
log.display("Unsetting catch for: " + exceptionName);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.ignore + " caught " + exceptionName);
|
||||
|
||||
v = new Vector();
|
||||
v.add(REMOVED_SAMPLE);
|
||||
v.add(exceptionName);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(v);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to remove catch for " + exceptionName);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.ignore.ignore001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class ignore001a {
|
||||
|
||||
/* TEST DEPENDANT VARIABLES AND CONSTANTS */
|
||||
static final String PACKAGE_NAME = "nsk.jdb.ignore.ignore001";
|
||||
static final String JAVA_EXCEPTION = "java.lang.NumberFormatException";
|
||||
static final String USER_EXCEPTION1 = PACKAGE_NAME + ".ignore001a$Exception1";
|
||||
static final String USER_EXCEPTION2 = PACKAGE_NAME + ".Exception2";
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
public static void main(String args[]) {
|
||||
ignore001a _ignore001a = new ignore001a();
|
||||
System.exit(ignore001.JCK_STATUS_BASE + _ignore001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
// static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
a(i);
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return ignore001.PASSED;
|
||||
}
|
||||
|
||||
private void a (int i) {
|
||||
try {
|
||||
switch (i) {
|
||||
case 0: case 3:
|
||||
log.display("Throwing NumberFormatException, i = " + i);
|
||||
throw new java.lang.NumberFormatException();
|
||||
case 1: case 4:
|
||||
log.display("Throwing Exception1, i = " + i);
|
||||
throw new Exception1();
|
||||
case 2: case 5:
|
||||
log.display("Throwing Exception2, i = " + i);
|
||||
throw new Exception2();
|
||||
}
|
||||
} catch (java.lang.NumberFormatException e0) {
|
||||
} catch (Exception1 e1) {
|
||||
} catch (Exception2 e2) {
|
||||
}
|
||||
// lastBreak();
|
||||
}
|
||||
|
||||
class Exception1 extends Exception {}
|
||||
}
|
||||
|
||||
class Exception2 extends Exception {}
|
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/interrupt/interrupt001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'interrupt <thread id>' command.
|
||||
* The debuggee program (interrupt001a.java) creates a number of additional
|
||||
* threads with name like "MyThread-<number>" and starts them. The jdb
|
||||
* suspends the debuggee at a moment when the additional threads are
|
||||
* waiting for notification for lock objects and then tries to interrupt them.
|
||||
* If these threads are interrupted then a value of the special
|
||||
* "notInterrupted" variable should not be modified.
|
||||
* Value of "notInterrupted" variable is checked by "eval <expr>" command.
|
||||
* The test passes if the value is equal to 0 and fails otherwise..
|
||||
* COMMENTS
|
||||
* Modified due to fix of the bug:
|
||||
* 4760826 TTY: 'interrupt <threadID>' command sometimes does not work in Mantis
|
||||
* Modified due to fix of the bug:
|
||||
* 4974992 Missed prompt with jdb testcase nsk/jdb/interrupt/interrupt001
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.interrupt.interrupt001.interrupt001
|
||||
* nsk.jdb.interrupt.interrupt001.interrupt001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.interrupt.interrupt001.interrupt001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.interrupt.interrupt001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class interrupt001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
return new interrupt001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.interrupt.interrupt001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".interrupt001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = DEBUGGEE_CLASS + "$" + MYTHREAD;
|
||||
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notInterrupted.get()";
|
||||
|
||||
static int numThreads = nsk.jdb.interrupt.interrupt001.interrupt001a.numThreads;
|
||||
|
||||
private static Pattern tidPattern = Pattern.compile("(0x[0-9a-f]+)");
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
|
||||
if (threads.length != numThreads) {
|
||||
log.complain("jdb should report " + numThreads + " instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
}
|
||||
|
||||
pauseTillAllThreadsWaiting(threads);
|
||||
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.interrupt + threads[i]);
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.threads);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont, true);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_RESULT);
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
|
||||
if (found.length() > 0) {
|
||||
if (found.indexOf(DEBUGGEE_RESULT + " = 0") < 0) {
|
||||
log.complain("Not all " + MYTHREAD + "s were interrupted.");
|
||||
log.complain(found);
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("TEST BUG: not found value for " + DEBUGGEE_RESULT);
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private void pauseTillAllThreadsWaiting(String[] threads) {
|
||||
String[] reply;
|
||||
boolean tidswaiting = false;
|
||||
|
||||
Set<String> tids = new HashSet<>(Arrays.asList(threads));
|
||||
Set<String> waitingTids = null;
|
||||
|
||||
do {
|
||||
String[] thrdsRply = (String[])jdb.receiveReplyFor(JdbCommand.threads);
|
||||
waitingTids = Arrays.asList(thrdsRply).stream()
|
||||
.filter((r)-> r.endsWith("waiting"))
|
||||
.map((r)->{
|
||||
Matcher m = tidPattern.matcher(r);
|
||||
if (m.find()) {
|
||||
return m.group(1);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter((r)-> r != null)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// If all Tids are waiting set allWorkersAreWaiting to true so
|
||||
// the main test thread will get out of its breakpoint loop
|
||||
// and continue with the test.
|
||||
if (waitingTids.containsAll(tids)) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.set + DEBUGGEE_CLASS + ".allWorkersAreWaiting=true");
|
||||
tidswaiting = true;
|
||||
} else {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
}
|
||||
} while (!tidswaiting);
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.interrupt.interrupt001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class interrupt001a {
|
||||
private class MyThread extends Thread {
|
||||
final Object lock;
|
||||
int ind;
|
||||
String name;
|
||||
|
||||
public MyThread (Object l, int i, String n) {
|
||||
lock = l;
|
||||
ind = i;
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (lock) {
|
||||
synchronized (waitnotify) {
|
||||
threadRunning = true;
|
||||
waitnotify.notify();
|
||||
}
|
||||
|
||||
try {
|
||||
flags[ind] = false;
|
||||
while (!flags[ind]) {
|
||||
lock.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
notInterrupted.decrementAndGet();
|
||||
synchronized (waitnotify) {
|
||||
waitnotify.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
interrupt001a _interrupt001a = new interrupt001a();
|
||||
System.exit(interrupt001.JCK_STATUS_BASE + _interrupt001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void breakHere () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 5; // number of threads
|
||||
static volatile boolean allWorkersAreWaiting = false;
|
||||
|
||||
private final Object waitnotify = new Object();
|
||||
private volatile boolean threadRunning;
|
||||
private volatile boolean[] flags = new boolean[numThreads];
|
||||
|
||||
private JdbArgumentHandler argumentHandler;
|
||||
private Log log;
|
||||
|
||||
public static final AtomicInteger notInterrupted = new AtomicInteger(numThreads);
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
int i;
|
||||
Thread[] holder = new Thread[numThreads];
|
||||
Object[] locks = new Object[numThreads];
|
||||
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
locks[i] = new Object();
|
||||
holder[i] = new MyThread(locks[i], i, MYTHREAD + "-" + i);
|
||||
}
|
||||
|
||||
synchronized (waitnotify) {
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
holder[i].start();
|
||||
try {
|
||||
threadRunning = false;
|
||||
while (!threadRunning) {
|
||||
waitnotify.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for start of " + MYTHREAD + "-" + i);
|
||||
return interrupt001.FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// allWorkersAreWaiting will be set to true by the debugger thread
|
||||
// when it sees all of the worker treads are waiting.
|
||||
do {
|
||||
breakHere(); // a break to get thread ids and then to interrupt MyThreads.
|
||||
} while (!allWorkersAreWaiting);
|
||||
|
||||
long waitTime = argumentHandler.getWaitTime() * 60 * 1000;
|
||||
long startTime = System.currentTimeMillis();
|
||||
while (notInterrupted.get() > 0 && System.currentTimeMillis() - startTime <= waitTime) {
|
||||
synchronized (waitnotify) {
|
||||
try {
|
||||
waitnotify.wait(waitTime);
|
||||
} catch (InterruptedException e) {
|
||||
log.display("Main thread was interrupted while waiting");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
synchronized (locks[i]) {
|
||||
flags[i] = true;
|
||||
locks[i].notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to check if MyThreads were interrupted
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return interrupt001.PASSED;
|
||||
}
|
||||
}
|
148
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001.java
Normal file
148
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/kill/kill001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'kill <thread id> <expr>' command.
|
||||
* The debuggee program (kill001a.java) creates a number of additional
|
||||
* threads with name like "MyThread-<number>" and starts them. The jdb
|
||||
* suspends debuggee at moment when additional threads try to obtain
|
||||
* lock on synchronized object (previously locked in main thread)
|
||||
* and then tries to kill them. If these threads are killed then
|
||||
* a value of the special "notKilled" variable should not be modified.
|
||||
* Value of "notKilled" variable is checked by "eval <expr>" command.
|
||||
* The test passes if the value is equal to 0 and fails otherwise..
|
||||
* COMMENTS
|
||||
* Modified due to fix of the test bug:
|
||||
* 4940902 TEST_BUG: race in nsk/jdb/kill/kill001
|
||||
* Modified due to fix of the bug:
|
||||
* 5024081 TEST_BUG: nsk/jdb/kill/kill001 is slow
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.kill.kill001.kill001
|
||||
* nsk.jdb.kill.kill001.kill001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.kill.kill001.kill001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.kill.kill001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class kill001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
return new kill001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.kill.kill001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".kill001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notKilled";
|
||||
static final String DEBUGGEE_EXCEPTIONS = DEBUGGEE_CLASS + ".exceptions";
|
||||
|
||||
static int numThreads = nsk.jdb.kill.kill001.kill001a.numThreads;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
|
||||
if (threads.length != numThreads) {
|
||||
log.complain("jdb should report " + numThreads + " instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[i] + " " +
|
||||
DEBUGGEE_EXCEPTIONS + "[" + i + "]",
|
||||
"killed");
|
||||
}
|
||||
|
||||
for (int i = 0; i <= numThreads; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
}
|
||||
|
||||
// make sure the debugger is at a breakpoint
|
||||
if (!jdb.isAtBreakpoint(reply, LAST_BREAK)) {
|
||||
log.display("Expected breakpoint has not been hit yet");
|
||||
jdb.waitForMessage(0, LAST_BREAK);
|
||||
}
|
||||
log.display("Breakpoint has been hit");
|
||||
|
||||
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.eval + DEBUGGEE_RESULT,
|
||||
DEBUGGEE_RESULT + " =");
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
|
||||
if (found.length() > 0) {
|
||||
if (found.indexOf(DEBUGGEE_RESULT + " = 0") < 0) {
|
||||
log.complain("Not all " + MYTHREAD + "s were killed. " + found + " remaining");
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("Value for " + DEBUGGEE_RESULT + " is not found.");
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.threads);
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
163
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java
Normal file
163
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.kill.kill001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class kill001a {
|
||||
public static void main(String args[]) {
|
||||
kill001a _kill001a = new kill001a();
|
||||
System.exit(kill001.JCK_STATUS_BASE + _kill001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void breakHere () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 5; // number of threads. one lock per thread.
|
||||
static Object lock = new Object();
|
||||
static Object waitnotify = new Object();
|
||||
public static volatile int notKilled = 0;
|
||||
static final String message = "kill001a's Exception";
|
||||
static int waitTime;
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static final Throwable[] exceptions = {
|
||||
new ThreadDeath(),
|
||||
new NullPointerException(message),
|
||||
new SecurityException(message),
|
||||
new com.sun.jdi.IncompatibleThreadStateException(message),
|
||||
new MyException(message)
|
||||
};
|
||||
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
waitTime = argumentHandler.getWaitTime() * 60 * 1000;
|
||||
|
||||
int i;
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread(MYTHREAD + "-" + i);
|
||||
}
|
||||
|
||||
// lock monitor to prevent threads from finishing after they started
|
||||
synchronized (lock) {
|
||||
synchronized (waitnotify) {
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
holder[i].start();
|
||||
try {
|
||||
waitnotify.wait();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for start of " + MYTHREAD + "-" + i);
|
||||
return kill001.FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to get thread ids and then to kill MyThreads.
|
||||
}
|
||||
|
||||
// wait during watTime until all MyThreads will be killed
|
||||
long oldTime = System.currentTimeMillis();
|
||||
while ((System.currentTimeMillis() - oldTime) <= kill001a.waitTime) {
|
||||
boolean waited = false;
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
waited = true;
|
||||
try {
|
||||
synchronized(waitnotify) {
|
||||
waitnotify.wait(1000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.display("Main thread was interrupted while waiting for killing of " + MYTHREAD + "-" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!waited) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to check if MyThreads were killed
|
||||
log.display("notKilled == " + notKilled);
|
||||
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
log.display("Debuggee FAILED");
|
||||
return kill001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return kill001.PASSED;
|
||||
}
|
||||
|
||||
static class MyException extends Exception {
|
||||
MyException (String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyThread extends Thread {
|
||||
String name;
|
||||
|
||||
public MyThread (String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Concatenate strings in advance to avoid lambda calculations later
|
||||
String ThreadFinished = "WARNING: Thread finished: " + this.name;
|
||||
String ThreadInterrupted = "WARNING: Thread was interrupted while waiting for killing: " + this.name;
|
||||
kill001a.log.display("Thread started: " + this.name);
|
||||
|
||||
synchronized (kill001a.waitnotify) {
|
||||
kill001a.waitnotify.notify();
|
||||
}
|
||||
// prevent thread from early finish
|
||||
synchronized (kill001a.lock) {}
|
||||
|
||||
// sleep during waitTime to give debugger a chance to kill debugee's thread
|
||||
try {
|
||||
Thread.currentThread().sleep(kill001a.waitTime);
|
||||
} catch (InterruptedException e) {
|
||||
kill001a.log.display(ThreadInterrupted);
|
||||
e.printStackTrace(kill001a.log.getOutStream());
|
||||
}
|
||||
|
||||
kill001a.notKilled++;
|
||||
kill001a.log.display(ThreadFinished);
|
||||
}
|
||||
}
|
141
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill002/kill002.java
Normal file
141
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill002/kill002.java
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/kill/kill002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'kill <thread id> <expr>' command.
|
||||
* The debuggee program (kill002a.java) creates a number of additional
|
||||
* threads with name like "MyThread-<number>" and starts them. The jdb
|
||||
* suspends debuggee at moment when additional threads are
|
||||
* waiting for notification for lock objects and then tries to kill them.
|
||||
* If these threads are killed then a value of the special
|
||||
* "notKilled" variable should not be modified.
|
||||
* Value of "notKilled" variable is checked by "eval <expr>" command.
|
||||
* The test passes if the value is equal to 0 and fails otherwise..
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.kill.kill002.kill002
|
||||
* nsk.jdb.kill.kill002.kill002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.kill.kill002.kill002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.kill.kill002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class kill002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
return new kill002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.kill.kill002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".kill002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notKilled";
|
||||
static final String DEBUGGEE_EXCEPTIONS = DEBUGGEE_CLASS + ".exceptions";
|
||||
|
||||
static int numThreads = nsk.jdb.kill.kill002.kill002a.numThreads;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
|
||||
if (threads.length != numThreads) {
|
||||
log.complain("jdb should report " + numThreads + " instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[i] + " " +
|
||||
DEBUGGEE_EXCEPTIONS + "[" + i + "]",
|
||||
"killed");
|
||||
}
|
||||
reply = jdb.receiveReplyFor(JdbCommand.threads);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// make sure the debugger is at a breakpoint
|
||||
if (!jdb.isAtBreakpoint(reply, LAST_BREAK)) {
|
||||
log.display("Expected breakpoint has not been hit yet");
|
||||
jdb.waitForMessage(0, LAST_BREAK);
|
||||
}
|
||||
log.display("Breakpoint has been hit");
|
||||
|
||||
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.eval + DEBUGGEE_RESULT,
|
||||
DEBUGGEE_RESULT + " =");
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
|
||||
if (found.length() > 0) {
|
||||
if (found.indexOf(DEBUGGEE_RESULT + " = 0") < 0) {
|
||||
log.complain("Not all " + MYTHREAD + "s were killed. " + found + " remaining");
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("Value for " + DEBUGGEE_RESULT + " is not found.");
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(numThreads + 1);
|
||||
}
|
||||
}
|
146
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill002/kill002a.java
Normal file
146
test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill002/kill002a.java
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
package nsk.jdb.kill.kill002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class kill002a {
|
||||
public static void main(String args[]) {
|
||||
kill002a _kill002a = new kill002a();
|
||||
System.exit(kill002.JCK_STATUS_BASE + _kill002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void breakHere () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 5; // number of threads
|
||||
static Object waitnotify = new Object();
|
||||
public static volatile int notKilled = 0;
|
||||
static final String message = "kill002a's Exception";
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static final Exception[] exceptions = {
|
||||
new InterruptedException(message),
|
||||
new NullPointerException(message),
|
||||
new SecurityException(message),
|
||||
new com.sun.jdi.IncompatibleThreadStateException(message),
|
||||
new MyException(message)
|
||||
};
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
int i;
|
||||
Thread[] holder = new Thread[numThreads];
|
||||
Object[] locks = new Object[numThreads];
|
||||
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
locks[i] = new Object();
|
||||
holder[i] = new MyThread(locks[i], MYTHREAD + "-" + i);
|
||||
}
|
||||
|
||||
synchronized (waitnotify) {
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
holder[i].start();
|
||||
try {
|
||||
waitnotify.wait();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for start of " + MYTHREAD + "-" + i);
|
||||
return kill002.FAILED;
|
||||
}
|
||||
|
||||
synchronized (locks[i]) { // holder[i] must wait on its lock[i] at this moment.
|
||||
log.display("Thread " + MYTHREAD + "-" + i + " is waiting");
|
||||
}
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to get thread ids and then to kill MyThreads.
|
||||
|
||||
// waits on all MyThreads completion in case they were not killed
|
||||
for (i = 0; i < numThreads ; i++) {
|
||||
synchronized (locks[i]) {
|
||||
locks[i].notifyAll();
|
||||
}
|
||||
if (holder[i].isAlive() && !holder[i].interrupted()) {
|
||||
try {
|
||||
holder[i].join();
|
||||
} catch (InterruptedException e) {
|
||||
log.display("Main thread was interrupted while waiting for finish of " + MYTHREAD + "-" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to check if MyThreads were killed
|
||||
|
||||
log.display("notKilled == " + notKilled);
|
||||
log.display("Debuggee PASSED");
|
||||
return kill002.PASSED;
|
||||
}
|
||||
|
||||
static class MyException extends Exception {
|
||||
MyException (String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyThread extends Thread {
|
||||
Object lock;
|
||||
String name;
|
||||
|
||||
public MyThread (Object l, String n) {
|
||||
lock = l;
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Concatenate strings in advance to avoid lambda calculations later
|
||||
final String ThreadFinished = "WARNING: Thread finished: " + this.name;
|
||||
String ThreadInterrupted = "WARNING: Thread was interrupted while waiting for killing: " + this.name;
|
||||
kill002a.log.display("Thread started: " + this.name);
|
||||
|
||||
synchronized (lock) {
|
||||
synchronized (kill002a.waitnotify) {
|
||||
kill002a.waitnotify.notify();
|
||||
}
|
||||
|
||||
try {
|
||||
lock.wait();
|
||||
kill002a.notKilled++;
|
||||
kill002a.log.display(ThreadFinished);
|
||||
} catch (Exception e) {
|
||||
kill002a.log.display(ThreadInterrupted);
|
||||
e.printStackTrace(kill002a.log.getOutStream());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/class/class001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test case for the 'class <class_id>' command.
|
||||
* The test checks if jdb correctly replies on request for
|
||||
* given debuggee class via 'class' command.
|
||||
* The test fails if :
|
||||
* - string "is not a valid" found in reply,
|
||||
* - reply does not contain full name of a checked class.
|
||||
* Otherwise the test passes.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.klass.class001.class001
|
||||
* nsk.jdb.klass.class001.class001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.klass.class001.class001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.klass.class001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class class001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new class001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.klass.class001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".class001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String NOT_VALID_SAMPLE = "is not a valid";
|
||||
|
||||
static String[] checkedClasses = {
|
||||
DEBUGGEE_CLASS,
|
||||
DEBUGGEE_CLASS + "$InnerInt1",
|
||||
DEBUGGEE_CLASS + "$Inner2",
|
||||
DEBUGGEE_CLASS + "$Inner3",
|
||||
DEBUGGEE_CLASS + "$Inner4",
|
||||
DEBUGGEE_CLASS + "$Inner5",
|
||||
DEBUGGEE_CLASS + "$Inner6",
|
||||
PACKAGE_NAME + ".Outer1"
|
||||
};
|
||||
|
||||
/* ------------------------------------- */
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
for (int i = 0; i < checkedClasses.length; i++) {
|
||||
if (!checkClass(checkedClasses[i])) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkClass (String className) {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand._class + className);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(NOT_VALID_SAMPLE);
|
||||
if (found.length() > 0) {
|
||||
log.complain("Failed to report class " + className);
|
||||
result = false;
|
||||
}
|
||||
found = grep.findFirst(className);
|
||||
if (found.length() == 0) {
|
||||
log.complain("Failed to report class " + className);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.klass.class001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class class001a {
|
||||
|
||||
/* TEST DEPENDANT VARIABLES AND CONSTANTS */
|
||||
static final String PACKAGE_NAME = "nsk.jdb.klass.class001";
|
||||
|
||||
public static void main(String args[]) {
|
||||
class001a _class001a = new class001a();
|
||||
System.exit(class001.JCK_STATUS_BASE + _class001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
init();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return class001.PASSED;
|
||||
}
|
||||
|
||||
interface InnerInt1 {}
|
||||
public class Inner2 implements InnerInt1 {}
|
||||
private class Inner3 {}
|
||||
protected class Inner4 {}
|
||||
abstract class Inner5 {}
|
||||
final class Inner6 extends Inner5{}
|
||||
|
||||
private void init () {
|
||||
Outer1 o1 = new Outer1();
|
||||
Inner2 i2 = new Inner2();
|
||||
Inner3 i3 = new Inner3();
|
||||
Inner4 i4 = new Inner4();
|
||||
Inner6 i6 = new Inner6();
|
||||
|
||||
lastBreak();
|
||||
}
|
||||
}
|
||||
|
||||
class Outer1 {}
|
137
test/hotspot/jtreg/vmTestbase/nsk/jdb/list/list002/list002.java
Normal file
137
test/hotspot/jtreg/vmTestbase/nsk/jdb/list/list002/list002.java
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/list/list002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the 'list' command.
|
||||
* It lists the source of given method and the source on a given line.
|
||||
* The test passes if it find expected strings in jdb's output.
|
||||
* The test consists of two parts:
|
||||
* list002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* list002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test functionally equals to nsk/jdb/list/list001 test
|
||||
* and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @build nsk.jdb.list.list002.list002
|
||||
* nsk.jdb.list.list002.list002a
|
||||
* @run driver jdk.test.lib.FileInstaller list002a.java src/nsk/jdb/list/list002/list002a.java
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.list.list002.list002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* "-jdb.option=-sourcepath src/"
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.list.list002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class list002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new list002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.list.list002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".list002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".runIt";
|
||||
static final int LINE_NUMBER = 38;
|
||||
|
||||
final static String METHOD_SOURCE[] = new String[] {
|
||||
"public int runIt(String args[], PrintStream out) {",
|
||||
"JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);",
|
||||
"Log log = new Log(out, argumentHandler);",
|
||||
"log.display(\"Debuggee PASSED\");",
|
||||
"return list002.PASSED;"
|
||||
};
|
||||
|
||||
final static String LINE_SOURCE =
|
||||
"System.exit(list002.JCK_STATUS_BASE + _list002a.runIt(args, System.out));";
|
||||
|
||||
final static String SOURCE_NOT_FOUND = "Source file not found";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.list + "runIt");
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find(SOURCE_NOT_FOUND) > 0) {
|
||||
failure(reply[0]);
|
||||
} else {
|
||||
for (int i = 0; i < METHOD_SOURCE.length; i++) {
|
||||
if (grep.find(METHOD_SOURCE[i]) == 0) {
|
||||
failure("Line is not found in method sources:\n\t"+
|
||||
METHOD_SOURCE[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.list + LINE_NUMBER);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find(SOURCE_NOT_FOUND) > 0) {
|
||||
failure(reply[0]);
|
||||
} else {
|
||||
if (grep.find(LINE_SOURCE) == 0) {
|
||||
failure("Line " + LINE_NUMBER + " is not found:\n\t"+
|
||||
LINE_SOURCE);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.list.list002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class list002a {
|
||||
static list002a _list002a = new list002a();
|
||||
|
||||
public static void main(String args[]) { // list002.LINE_NUMBER
|
||||
System.exit(list002.JCK_STATUS_BASE + _list002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return list002.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/locals/locals002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the 'locals' command.
|
||||
* The test sets breakpoints in 'allKindsOfLocals' and 'allKindsOfArgs'
|
||||
* methods of debugged 'locals002a' class. Once the debuggee is
|
||||
* suspended in method, the test via 'locals' command compares
|
||||
* the values of all visible variables with expected ones.
|
||||
* The test consists of two parts:
|
||||
* locals002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* locals002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test functionally equals to nsk/jdb/locals/locals001 test
|
||||
* and replaces it.
|
||||
* Test fixed according to test bug:
|
||||
* 5045859 TEST_BUG: some JDB tests do not recognize JDB prompt
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.locals.locals002.locals002
|
||||
*
|
||||
* @comment make sure locals002a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.locals.locals002.locals002a
|
||||
* @compile -g:lines,source,vars locals002a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.locals.locals002.locals002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.locals.locals002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class locals002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
compoundPromptIdent = COMPOUND_PROMPT_IDENT;
|
||||
return new locals002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.locals.locals002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".locals002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String COMPOUND_PROMPT_IDENT = "main";
|
||||
static final int BREAKPOINT_LINE1 = 84;
|
||||
static final int BREAKPOINT_LINE2 = 100;
|
||||
|
||||
static final String LOCALS[][] = new String[][] {
|
||||
{ "boolVar" , "true" , "false" },
|
||||
{ "byteVar" , "27" , "12" },
|
||||
{ "charVar" , "V" , "A" },
|
||||
{ "shortVar" , "767" , "327" },
|
||||
{ "intVar" , "1474" , "3647" },
|
||||
{ "longVar" , "21345" , "65789" },
|
||||
{ "floatVar" , "3.141" , "4.852" },
|
||||
{ "doubleVar", "2.578" , "3.8976" },
|
||||
{ "objVar" , "objVarString" , "objArgString" },
|
||||
{ "arrVar" , "int[5]" , "int[3]" }
|
||||
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE1);
|
||||
jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE2);
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.locals);
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < LOCALS.length; i++) {
|
||||
v = new Vector();
|
||||
v.add(LOCALS[i][0]);
|
||||
v.add(LOCALS[i][2]);
|
||||
if (grep.find(v) == 0) {
|
||||
failure("Cannot find " + LOCALS[0][0] +
|
||||
" with expected value: " + LOCALS[i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.locals);
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < LOCALS.length; i++) {
|
||||
v = new Vector();
|
||||
v.add(LOCALS[i][0]);
|
||||
v.add(LOCALS[i][1]);
|
||||
if (grep.find(v) == 0) {
|
||||
failure("Cannot find " + LOCALS[0][0] +
|
||||
" with expected value: " + LOCALS[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkStop () {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
Vector v;
|
||||
boolean result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
package nsk.jdb.locals.locals002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class locals002a {
|
||||
static locals002a _locals002a = new locals002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(locals002.JCK_STATUS_BASE + _locals002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int arr[] = new int[3];
|
||||
|
||||
for (int i = 0 ; i < 3 ; i++) arr[i] = i*i;
|
||||
|
||||
allKindsOfVars (
|
||||
false,
|
||||
(byte)12,
|
||||
'A',
|
||||
(short)327,
|
||||
3647,
|
||||
(long)65789,
|
||||
(float)4.852,
|
||||
(double)3.8976,
|
||||
"objArgString",
|
||||
arr
|
||||
);
|
||||
|
||||
allKindsOfLocals();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return locals002.PASSED;
|
||||
}
|
||||
|
||||
public void allKindsOfVars (
|
||||
boolean boolVar,
|
||||
byte byteVar,
|
||||
char charVar,
|
||||
short shortVar,
|
||||
int intVar,
|
||||
long longVar,
|
||||
float floatVar,
|
||||
double doubleVar,
|
||||
Object objVar,
|
||||
int[] arrVar
|
||||
)
|
||||
{
|
||||
System.out.println("Arguments but no locals"); // locals002.BREAKPOINT_LINE1
|
||||
}
|
||||
|
||||
static void allKindsOfLocals() {
|
||||
boolean boolVar = true;
|
||||
byte byteVar = 27;
|
||||
char charVar = 'V';
|
||||
short shortVar = (short)767;
|
||||
int intVar = 1474;
|
||||
long longVar = (long)21345;
|
||||
float floatVar = (float)3.141;
|
||||
double doubleVar = (double)2.578;
|
||||
Object objVar = "objVarString";
|
||||
int[] arrVar = new int[5];
|
||||
|
||||
for (int j = 0; j < 5 ; j++) arrVar[j] = j;
|
||||
System.out.println("Locals but no arguments"); // locals002.BREAKPOINT_LINE2
|
||||
}
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/methods/methods002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the 'methods' command.
|
||||
* The test checks the following cases
|
||||
* - class with various method modifiers,
|
||||
* - class with various constructors,
|
||||
* - class with various overloaded methods,
|
||||
* - abstract class and interface,
|
||||
* - implementing class,
|
||||
* - class with inherited methods,
|
||||
* - class with inherited and overrided methods.
|
||||
* The test passes if signatures for all expected methods are listed
|
||||
* in reply on command for every case.
|
||||
* The test consists of two parts:
|
||||
* methods002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* methods002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* This test replaces the nsk/jdb/methods/methods001 one.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.methods.methods002.methods002
|
||||
* nsk.jdb.methods.methods002.methods002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.methods.methods002.methods002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.methods.methods002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class methods002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new methods002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.methods.methods002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".methods002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// Case for class with method modifiers
|
||||
String testedClass1 = TEST_CLASS + "a";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass1);
|
||||
for (int i = 1; i <= 33; i++) {
|
||||
checkMethod( reply, "m" + intToString(i), 1, testedClass1, testedClass1 );
|
||||
}
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
checkMethod( reply, "f" + intToString(i), 1, testedClass1, testedClass1 );
|
||||
}
|
||||
|
||||
// Case for class with many constructors
|
||||
String testedClass2 = TEST_CLASS + "b";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass2);
|
||||
String[] reply1 = toStringArray(reply); // on Windows reply is single string with embedded \r\n symbols
|
||||
checkMethod( reply1, "<init>", 4, testedClass2, testedClass2 );
|
||||
|
||||
// Case for class with overloaded methods
|
||||
String testedClass3 = TEST_CLASS + "c";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass3);
|
||||
reply1 = toStringArray(reply); // // on Windows reply is single string with embedded \r\n symbols
|
||||
checkMethod( reply1, "m01", 3, testedClass3, testedClass3 );
|
||||
|
||||
// Case for abstract class
|
||||
String testedClass4 = TEST_CLASS + "d";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass4);
|
||||
checkMethod( reply, "m01", 1, testedClass4, testedClass4 );
|
||||
|
||||
// Case for interface
|
||||
String testedClass5 = TEST_CLASS + "i";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass5);
|
||||
checkMethod( reply, "i01", 1, testedClass5, testedClass5 );
|
||||
|
||||
// Case for class with implemented method
|
||||
String testedClass6 = TEST_CLASS + "e";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass6);
|
||||
checkMethod( reply, "m01", 1, testedClass4, testedClass6 );
|
||||
checkMethod( reply, "i01", 1, testedClass5, testedClass6 );
|
||||
checkMethod( reply, "m01", 1, testedClass6, testedClass6 );
|
||||
|
||||
// Case for class with inherited methods
|
||||
String testedClass7 = TEST_CLASS + "f";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass7);
|
||||
for (int i = 1; i <= 33; i++) {
|
||||
checkMethod( reply, "m" + intToString(i), 1, testedClass1, testedClass7 );
|
||||
}
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
checkMethod( reply, "f" + intToString(i), 1, testedClass1, testedClass7 );
|
||||
}
|
||||
|
||||
// Case for class with inherited and overrided methods
|
||||
String testedClass8 = TEST_CLASS + "g";
|
||||
reply = jdb.receiveReplyFor(JdbCommand.methods + testedClass8);
|
||||
for (int i = 1; i <= 33; i++) {
|
||||
checkMethod( reply, "m" + intToString(i), 1, testedClass8, testedClass8 );
|
||||
}
|
||||
for (int i = 1; i <= 33; i++) {
|
||||
checkMethod( reply, "m" + intToString(i), 1, testedClass1, testedClass8 );
|
||||
}
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
checkMethod( reply, "f" + intToString(i), 1, testedClass1, testedClass8 );
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private void checkMethod (
|
||||
String[] reply, /* reply on 'methods' command */
|
||||
String methodName, /* method name */
|
||||
int expOccur, /* expected number of occurences of the method */
|
||||
String ownerClass, /* name of class defining method */
|
||||
String testedClass /* name of tested class */
|
||||
) {
|
||||
|
||||
Paragrep grep = new Paragrep(reply);
|
||||
Vector v = new Vector();
|
||||
|
||||
v.add(ownerClass);
|
||||
v.add(methodName);
|
||||
int j = grep.find(v);
|
||||
if (j != expOccur) {
|
||||
failure("Wrong number of occurences of method " + methodName +
|
||||
"\n\t of class " + ownerClass +
|
||||
"\n\t in class " + testedClass +
|
||||
"\n\t expected number: " + expOccur + " got: " + j);
|
||||
}
|
||||
}
|
||||
|
||||
private String[] toStringArray (String[] arr) {
|
||||
Vector v = new Vector();
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
StringTokenizer st = new StringTokenizer(arr[i], "\r\n");
|
||||
while (st.hasMoreTokens()) {
|
||||
v.add(st.nextToken());
|
||||
}
|
||||
}
|
||||
Object[] objects = v.toArray();
|
||||
String[] results = new String[objects.length];
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
results[i] = (String)objects[i];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private String intToString (int i) {
|
||||
String s = String.valueOf(i);
|
||||
if (s.length()==1)
|
||||
s = "0" + s;
|
||||
return s;
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.methods.methods002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class methods002a {
|
||||
static methods002a _methods002a = new methods002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(methods002.JCK_STATUS_BASE + _methods002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
methods002b b = new methods002b(1);
|
||||
methods002c c = new methods002c();
|
||||
methods002e e = new methods002e();
|
||||
methods002f f = new methods002f();
|
||||
methods002g g = new methods002g();
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return methods002.PASSED;
|
||||
}
|
||||
|
||||
static long lo;
|
||||
|
||||
// various method modifiers
|
||||
void m01 (long l) { lo = l; };
|
||||
private void m02 (long l) { lo = l; };
|
||||
protected void m03 (long l) { lo = l; };
|
||||
public void m04 (long l) { lo = l; };
|
||||
static void m05 (long l) { lo = l; };
|
||||
synchronized void m06 (long l) { lo = l; };
|
||||
strictfp void m07 (long l) { lo = l; };
|
||||
native void m08 (long l);
|
||||
public static synchronized strictfp void m09 (long l) { lo = l; };
|
||||
|
||||
long m10 (long l) { return lo + l; };
|
||||
private long m11 (long l) { return lo + l; };
|
||||
protected long m12 (long l) { return lo + l; };
|
||||
public long m13 (long l) { return lo + l; };
|
||||
static long m14 (long l) { return lo + l; };
|
||||
synchronized long m15 (long l) { return lo + l; };
|
||||
strictfp long m16 (long l) { return lo + l; };
|
||||
native long m17 (long l);
|
||||
public static synchronized strictfp long m18 (long l) { return lo + l; };
|
||||
|
||||
Object m19 () { return new Object(); };
|
||||
private Object m20 () { return new Object(); };
|
||||
protected Object m21 () { return new Object(); };
|
||||
public Object m22 () { return new Object(); };
|
||||
static Object m23 () { return new Object(); };
|
||||
synchronized Object m24 () { return new Object(); };
|
||||
strictfp Object m25 () { return new Object(); };
|
||||
native Object m26 ();
|
||||
public static synchronized strictfp Object m27 () { return new Object(); };
|
||||
|
||||
|
||||
// array methods
|
||||
double[] m28 () { return new double[1]; };
|
||||
double m29 (double[] arr) {return arr[0];};
|
||||
double[][] m30 (double[][] arr) {return arr;};
|
||||
|
||||
String[] m31 () { return new String[1];};
|
||||
String m32 (String[] arr) { return arr[0];};
|
||||
String[][] m33 (String[][] arr) {return arr;};
|
||||
|
||||
// final methods
|
||||
final void f01 (long l) { lo = l; };
|
||||
final long f02 (long l) { return lo + l; };
|
||||
final Object f03 () { return new Object(); };
|
||||
}
|
||||
|
||||
// Class with many constructors
|
||||
class methods002b {
|
||||
int ind;
|
||||
methods002b (int i) { ind = i; };
|
||||
|
||||
private methods002b (int i, int j) { ind = i+j; };
|
||||
protected methods002b (int i, int j, int k) { ind = i+j+k; };
|
||||
public methods002b (int i, int j, int k, int l) { ind = i+j+k+l; };
|
||||
}
|
||||
|
||||
// Class with overloaded methods
|
||||
class methods002c {
|
||||
int m01 (int i) { return i; };
|
||||
int m01 (int i, int j) { return i+j; };
|
||||
int m01 (int i, short j) { return i+j; };
|
||||
}
|
||||
|
||||
// Class with abstract methods
|
||||
abstract class methods002d {
|
||||
abstract void m01 ();
|
||||
}
|
||||
|
||||
interface methods002i {
|
||||
void i01 ();
|
||||
}
|
||||
|
||||
class methods002e extends methods002d implements methods002i {
|
||||
void m01 () {};
|
||||
public void i01 () {};
|
||||
}
|
||||
|
||||
// Class with inherited methods
|
||||
class methods002f extends methods002a {}
|
||||
|
||||
// Class with inherited and overrided method
|
||||
class methods002g extends methods002f {
|
||||
static long lo;
|
||||
|
||||
void m01 (long l) { lo = l; };
|
||||
private void m02 (long l) { lo = l; };
|
||||
protected void m03 (long l) { lo = l; };
|
||||
public void m04 (long l) { lo = l; };
|
||||
static void m05 (long l) { lo = l; };
|
||||
synchronized void m06 (long l) { lo = l; };
|
||||
strictfp void m07 (long l) { lo = l; };
|
||||
native void m08 (long l);
|
||||
public static synchronized strictfp void m09 (long l) { lo = l; };
|
||||
|
||||
long m10 (long l) { return lo + l; };
|
||||
private long m11 (long l) { return lo + l; };
|
||||
protected long m12 (long l) { return lo + l; };
|
||||
public long m13 (long l) { return lo + l; };
|
||||
static long m14 (long l) { return lo + l; };
|
||||
synchronized long m15 (long l) { return lo + l; };
|
||||
strictfp long m16 (long l) { return lo + l; };
|
||||
native long m17 (long l);
|
||||
public static synchronized strictfp long m18 (long l) { return lo + l; };
|
||||
|
||||
Object m19 () { return new Object(); };
|
||||
private Object m20 () { return new Object(); };
|
||||
protected Object m21 () { return new Object(); };
|
||||
public Object m22 () { return new Object(); };
|
||||
static Object m23 () { return new Object(); };
|
||||
synchronized Object m24 () { return new Object(); };
|
||||
strictfp Object m25 () { return new Object(); };
|
||||
native Object m26 ();
|
||||
public static synchronized strictfp Object m27 () { return new Object(); };
|
||||
|
||||
double[] m28 () { return new double[1]; };
|
||||
double m29 (double[] arr) {return arr[0];};
|
||||
double[][] m30 (double[][] arr) {return arr;};
|
||||
|
||||
String[] m31 () { return new String[1];};
|
||||
String m32 (String[] arr) { return arr[0];};
|
||||
String[][] m33 (String[][] arr) {return arr;};
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/monitor/monitor001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* A positive test for the 'monitor <command>' command.
|
||||
* The jdb sets up line breakpoint at the debugged application. Then four different
|
||||
* commands are set as a "monitor" by 'monitor <command>' command. After resuming the
|
||||
* debuggee stops at the breakpoint. All "monitored" commands should be executed.
|
||||
* The test passes if correct replies for all "monitored" commands are found in jdb stdout
|
||||
* stream.
|
||||
* The test consists of two program:
|
||||
* monitor001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* monitor001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test was updated due fix of the bug 4686159.
|
||||
* Test fixed according to test bug:
|
||||
* 5041797 TEST_BUG: race condition in JDB output readirectors
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.monitor.monitor001.monitor001
|
||||
* nsk.jdb.monitor.monitor001.monitor001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.monitor.monitor001.monitor001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.monitor.monitor001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class monitor001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new monitor001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.monitor.monitor001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".monitor001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final int LINE_NUMBER = 47;
|
||||
|
||||
static final String[] CHECKED_COMMANDS = {
|
||||
JdbCommand.threads,
|
||||
JdbCommand.methods + DEBUGGEE_CLASS,
|
||||
JdbCommand.fields + DEBUGGEE_CLASS,
|
||||
JdbCommand.eval + "(new java.lang.String(\"Hello, World\")).length()"
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + LINE_NUMBER);
|
||||
|
||||
for (int i = 0; i < CHECKED_COMMANDS.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.monitor + CHECKED_COMMANDS[i]);
|
||||
}
|
||||
|
||||
int repliesCount = CHECKED_COMMANDS.length + 1;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont, true, repliesCount);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.monitor);
|
||||
if (!checkMonitors(reply)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
reply = jdb.getTotalReply();
|
||||
if (!checkCommands(reply)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkMonitors(String[] reply) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
Vector v;
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < CHECKED_COMMANDS.length; i++) {
|
||||
if ((count = grep.find(CHECKED_COMMANDS[i])) != 1) {
|
||||
log.complain("Wrong number of monitor command: " + CHECKED_COMMANDS[i]);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkCommands(String[] reply) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
Vector v = new Vector();
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
|
||||
// check 'threads'
|
||||
v.add("java.lang.Thread");
|
||||
v.add("main");
|
||||
if ((count = grep.find(v)) != 1) {
|
||||
log.complain("Wrong number of execution of monitored command: " + CHECKED_COMMANDS[0]);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
// check 'methods'
|
||||
if ((count = grep.find("runIt(java.lang.String[], java.io.PrintStream)")) != 1) {
|
||||
log.complain("Wrong number of execution of monitored command: " + CHECKED_COMMANDS[1]);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
// check 'fields'
|
||||
if ((count = grep.find(DEBUGGEE_CLASS + " _monitor001a")) != 1) {
|
||||
log.complain("Wrong number of execution of monitored command: " + CHECKED_COMMANDS[2]);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
// check 'eval'
|
||||
if ((count = grep.find("length() = 12")) != 1) {
|
||||
log.complain("Wrong number of execution of monitored command: " + CHECKED_COMMANDS[3]);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.monitor.monitor001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class monitor001a {
|
||||
static monitor001a _monitor001a = new monitor001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(monitor001.JCK_STATUS_BASE + _monitor001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
int localInt = 0; // monitor001.LINE_NUMBER
|
||||
localInt++; // dummy breakpoint
|
||||
log.display("Debuggee PASSED");
|
||||
return monitor001.PASSED;
|
||||
}
|
||||
}
|
154
test/hotspot/jtreg/vmTestbase/nsk/jdb/next/next001/next001.java
Normal file
154
test/hotspot/jtreg/vmTestbase/nsk/jdb/next/next001/next001.java
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/next/next001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'next' command.
|
||||
* The debuggee program (next001a.java) creates two additional
|
||||
* threads of MyThread type and starts them. The jdb sets up breakpoint
|
||||
* inside the method 'func2' which is invoked in these addional threads.
|
||||
* When breakpoint is hitted the checked command is called at the line
|
||||
* in which debuggee's method ('func3') is invoked. After this,
|
||||
* the stack trace of the current method is checked by 'where' command.
|
||||
* The test passes if only calling method ('func2') presents in stack
|
||||
* trace, but not the called method ('func3').
|
||||
* The test consists of two program:
|
||||
* next001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* next001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.next.next001.next001
|
||||
* nsk.jdb.next.next001.next001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.next.next001.next001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.next.next001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class next001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new next001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.next.next001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".next001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
|
||||
static final String[] checkedMethods = {"func1", "func2", "func3"};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
|
||||
int breakCount = 0;
|
||||
int nextCount = 0;
|
||||
for (int i = 0; i < next001a.numThreads; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) {
|
||||
breakCount++;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.next);
|
||||
if (!checkNext()) {
|
||||
success = false;
|
||||
} else {
|
||||
nextCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (nextCount != next001a.numThreads) {
|
||||
log.complain("Wrong number of 'next' events: " + nextCount);
|
||||
log.complain("Must be equal to : " + next001a.numThreads);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkNext () {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
int count;
|
||||
boolean result = true;
|
||||
String[] reply;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[2]);
|
||||
if (count > 0) {
|
||||
log.complain("Debuggee is suspended in wrong method after 'next' command: " + DEBUGGEE_THREAD + "." + checkedMethods[2]);
|
||||
result= false;
|
||||
}
|
||||
|
||||
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[1]);
|
||||
if (count != 1) {
|
||||
log.complain("Checked method does not exist in thread stack trace: " + DEBUGGEE_THREAD + "." + checkedMethods[1]);
|
||||
result= false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.next.next001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class next001a {
|
||||
public static void main(String args[]) {
|
||||
next001a _next001a = new next001a();
|
||||
System.exit(next001.JCK_STATUS_BASE + _next001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 2; // number of threads.
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static Object waitnotify = new Object();
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread();
|
||||
holder[i].start();
|
||||
try {
|
||||
holder[i].join();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for finish of " + MYTHREAD + "-" + i);
|
||||
return next001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return next001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyThread extends Thread {
|
||||
public void run() {
|
||||
int runLocal = func1(100);
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i);
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
next001a.lastBreak();
|
||||
int int2 = func3(i); // this is the line before 'next' command
|
||||
return int2; // this is the line after 'next' command
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
return i*i;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/connect/connect001.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-connect' option with 'com.sun.jdi.CommandLineLaunch"
|
||||
* connector.
|
||||
* Jdb is started with particular connector argument.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.options.connect.connect001a" string
|
||||
* is found in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* connect001.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* connect001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test is similar to nsk/jdb/run/run002, but uses particular connector
|
||||
* overriding settings in ini-file.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.connect.connect001.connect001
|
||||
* nsk.jdb.options.connect.connect001.connect001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect001.connect001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -connector=launching
|
||||
* -transport=default
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class connect001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new connect001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected boolean shouldPass() {
|
||||
String feature = "com.sun.jdi.CommandLineLaunch";
|
||||
if (argumentHandler.shouldPass(feature)) {
|
||||
log.println("Test passes because of not implemented feature: " + feature);
|
||||
return true;
|
||||
}
|
||||
return super.shouldPass();
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class connect001a {
|
||||
static connect001a _connect001a = new connect001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(connect001.JCK_STATUS_BASE + _connect001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return connect001.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/connect/connect002.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-connect' option with 'com.sun.jdi.SocketAttach"
|
||||
* connector.
|
||||
* Jdb is started with particular connector argument.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.options.connect.connect002a" string
|
||||
* is found in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* connect002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* connect002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test is similar to nsk/jdb/run/run002, but uses particular connector
|
||||
* overriding settings in ini-file.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.connect.connect002.connect002
|
||||
* nsk.jdb.options.connect.connect002.connect002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect002.connect002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -connector=attaching
|
||||
* -transport=socket
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class connect002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new connect002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected boolean shouldPass() {
|
||||
String feature = "com.sun.jdi.SocketAttach";
|
||||
if (argumentHandler.shouldPass(feature)) {
|
||||
log.println("Test passes because of not implemented feature: " + feature);
|
||||
return true;
|
||||
}
|
||||
return super.shouldPass();
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class connect002a {
|
||||
static connect002a _connect002a = new connect002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(connect002.JCK_STATUS_BASE + _connect002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return connect002.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/connect/connect003.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-connect' option with 'com.sun.jdi.SharedMemoryAttach"
|
||||
* connector.
|
||||
* Jdb is started with particular connector argument.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.options.connect.connect003a" string
|
||||
* is found in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* connect003.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* connect003a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test is similar to nsk/jdb/run/run002, but uses particular connector
|
||||
* overriding settings in ini-file.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.connect.connect003.connect003
|
||||
* nsk.jdb.options.connect.connect003.connect003a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect003.connect003
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -connector=attaching
|
||||
* -transport=shmem
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class connect003 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new connect003().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect003";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect003";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected boolean shouldPass() {
|
||||
String feature = "com.sun.jdi.SharedMemoryAttach";
|
||||
if (argumentHandler.shouldPass(feature)) {
|
||||
log.println("Test passes because of not implemented feature: " + feature);
|
||||
return true;
|
||||
}
|
||||
return super.shouldPass();
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class connect003a {
|
||||
static connect003a _connect003a = new connect003a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(connect003.JCK_STATUS_BASE + _connect003a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return connect003.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/connect/connect004.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-connect' option with 'com.sun.jdi.SocketListen"
|
||||
* connector.
|
||||
* Jdb is started with particular connector argument.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.options.connect.connect004a" string
|
||||
* is found in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* connect004.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* connect004a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test is similar to nsk/jdb/run/run002, but uses particular connector
|
||||
* overriding settings in ini-file.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.connect.connect004.connect004
|
||||
* nsk.jdb.options.connect.connect004.connect004a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect004.connect004
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -connector=listening
|
||||
* -transport=socket
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect004;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class connect004 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new connect004().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect004";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect004";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected boolean shouldPass() {
|
||||
String feature = "com.sun.jdi.SocketListen";
|
||||
if (argumentHandler.shouldPass(feature)) {
|
||||
log.println("Test passes because of not implemented feature: " + feature);
|
||||
return true;
|
||||
}
|
||||
return super.shouldPass();
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect004;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class connect004a {
|
||||
static connect004a _connect004a = new connect004a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(connect004.JCK_STATUS_BASE + _connect004a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return connect004.PASSED;
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/connect/connect005.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-connect' option with 'com.sun.jdi.SharedMemoryListen"
|
||||
* connector.
|
||||
* Jdb is started with particular connector argument.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.options.connect.connect005a" string
|
||||
* is found in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* connect005.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* connect005a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test is similar to nsk/jdb/run/run002, but uses particular connector
|
||||
* overriding settings in ini-file.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.connect.connect005.connect005
|
||||
* nsk.jdb.options.connect.connect005.connect005a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.options.connect.connect005.connect005
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -connector=listening
|
||||
* -transport=shmem
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect005;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class connect005 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new connect005().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect.connect005";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect005";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected boolean shouldPass() {
|
||||
String feature = "com.sun.jdi.SharedMemoryListen";
|
||||
if (argumentHandler.shouldPass(feature)) {
|
||||
log.println("Test passes because of not implemented feature: " + feature);
|
||||
return true;
|
||||
}
|
||||
return super.shouldPass();
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.connect.connect005;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class connect005a {
|
||||
static connect005a _connect005a = new connect005a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(connect005.JCK_STATUS_BASE + _connect005a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return connect005.PASSED;
|
||||
}
|
||||
}
|
168
test/hotspot/jtreg/vmTestbase/nsk/jdb/options/listconnectors/listconnectors001/listconnectors001.java
Normal file
168
test/hotspot/jtreg/vmTestbase/nsk/jdb/options/listconnectors/listconnectors001/listconnectors001.java
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/options/listconnectors/listconnectors001.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for '-listconnectors' option of jdb.
|
||||
* This test checks that jdb started with tested option prints to stdout
|
||||
* list of connectors and transports, that includes all supported
|
||||
* connectors and transport configurations:
|
||||
* com.sun.jdi.CommandLineLaunch (dt_socket, dt_shmem)
|
||||
* com.sun.jdi.RawLineLaunch (dt_socket, dt_shmem)
|
||||
* com.sun.jdi.SocketAttach (dt_socket)
|
||||
* com.sun.jdi.SocketListen (dt_socket)
|
||||
* com.sun.jdi.SharedMemoryAttach (dt_shmem)
|
||||
* com.sun.jdi.SharedMemoryListen (dt_shmem)
|
||||
* Those configurations, which are not supported on tested platform,
|
||||
* are just ignored.
|
||||
* This test does not actually use debuggee class and any connectors
|
||||
* regardless of settings in ini-file, and the main test class
|
||||
* specifically overrides default behaviour of framework classes.
|
||||
* The test consists of one part:
|
||||
* listconnectors001.java - test driver, i.e. launches jdb
|
||||
* and checks its output.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.options.listconnectors.listconnectors001.listconnectors001
|
||||
* @run main/othervm PropertyResolvingWrapper
|
||||
* nsk.jdb.options.listconnectors.listconnectors001.listconnectors001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -jdb.option=-listconnectors
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.options.listconnectors.listconnectors001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class listconnectors001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new listconnectors001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.options.connect";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".connect001";
|
||||
static final String DEBUGGEE_CLASS = null;
|
||||
static final String FIRST_BREAK = null;
|
||||
static final String LAST_BREAK = null;
|
||||
|
||||
static final String TESTED_OPTION = "-listconnectors";
|
||||
static final String TESTED_CONNECTORS_LIST[] = {
|
||||
"com.sun.jdi.CommandLineLaunch", "dt_socket",
|
||||
"com.sun.jdi.CommandLineLaunch", "dt_shmem",
|
||||
"com.sun.jdi.RawCommandLineLaunch", "dt_socket",
|
||||
"com.sun.jdi.RawCommandLineLaunch", "dt_shmem",
|
||||
"com.sun.jdi.SocketAttach", "dt_socket",
|
||||
"com.sun.jdi.SocketListen", "dt_socket",
|
||||
"com.sun.jdi.SharedMemoryAttach", "dt_shmem",
|
||||
"com.sun.jdi.SharedMemoryListen", "dt_shmem",
|
||||
};
|
||||
static final int TESTED_CONNECTORS_COUNT = TESTED_CONNECTORS_LIST.length / 2;
|
||||
/*
|
||||
protected void launchJdbAndDebuggee(String debuggeeClass) throws Exception {
|
||||
String jdbExecPath = argumentHandler.getJdbExecPath();
|
||||
String args[] = {jdbExecPath, TESTED_OPTION};
|
||||
|
||||
launcher = new Launcher(argumentHandler, log);
|
||||
jdb = new Jdb(launcher);
|
||||
jdb.launch(args);
|
||||
}
|
||||
*/
|
||||
|
||||
protected void initJdb() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
// do noting
|
||||
}
|
||||
|
||||
protected void afterJdbExit() {
|
||||
String[] reply = jdb.getTotalReply();
|
||||
|
||||
for (int i = 0; i < TESTED_CONNECTORS_COUNT; i++) {
|
||||
String connector = TESTED_CONNECTORS_LIST[i*2 + 0];
|
||||
String transport = TESTED_CONNECTORS_LIST[i*2 + 1];
|
||||
Paragrep grep = new Paragrep(reply);
|
||||
|
||||
Vector<String> v = new Vector<String>();
|
||||
v.add(Jdb.SUPPORTED_CONNECTOR_NAME);
|
||||
v.add(connector);
|
||||
v.add(Jdb.SUPPORTED_TRANSPORT_NAME);
|
||||
if (!transport.equals("*")) {
|
||||
v.add(transport);
|
||||
}
|
||||
|
||||
int found = grep.find(v);
|
||||
if (found == 1) {
|
||||
display("expected connector found:\n"
|
||||
+ " connector: " + connector
|
||||
+ " transport: " + transport
|
||||
+ " found: " + found);
|
||||
} else if (found > 1) {
|
||||
failure("duplicated connector found (see jdb.stdout):\n"
|
||||
+ " connector: " + connector
|
||||
+ " transport: " + transport
|
||||
+ " found: " + found);
|
||||
} else if (argumentHandler.shouldPass(connector)
|
||||
|| argumentHandler.shouldPass(connector, transport)) {
|
||||
display("unsupported connector not found:\n"
|
||||
+ " connector: " + connector
|
||||
+ " transport: " + transport
|
||||
+ " found: " + found);
|
||||
} else {
|
||||
failure("no expected connector found (see jdb.stdout):\n"
|
||||
+ " connector: " + connector
|
||||
+ " transport: " + transport
|
||||
+ " found: " + found);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
176
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop/pop001/pop001.java
Normal file
176
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop/pop001/pop001.java
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/pop/pop001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* A positive test case for the 'pop' command.
|
||||
* The debugged application (pop001a.java) starts additional thread of MyThread
|
||||
* class. The 'run()' method of the this class invokes recursively a number of
|
||||
* int methods. The jdb sets breakpoint in the last called 'func5()' method
|
||||
* to suspend the debugged VM when all the methods, i.e. from 'func1()' to
|
||||
* 'func5()', are in MyThread's stack. Then jdb steps up three frame on stack
|
||||
* by 'up 3' command. At this moment frame with 'func2()' is current.
|
||||
* Then the 'pop' command is called. The test passes if after execution of
|
||||
* tested command the 'func1()' frame becomes current and jdb correctly reports
|
||||
* the thread stack and local variable(s) of the current frame.
|
||||
* The test consists of two program:
|
||||
* pop001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* pop001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.pop.pop001.pop001
|
||||
* nsk.jdb.pop.pop001.pop001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.pop.pop001.pop001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.pop.pop001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class pop001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new pop001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.pop.pop001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".pop001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
static final String[] CHECKED_METHODS = {"func1", "func2", "func3", "func4", "func5"};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
while (true) {
|
||||
String[] threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
if (threads.length != 1) {
|
||||
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.thread + threads[0]);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak()
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func5", "[1]", "lastBreak", false)) {
|
||||
success = false;
|
||||
}
|
||||
reply = jdb.receiveReplyFor(JdbCommand.up + " 3");
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func2", "[4]", "func3", false)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.pop);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func1", "[1]", "func2", true)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.locals);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("Internal exception") > 0) {
|
||||
log.complain("Internal exception was thrown while 'locals' command");
|
||||
for (int i = 0; i < reply.length; i++) {
|
||||
log.complain(reply[i]);
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
}
|
||||
|
||||
private boolean checkStack (String[] reply, String shouldBe, String frameNum, String shouldNotBe, boolean pop ) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
Vector v = new Vector();
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
v.add(frameNum);
|
||||
v.add(DEBUGGEE_THREAD + "." + shouldBe);
|
||||
if ((count = grep.find(v)) != 1) {
|
||||
log.complain("Contents of stack trace is incorrect " + ( pop? "after 'pop' command": ""));
|
||||
log.complain("Searched for: " + DEBUGGEE_THREAD + "." + shouldBe);
|
||||
log.complain("Count : " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (grep.find(DEBUGGEE_THREAD + "." + shouldNotBe) > 0) {
|
||||
log.complain("Contents of stack trace is incorrect " + ( pop? "after 'pop' command": ""));
|
||||
log.complain("Found wrong frame: " + DEBUGGEE_THREAD + "." + shouldNotBe);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
117
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop/pop001/pop001a.java
Normal file
117
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop/pop001/pop001a.java
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.pop.pop001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class pop001a {
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static pop001a _pop001a = new pop001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(pop001.JCK_STATUS_BASE + _pop001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
MyThread myThread = new MyThread(MYTHREAD);
|
||||
myThread.start();
|
||||
|
||||
if (myThread.isAlive()) {
|
||||
try {
|
||||
myThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for finish of " + MYTHREAD);
|
||||
return pop001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return pop001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
public MyThread (String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
pop001a.log.display("run() started");
|
||||
int runLocal;
|
||||
int j = func1(0);
|
||||
pop001a.log.display("run() finished");
|
||||
}
|
||||
|
||||
public int func1(int intParam) {
|
||||
pop001a.log.display("func1() started");
|
||||
int func1Local;
|
||||
intParam++;
|
||||
return func2(intParam);
|
||||
}
|
||||
|
||||
public int func2(int intParam) {
|
||||
pop001a.log.display("func2() started");
|
||||
int func2Local;
|
||||
intParam++;
|
||||
return func3(intParam);
|
||||
}
|
||||
|
||||
public int func3(int intParam) {
|
||||
pop001a.log.display("func3() started");
|
||||
int func3Local;
|
||||
intParam++;
|
||||
return func4(intParam);
|
||||
}
|
||||
|
||||
public int func4(int intParam) {
|
||||
pop001a.log.display("func4() started");
|
||||
int func4Local;
|
||||
intParam++;
|
||||
return func5(intParam);
|
||||
}
|
||||
|
||||
public int func5(int intParam) {
|
||||
pop001a.log.display("func5() started");
|
||||
int func5Local;
|
||||
intParam++;
|
||||
pop001a.lastBreak();
|
||||
return intParam;
|
||||
}
|
||||
}
|
111
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop_exception/pop_exception001/pop_exception001.java
Normal file
111
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop_exception/pop_exception001/pop_exception001.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/pop_exception/pop_exception001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* Test for cr 6972759 "Step over not working after thrown exception and Pop"
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.pop_exception.pop_exception001.pop_exception001
|
||||
* nsk.jdb.pop_exception.pop_exception001.pop_exception001a
|
||||
* @run main/othervm PropertyResolvingWrapper
|
||||
* nsk.jdb.pop_exception.pop_exception001.pop_exception001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.pop_exception.pop_exception001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class pop_exception001 extends JdbTest {
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.pop_exception.pop_exception001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".pop_exception001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new pop_exception001().runTest(argv, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void runCases() {
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand._catch + "java.lang.NullPointerException");
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
//exception
|
||||
jdb.receiveReplyFor(JdbCommand.pop);
|
||||
jdb.receiveReplyFor(JdbCommand.pop);
|
||||
jdb.receiveReplyFor(JdbCommand.ignore + "java.lang.NullPointerException");
|
||||
jdb.receiveReplyFor(JdbCommand.step);
|
||||
jdb.receiveReplyFor(JdbCommand.next);
|
||||
jdb.receiveReplyFor(JdbCommand.next);
|
||||
String[] reply = jdb.receiveReplyFor(JdbCommand.next);
|
||||
|
||||
jdb.quit();
|
||||
checkJdbReply(reply);
|
||||
}
|
||||
|
||||
private void checkJdbReply(String[] jdbReply) {
|
||||
String replyString = "";
|
||||
for(String s: jdbReply) {
|
||||
replyString += s;
|
||||
if(s.contains("line=")){
|
||||
if(!s.contains("line=" + pop_exception001a.expectedFinish)) {
|
||||
throw new Failure("FAILED: Expected location: line=" + pop_exception001a.expectedFinish + "\n found: " + s);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Failure("FAILED: Couldn't determinate finish position: " + replyString);
|
||||
}
|
||||
}
|
68
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop_exception/pop_exception001/pop_exception001a.java
Normal file
68
test/hotspot/jtreg/vmTestbase/nsk/jdb/pop_exception/pop_exception001/pop_exception001a.java
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.pop_exception.pop_exception001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
/**
|
||||
* debugee application
|
||||
*/
|
||||
public class pop_exception001a {
|
||||
public static void main(String args[]) {
|
||||
pop_exception001a _pop_exception001a = new pop_exception001a();
|
||||
System.exit(Consts.JCK_STATUS_BASE + _pop_exception001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
int i = 0;
|
||||
Object item = null;
|
||||
try {
|
||||
item = new Object();
|
||||
i = 5; // expectedFinish
|
||||
item = getItem(i);
|
||||
} finally {
|
||||
System.out.println("item = "+item);
|
||||
}
|
||||
return Consts.TEST_PASSED;
|
||||
}
|
||||
|
||||
private Object getItem(int i) {
|
||||
if (i == 5) {
|
||||
throw new NullPointerException("Something went wrong");
|
||||
} else {
|
||||
return new Integer(i);
|
||||
}
|
||||
}
|
||||
|
||||
public final static String expectedFinish = "51";
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/print/print002.
|
||||
* VM Testbase keywords: [quick, jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This is a test for the 'print <expr>' command.
|
||||
* The test checks if jdb correctly prints values for the following
|
||||
* expressions:
|
||||
* - arithmetic expression of local variables,
|
||||
* - boolean expression of local variables,
|
||||
* - string field deeply nested in class hierarchy.
|
||||
* The test passes when all printed values are equal to expected ones.
|
||||
* The test consists of two program:
|
||||
* print002.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* print002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* The test replaces the nsk/jdb/print/print001 one.
|
||||
* Test was fixed according to test bug:
|
||||
* 4862693 NSK testcase nsk/jdb/print/print002 fails with operation not yet supported
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.print.print002.print002
|
||||
*
|
||||
* @comment make sure print002a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.print.print002.print002a
|
||||
* @compile -g:lines,source,vars print002a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.print.print002.print002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.print.print002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class print002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new print002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.print.print002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".print002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String[][] checkedExpr = {
|
||||
{ "i + j", "8"},
|
||||
{ "j - i", "4"},
|
||||
{ "j * i", "12"},
|
||||
{ "j / i", "3"},
|
||||
// { "j % i", "0"},
|
||||
// { "i++", "2"},
|
||||
// { "++i", "3"},
|
||||
// { "j--", "6"},
|
||||
// { "--j", "5"},
|
||||
// { "!b1 ", "false"},
|
||||
// { "b2 && b1", "false"},
|
||||
// { "b2 || b1", "true"},
|
||||
{ "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.s", "foo" }
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// to get out of lastBreak()
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
|
||||
for (int i = 0; i < checkedExpr.length; i++) {
|
||||
if (!checkValue(checkedExpr[i][0], checkedExpr[i][1])) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkValue (String expr, String value) {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
Vector v;
|
||||
boolean result = true;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.print + expr);
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(value);
|
||||
if (found.length() <= 0) {
|
||||
log.complain("jdb failed to report value of expression: " + expr);
|
||||
log.complain("\t expected : " + value + " ;\n\t reported: " + (reply.length > 0? reply[0]: ""));
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.print.print002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class print002a {
|
||||
|
||||
static print002a _print002a = new print002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(print002.JCK_STATUS_BASE + _print002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
int i = 2;
|
||||
int j = 6;
|
||||
boolean b1 = true;
|
||||
boolean b2 = false;
|
||||
|
||||
A a = new A();
|
||||
|
||||
synchronized (this) {
|
||||
lastBreak();
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return print002.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
B b;
|
||||
A() { b = new B(); }
|
||||
}
|
||||
|
||||
class B {
|
||||
C c;
|
||||
B() { c = new C(); }
|
||||
}
|
||||
|
||||
class C {
|
||||
D d;
|
||||
C() { d = new D(); }
|
||||
}
|
||||
|
||||
class D {
|
||||
E e;
|
||||
D() { e = new E(); }
|
||||
}
|
||||
|
||||
class E {
|
||||
F f;
|
||||
E() { f = new F(); }
|
||||
}
|
||||
|
||||
class F {
|
||||
G g;
|
||||
F() { g = new G(); }
|
||||
}
|
||||
|
||||
class G {
|
||||
H h;
|
||||
G() { h = new H(); }
|
||||
}
|
||||
|
||||
class H {
|
||||
I i;
|
||||
H() { i = new I(); }
|
||||
}
|
||||
|
||||
class I {
|
||||
J j;
|
||||
I() { j = new J(); }
|
||||
}
|
||||
|
||||
class J {
|
||||
K k;
|
||||
J() { k = new K(); }
|
||||
}
|
||||
|
||||
class K {
|
||||
L l;
|
||||
K() { l = new L(); }
|
||||
}
|
||||
|
||||
class L {
|
||||
M m;
|
||||
L() { m = new M(); }
|
||||
}
|
||||
|
||||
class M {
|
||||
N n;
|
||||
M() { n = new N(); }
|
||||
}
|
||||
|
||||
class N {
|
||||
O o;
|
||||
N() { o = new O(); }
|
||||
}
|
||||
|
||||
class O {
|
||||
P p;
|
||||
O() { p = new P(); }
|
||||
}
|
||||
|
||||
class P {
|
||||
Q q;
|
||||
P() { q = new Q(); }
|
||||
}
|
||||
|
||||
class Q {
|
||||
R r;
|
||||
Q() { r = new R(); }
|
||||
}
|
||||
|
||||
class R {
|
||||
S s;
|
||||
R() { s = new S(); }
|
||||
}
|
||||
|
||||
class S {
|
||||
T t;
|
||||
S() { t = new T(); }
|
||||
}
|
||||
|
||||
class T {
|
||||
U u;
|
||||
T() { u = new U(); }
|
||||
}
|
||||
|
||||
class U {
|
||||
V v;
|
||||
U() { v = new V(); }
|
||||
}
|
||||
|
||||
class V {
|
||||
W w;
|
||||
V() { w = new W(); }
|
||||
}
|
||||
|
||||
class W {
|
||||
X x;
|
||||
W() { x = new X(); }
|
||||
}
|
||||
|
||||
class X {
|
||||
Y y;
|
||||
X() { y = new Y(); }
|
||||
}
|
||||
|
||||
class Y {
|
||||
Z z;
|
||||
Y() { z = new Z(); }
|
||||
}
|
||||
|
||||
class Z {
|
||||
String s;
|
||||
Z() { s = "foo";}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
classes
|
||||
threads
|
||||
methods nsk.jdb.read.read001.read001a
|
||||
fields nsk.jdb.read.read001.read001a
|
||||
locals
|
200
test/hotspot/jtreg/vmTestbase/nsk/jdb/read/read001/read001.java
Normal file
200
test/hotspot/jtreg/vmTestbase/nsk/jdb/read/read001/read001.java
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/read/read001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* A positive test for the 'read <filename>' command.
|
||||
* The jdb stops the debugged application on enter in read001a.lastBreak()
|
||||
* method. Then the tested command is called for the 'jdb.scenario' file.
|
||||
* The test passes if correct replies for all commands containing in
|
||||
* 'jdb.scenario' are found in jdb stdout stream.
|
||||
* The test consists of two program:
|
||||
* read001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* read001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* Only limited number of commands is used in 'jdb.scenario' file because
|
||||
* the jdb does not wait until end of reply for current command and
|
||||
* immediatly executes the next command from 'jdb.scenario'.
|
||||
* Fixed test according to test bug:
|
||||
* 4665075 TTY: error messages for commands from scenario file of 'read' command
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.read.read001.read001
|
||||
*
|
||||
* @comment make sure read001a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.read.read001.read001a
|
||||
* @compile -g:lines,source,vars read001a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.read.read001.read001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.read.read001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class read001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new read001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.read.read001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".read001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String SCENARIO_FILE = "jdb.scenario";
|
||||
static final int SCENARIO_COMMANDS_COUNT = 5;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
String workdir = argumentHandler.getWorkDir();
|
||||
|
||||
// stop in lastBreak() method
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// return to testedInstanceMethod()
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
|
||||
String command = JdbCommand.read + workdir + File.separator + SCENARIO_FILE;
|
||||
int count = SCENARIO_COMMANDS_COUNT + 1;
|
||||
reply = jdb.receiveReplyFor(command, true, count);
|
||||
|
||||
if (!checkCommands(reply)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkCommands(String[] reply) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
Vector v = new Vector();
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
|
||||
// check 'threads'
|
||||
log.display("Check reply for command: classes");
|
||||
if ((count = grep.find("nsk.jdb.read.read001.read001aTestedClass")) != 1) {
|
||||
log.complain("Wrong number of execution of command: classes");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'threads'
|
||||
log.display("Check reply for command: threads");
|
||||
if ((count = grep.find("TestedThreadInstance")) != 1) {
|
||||
log.complain("Wrong number of execution of command: threads");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'methods'
|
||||
log.display("Check reply for command: methods");
|
||||
if ((count = grep.find("testedInstanceMethod()")) != 1) {
|
||||
log.complain("Wrong number of execution of command: methods nsk.jdb.read.read001a");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'fields'
|
||||
log.display("Check reply for command: fields");
|
||||
if ((count = grep.find("testedStaticFieldBoolean")) != 1) {
|
||||
log.complain("Wrong number of execution of command: fields nsk.jdb.read.read001.presentedInstance");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'locals'
|
||||
log.display("Check reply for command: locals");
|
||||
if ((count = grep.find("testedLocalVarInt")) != 1) {
|
||||
log.complain("Wrong number of execution of command: locals");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
/*
|
||||
// check 'eval'
|
||||
log.display("Check reply for command: eval");
|
||||
if ((count = grep.find("556600")) != 1) {
|
||||
log.complain("Wrong number of execution of command: "
|
||||
+ "eval nsk.jdb.read.read001a.staticInt+instanceInt*3");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'print'
|
||||
log.display("Check reply for command: print");
|
||||
if ((count = grep.find("staticString = \"static string of read001a class\"")) != 1) {
|
||||
log.complain("Wrong number of execution of command: "
|
||||
+ "print nsk.jdb.read.read001.read001a.staticString"
|
||||
);
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
// check 'dump'
|
||||
log.display("Check reply for command: dump");
|
||||
if ((count = grep.find("instance of nsk.jdb.read.read001.read001a")) != 1) {
|
||||
log.complain("Wrong number of execution of command: "
|
||||
+ "dump nsk.jdb.read.read001.read001a._read001a");
|
||||
log.complain(" Expected: 1; found: " + count);
|
||||
result = false;
|
||||
}
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
107
test/hotspot/jtreg/vmTestbase/nsk/jdb/read/read001/read001a.java
Normal file
107
test/hotspot/jtreg/vmTestbase/nsk/jdb/read/read001/read001a.java
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.read.read001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class read001a {
|
||||
|
||||
static boolean testedStaticFieldBoolean = true;
|
||||
double testedInstanceFieldDouble = (double)3.1414926;
|
||||
|
||||
public static void main(String args[]) {
|
||||
read001a _read001a = new read001a();
|
||||
System.exit(read001.JCK_STATUS_BASE + _read001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
void lastBreak () {}
|
||||
|
||||
void testedInstanceMethod() {
|
||||
int testedLocalVarInt = 0;
|
||||
String testedLocalVarString = "foo";
|
||||
|
||||
lastBreak();
|
||||
|
||||
testedLocalVarString = "bar";
|
||||
}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
int localInt = 0;
|
||||
|
||||
read001aTestedClass obj = new read001aTestedClass();
|
||||
read001aTestedThread thread = new read001aTestedThread("TestedThreadInstance");
|
||||
|
||||
synchronized (thread.finishingMonitor) {
|
||||
synchronized (thread.startingMonitor) {
|
||||
try {
|
||||
thread.start();
|
||||
thread.startingMonitor.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Interrupted while starting tested thread: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
testedInstanceMethod();
|
||||
}
|
||||
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Interrupted while finishing tested thread: " + e);
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return read001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class read001aTestedClass {
|
||||
char instanceFiledChar = 'x';
|
||||
}
|
||||
|
||||
class read001aTestedThread extends Thread {
|
||||
|
||||
Object startingMonitor = new Object();
|
||||
Object finishingMonitor = new Object();
|
||||
|
||||
public read001aTestedThread(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (startingMonitor) {
|
||||
startingMonitor.notifyAll();
|
||||
}
|
||||
|
||||
synchronized (finishingMonitor) {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.redefine.redefine001;
|
||||
|
||||
public class RedefinedClass {
|
||||
public static String foo() {
|
||||
return "BEFORE_REDEFINITION"; // This string is substituted with
|
||||
// 'return "AFTER_REDEFINITION";' in
|
||||
// the newclass/RedefinedClass.java.
|
||||
}
|
||||
}
|
30
test/hotspot/jtreg/vmTestbase/nsk/jdb/redefine/redefine001/newclass_g/RedefinedClass.java
Normal file
30
test/hotspot/jtreg/vmTestbase/nsk/jdb/redefine/redefine001/newclass_g/RedefinedClass.java
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.redefine.redefine001;
|
||||
|
||||
public class RedefinedClass {
|
||||
public static String foo() {
|
||||
return "AFTER_REDEFINITION";
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/redefine/redefine001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'redefine <class id> <class file name>' command.
|
||||
* The debuggee program invokes three times method 'foo()' of RedefinedClass
|
||||
* class. This class in redefined with checked command each time before last
|
||||
* two invocations. If redefinitions occurs then the value returned by 'foo()'
|
||||
* method must be different from one returned previous invocation.
|
||||
* The test passes if method 'foo()' of the RedefinedClass returns expected
|
||||
* values.
|
||||
* The test consists of three program:
|
||||
* redefine001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* redefine001a.java - the debugged application.
|
||||
* RedefinedClass.java - the class to be redefined.
|
||||
* newclass_g/RedefinedClass.java - the redefining class.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.redefine.redefine001.redefine001
|
||||
* nsk.jdb.redefine.redefine001.redefine001a
|
||||
*
|
||||
* @comment compile newclass_g/RedefinedClass.java to newclass_g
|
||||
* @build ExecDriver
|
||||
* @run driver PropertyResolvingWrapper ExecDriver --cmd
|
||||
* ${compile.jdk}/bin/javac
|
||||
* -d ${test.classes}/newclass_g
|
||||
* -g:lines,source,vars
|
||||
* -cp ${test.class.path}
|
||||
* ${test.src}/newclass_g/RedefinedClass.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.redefine.redefine001.redefine001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.redefine.redefine001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
import nsk.share.classload.ClassLoadUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class redefine001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new redefine001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.redefine.redefine001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".redefine001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String REDEFINED_CLASS = PACKAGE_NAME + ".RedefinedClass";
|
||||
static final String BEFORE_REDEFINITION = "BEFORE_REDEFINITION";
|
||||
static final String FIRST_REDEFINITION = "AFTER_REDEFINITION";
|
||||
static final String SECOND_REDEFINITION = BEFORE_REDEFINITION;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak()
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_CLASS + ".flag");
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find(BEFORE_REDEFINITION) == 0) {
|
||||
log.complain("Wrong value of redefine001a.flag before redefinition: " + (reply.length > 0? reply[0]: ""));
|
||||
success = false;
|
||||
}
|
||||
|
||||
String className = RedefinedClass.class.getName();
|
||||
String pathToRedefFile1 = ClassLoadUtils.getRedefineClassFileName("newclass_g", className);
|
||||
if (new File(pathToRedefFile1).exists()) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.redefine + REDEFINED_CLASS + " " + pathToRedefFile1);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_CLASS + ".flag");
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find(FIRST_REDEFINITION) == 0) {
|
||||
log.complain("Wrong value of redefine001a.flag after first redefinition: " + (reply.length > 0? reply[0]: ""));
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("File does not exists: " + pathToRedefFile1);
|
||||
success = false;
|
||||
}
|
||||
|
||||
String pathToRedefFile2 = ClassLoadUtils.getClassPathFileName(className);
|
||||
if (new File(pathToRedefFile2).exists()) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.redefine + REDEFINED_CLASS + " " + pathToRedefFile2);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_CLASS + ".flag");
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find(SECOND_REDEFINITION) == 0) {
|
||||
log.complain("Wrong value of redefine001a.flag after second redefinition: " + (reply.length > 0? reply[0]: ""));
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("File does not exists: " + pathToRedefFile2);
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
}
|
||||
|
||||
private boolean checkStop () {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
Vector v;
|
||||
boolean result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.redefine.redefine001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class redefine001a {
|
||||
static redefine001a _redefine001a = new redefine001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(redefine001.JCK_STATUS_BASE + _redefine001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
RedefinedClass c = new RedefinedClass();
|
||||
|
||||
flag = c.foo();
|
||||
|
||||
lastBreak(); // at this point RedefinedClass is redefined.
|
||||
|
||||
flag = c.foo();
|
||||
|
||||
lastBreak();
|
||||
|
||||
flag = c.foo();
|
||||
|
||||
lastBreak();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return redefine001.PASSED;
|
||||
}
|
||||
|
||||
static String flag = "";
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/reenter/reenter001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* A positive test case for the 'reenter' command.
|
||||
* The debugged application (reenter001a.java) starts additional thread of MyThread
|
||||
* class. The 'run()' method of the this class invokes recursively a number of
|
||||
* int methods. The jdb sets breakpoint in the last called 'func5()' method
|
||||
* to suspend the debugged VM when all the methods, i.e. from 'func1()' to
|
||||
* 'func5()', are in MyThread's stack. Then jdb steps up three frame on stack
|
||||
* by 'up 3' command. At this moment frame with 'func2()' is current.
|
||||
* Then the 'reenter' command is called. The test passes if after execution of
|
||||
* tested command the 'func2()' frame reentered, i.e. top frame of the stack.
|
||||
* The test consists of two program:
|
||||
* reenter001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* reenter001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.reenter.reenter001.reenter001
|
||||
* nsk.jdb.reenter.reenter001.reenter001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.reenter.reenter001.reenter001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.reenter.reenter001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class reenter001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new reenter001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.reenter.reenter001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".reenter001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
static final String[] CHECKED_METHODS = {"func1", "func2", "func3", "func4", "func5"};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
while (true) {
|
||||
String[] threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
if (threads.length != 1) {
|
||||
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.thread + threads[0]);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak()
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func5", "[1]", "lastBreak", false)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.up + " 3");
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func2", "[4]", "func3", false)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.reenter);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
if (!checkStack(reply, "func2", "[1]", "func3", true)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.locals);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("Internal exception") > 0) {
|
||||
log.complain("Internal exception was thrown while 'locals' command");
|
||||
for (int i = 0; i < reply.length; i++) {
|
||||
log.complain(reply[i]);
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
}
|
||||
|
||||
private boolean checkStack (String[] reply, String shouldBe, String frameNum, String shouldNotBe, boolean reenter ) {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
Vector v = new Vector();
|
||||
boolean result = true;
|
||||
int count;
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
v.add(frameNum);
|
||||
v.add(DEBUGGEE_THREAD + "." + shouldBe);
|
||||
if ((count = grep.find(v)) != 1) {
|
||||
log.complain("Contents of stack trace is incorrect " + ( reenter? "after 'reenter' command": ""));
|
||||
log.complain("Searched for: " + DEBUGGEE_THREAD + "." + shouldBe);
|
||||
log.complain("Count : " + count);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (grep.find(DEBUGGEE_THREAD + "." + shouldNotBe) > 0) {
|
||||
log.complain("Contents of stack trace is incorrect " + ( reenter? "after 'reenter' command": ""));
|
||||
log.complain("Found wrong frame: " + DEBUGGEE_THREAD + "." + shouldNotBe);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.reenter.reenter001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class reenter001a {
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static reenter001a _reenter001a = new reenter001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(reenter001.JCK_STATUS_BASE + _reenter001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
MyThread myThread = new MyThread(MYTHREAD);
|
||||
myThread.start();
|
||||
|
||||
if (myThread.isAlive()) {
|
||||
try {
|
||||
myThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for finish of " + MYTHREAD);
|
||||
return reenter001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return reenter001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
public MyThread (String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
reenter001a.log.display("run() started");
|
||||
int runLocal;
|
||||
int j = func1(0);
|
||||
reenter001a.log.display("run() finished");
|
||||
}
|
||||
|
||||
public int func1(int intParam) {
|
||||
reenter001a.log.display("func1() started");
|
||||
int func1Local;
|
||||
intParam++;
|
||||
return func2(intParam);
|
||||
}
|
||||
|
||||
public int func2(int intParam) {
|
||||
reenter001a.log.display("func2() started");
|
||||
int func2Local;
|
||||
intParam++;
|
||||
return func3(intParam);
|
||||
}
|
||||
|
||||
public int func3(int intParam) {
|
||||
reenter001a.log.display("func3() started");
|
||||
int func3Local;
|
||||
intParam++;
|
||||
return func4(intParam);
|
||||
}
|
||||
|
||||
public int func4(int intParam) {
|
||||
reenter001a.log.display("func4() started");
|
||||
int func4Local;
|
||||
intParam++;
|
||||
return func5(intParam);
|
||||
}
|
||||
|
||||
public int func5(int intParam) {
|
||||
reenter001a.log.display("func5() started");
|
||||
int func5Local;
|
||||
intParam++;
|
||||
reenter001a.lastBreak();
|
||||
return intParam;
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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 4689395
|
||||
* @summary converted from VM Testbase nsk/jdb/regression/b4689395.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* Regression test for the bug
|
||||
* 4689395 (P4/S3) "step over" after a class is redefined acts like "step out"
|
||||
* Release summary: 1.4
|
||||
* Hardware version: generic
|
||||
* O/S version (unbundled products): 5.8
|
||||
* The test consists of two java-files:
|
||||
* b4689395.java - launches jdb and debuggee, writes commands to jdb,
|
||||
* reads the jdb output;
|
||||
* b4689395a.java - the debugged application.
|
||||
* The debugged application (b4689395a.java) defines method minor() that
|
||||
* prints four lines into System.out. b4689395 sets a breakpoint on the 54th
|
||||
* line
|
||||
* System.out.println("A breakpoint is here.");
|
||||
* and then redefines b4689395a with newclass/b4689395a. Those classes differ
|
||||
* just in the 30th line (period is omitted in newclass/b4689395a). After that
|
||||
* the debuggee invokes 'next' command. The test fails if
|
||||
* b4689395.ERROR_MESSAGE message appears in output, otherwise the test passes.
|
||||
* COMMENTS
|
||||
* The test reproduces the bug on Solsparc.
|
||||
* java version "1.4.1-beta"
|
||||
* Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
|
||||
* Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
|
||||
* Command line
|
||||
* ../jdk1.4.1-b14/solsparc/bin/java b4689395 -arch=sparc
|
||||
* -waittime=2 -debugee.vmkind=java
|
||||
* -jdb=../jdk1.4.1-b14/solsparc/bin/jdb
|
||||
* -workdir=../b4689395 -jdb.option= -debugee.vmkeys=
|
||||
* #launcher > Compound prompt found: main[1]
|
||||
* #Test cases starts.
|
||||
* #Sending command: stop at b4689395a:54
|
||||
* #
|
||||
* #launcher > Compound prompt found: main[1]
|
||||
* #Sending command: cont
|
||||
* #
|
||||
* #launcher > Compound prompt found: main[1]
|
||||
* #Sending command: redefine b4689395a b4689395/newclass/b4689395a.class
|
||||
* #
|
||||
* #launcher > Compound prompt found: main[1]
|
||||
* #Sending command: next
|
||||
* #
|
||||
* #launcher > Compound prompt found: main[1]
|
||||
* ## ERROR: 'ERROR_M' is not expected to be printed after 'next' command.
|
||||
* #Sending command: cont
|
||||
* #
|
||||
* #Test cases ends.
|
||||
* #Waiting for jdb exits
|
||||
* #jdb normally exited
|
||||
* ## ERROR: TEST FAILED
|
||||
* #
|
||||
* #
|
||||
* ##>
|
||||
* ##> SUMMARY: Following errors occured
|
||||
* ##> during test execution:
|
||||
* ##>
|
||||
* ## ERROR: 'ERROR_M' is not expected to be printed after 'next' command.
|
||||
* ## ERROR: TEST FAILED
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
*
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.regression.b4689395.b4689395
|
||||
* nsk.jdb.regression.b4689395.b4689395a
|
||||
*
|
||||
* @comment compile newclass/b4689395a.java to newclass
|
||||
* @build ExecDriver
|
||||
* @run driver PropertyResolvingWrapper ExecDriver --cmd
|
||||
* ${compile.jdk}/bin/javac
|
||||
* -d ${test.classes}/newclass
|
||||
* -cp ${test.class.path}
|
||||
* ${test.src}/newclass/b4689395a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.regression.b4689395.b4689395
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.regression.b4689395;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
import nsk.share.classload.ClassLoadUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class b4689395 extends JdbTest {
|
||||
final static String TEST_CLASS = b4689395.class.getName();
|
||||
final static String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
final static String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
final static String ERROR_MESSAGE = "ERROR_M";
|
||||
final static int LINE_NUMBER = 54;
|
||||
private String classFile;
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
return new b4689395().runTest(argv, out);
|
||||
}
|
||||
|
||||
public b4689395() {
|
||||
classFile = ClassLoadUtils.getRedefineClassFileName(DEBUGGEE_CLASS);
|
||||
if (classFile == null)
|
||||
throw new TestFailure("Unable to find redefine class file in classpath for: " + DEBUGGEE_CLASS);
|
||||
}
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + LINE_NUMBER);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
if (new File(classFile).exists()) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.redefine + DEBUGGEE_CLASS
|
||||
+ " " + classFile);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.next);
|
||||
|
||||
Paragrep grep = new Paragrep(reply);
|
||||
if (grep.find(ERROR_MESSAGE) != 0) {
|
||||
log.complain("'" + ERROR_MESSAGE + "' is not expected to be "
|
||||
+ "printed after 'next' command.");
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("File does not exist: " + classFile);
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.regression.b4689395;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class b4689395a {
|
||||
static b4689395a _b4689395a = new b4689395a();
|
||||
final static String ERROR_MESSAGE = "ERROR_M";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(Consts.JCK_STATUS_BASE + _b4689395a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
minor();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return Consts.TEST_PASSED;
|
||||
}
|
||||
|
||||
public static void minor() {
|
||||
System.out.println("In the top of the method minor()."); // b4689395.LINE_NUMBER
|
||||
System.out.println("A breakpoint is here.");
|
||||
System.out.println("In the bottom of the method minor().");
|
||||
System.out.println(ERROR_MESSAGE);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.regression.b4689395;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class b4689395a {
|
||||
static b4689395a _b4689395a = new b4689395a();
|
||||
final static String ERROR_MESSAGE = "ERROR_M";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(Consts.JCK_STATUS_BASE + _b4689395a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
minor();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return Consts.TEST_PASSED;
|
||||
}
|
||||
|
||||
public static void minor() {
|
||||
System.out.println("In the top of the method minor()"); // b4689395.LINE_NUMBER
|
||||
System.out.println("A breakpoint is here.");
|
||||
System.out.println("In the bottom of the method minor().");
|
||||
System.out.println(ERROR_MESSAGE);
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/resume/resume002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This is a test for jdb 'resume all' and 'resume <thread id>' commands.
|
||||
* The debuggee starts 5 'MyThreads' that are all suspended on the lock
|
||||
* that the main thread holds. The the test driver issues the following
|
||||
* commands for check:
|
||||
* - 'suspend all' : "All threads suspended" message is expected in
|
||||
* jdb output stream;
|
||||
* - 'resume all' : "All threads resumed" message is expected in
|
||||
* jdb output stream;
|
||||
* - 'suspend <thread_id>' for each 'MyThread';
|
||||
* - 'resume <thread_id>' for each 'MyThread'.
|
||||
* The test consists of two parts:
|
||||
* resume002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* resume002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/resume/resume001 test
|
||||
* and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.resume.resume002.resume002
|
||||
* nsk.jdb.resume.resume002.resume002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.resume.resume002.resume002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.resume.resume002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class resume002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new resume002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.resume.resume002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".resume002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String THREAD_NAME = "MyThread";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
String[] threadIds = jdb.getThreadIds(PACKAGE_NAME + "." + THREAD_NAME);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.suspend);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("All threads suspended") == 0) {
|
||||
failure("jdb cannot suspend all threads");
|
||||
}
|
||||
reply = jdb.receiveReplyFor(JdbCommand.resume, false);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("All threads resumed") == 0) {
|
||||
failure("jdb cannot resume all threads");
|
||||
}
|
||||
|
||||
jdb.receiveReplyFor(JdbCommand.thread + threadIds[0]);
|
||||
|
||||
for (int i = 0; i < resume002a.numThreads; i++) {
|
||||
jdb.receiveReplyFor(JdbCommand.suspend + threadIds[i]);
|
||||
jdb.receiveReplyFor(JdbCommand.resume + threadIds[i]);
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.resume.resume002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class resume002a {
|
||||
public static void main(String args[]) {
|
||||
resume002a _resume002a = new resume002a();
|
||||
System.exit(resume002.JCK_STATUS_BASE + _resume002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
static int numThreads = 5; // number of threads
|
||||
static Thread holder [] = new Thread[numThreads];
|
||||
|
||||
static Object waitnotify = new Object();
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
Lock lock = new Lock();
|
||||
|
||||
try {
|
||||
lock.setLock();
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread(lock, "MyThread#" + i);
|
||||
synchronized (waitnotify) {
|
||||
holder[i].start();
|
||||
waitnotify.wait();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in main thread: " +
|
||||
e.getMessage());
|
||||
System.exit(resume002.FAILED);
|
||||
}
|
||||
|
||||
lastBreak(); // When jdb stops here, there should be 5 running MyThreads.
|
||||
lock.releaseLock();
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
try {
|
||||
holder[i].join(argumentHandler.getWaitTime() * 60000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Unexpected InterruptedException catched while waiting for join of: " + holder[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return resume002.PASSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Lock {
|
||||
boolean lockSet;
|
||||
|
||||
synchronized void setLock() throws InterruptedException {
|
||||
while (lockSet == true)
|
||||
wait();
|
||||
lockSet = true;
|
||||
}
|
||||
|
||||
synchronized void releaseLock() {
|
||||
if (lockSet == true) {
|
||||
lockSet = false;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
Lock lock;
|
||||
String name;
|
||||
|
||||
MyThread (Lock l, String name) {
|
||||
this.lock = l;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (resume002a.waitnotify) {
|
||||
resume002a.waitnotify.notifyAll();
|
||||
}
|
||||
try {
|
||||
lock.setLock();
|
||||
} catch(Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in MyThread: " +
|
||||
e.getMessage());
|
||||
System.exit(resume002.FAILED);
|
||||
}
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
107
test/hotspot/jtreg/vmTestbase/nsk/jdb/run/run002/run002.java
Normal file
107
test/hotspot/jtreg/vmTestbase/nsk/jdb/run/run002/run002.java
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/run/run002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the 'run' command.
|
||||
* The 'run' command is issued in the superclass of test driver class.
|
||||
* The test is passed if "run nsk.jdb.run.run002a" string is found
|
||||
* in jdb's output stream:
|
||||
* The test consists of two parts:
|
||||
* run002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* run002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/run/run001 test and
|
||||
* replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.run.run002.run002
|
||||
* nsk.jdb.run.run002.run002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.run.run002.run002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.run.run002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class run002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new run002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.run.run002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".run002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (argumentHandler.isLaunchingConnector()) {
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
v = new Vector();
|
||||
v.add(JdbCommand.run);
|
||||
v.add(DEBUGGEE_CLASS);
|
||||
if (grep.find(v) != 1) {
|
||||
failure("jdb failed to run debugged application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.run.run002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class run002a {
|
||||
static run002a _run002a = new run002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(run002.JCK_STATUS_BASE + _run002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return run002.PASSED;
|
||||
}
|
||||
}
|
135
test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set001/set001.java
Normal file
135
test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set001/set001.java
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/set/set001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'set <lvalue> = <expr>' command.
|
||||
* The test checks if jdb correctly sets value for the following
|
||||
* fields and variables:
|
||||
* - static field,
|
||||
* - instance field
|
||||
* The jdb suspends the debuggee inside the method runIt and then tries
|
||||
* to set new values for the fields and variables using checked command.
|
||||
* Then the debuggee checks if modified fields/variables have expected
|
||||
* values. If not, then special errorMessage variable is appended with
|
||||
* the info of wrong values. The test passes when length of errorMessage
|
||||
* is equal to 0, and fails otherwise.
|
||||
* The test consists of two program:
|
||||
* set001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* set001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.set.set001.set001
|
||||
*
|
||||
* @comment make sure set001a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.set.set001.set001a
|
||||
* @compile -g:lines,source,vars set001a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.set.set001.set001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.set.set001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class set001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new set001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.set.set001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".set001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String ERROR_MESSAGE = DEBUGGEE_CLASS + ".errorMessage";
|
||||
|
||||
static final String[][] checkedExpr = {
|
||||
{ DEBUGGEE_CLASS + ".myStaticField", "-2147483648" },
|
||||
{ DEBUGGEE_CLASS + "._set001a.myInstanceField", "9223372036854775807" },
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// to get out of lastBreak()
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
|
||||
// set values
|
||||
for (int i = 0; i < checkedExpr.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.set + checkedExpr[i][0] + " = " + checkedExpr[i][1]);
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
// check value of debuggeeResult
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + ERROR_MESSAGE);
|
||||
//if everything is OK reply will look like this
|
||||
// nsk.jdb.set.set001.set001a.errorMessage = ""
|
||||
if (!reply[0].contains("\"\"")) {
|
||||
log.complain("jdb failed to set value for expression(s): ");
|
||||
for (int i = 0; i < reply.length; i++) {
|
||||
log.complain(reply[i]);
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.set.set001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class set001a {
|
||||
|
||||
private static final String DEBUGGEE_PASSED = "Debuggee PASSED";
|
||||
private static final String DEBUGGEE_FAILED = "Debuggee FAILED";
|
||||
|
||||
static set001a _set001a = new set001a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(set001.JCK_STATUS_BASE + _set001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
String debuggeeResult = DEBUGGEE_PASSED;
|
||||
|
||||
int localInt = 0;
|
||||
lastBreak();
|
||||
/* jdb should change values of fileds and variables */
|
||||
|
||||
if (set001a.myStaticField != Integer.MIN_VALUE) {
|
||||
errorMessage += "\nWrong value of set001a.myStaticField: " + set001a.myStaticField + ", expected: " + Integer.MIN_VALUE;
|
||||
}
|
||||
if (_set001a.myInstanceField != Long.MAX_VALUE) {
|
||||
errorMessage += "\nWrong value of _set001a.myInstanceField: " + _set001a.myInstanceField + ", expected: " + Long.MAX_VALUE;
|
||||
}
|
||||
if (errorMessage.length() > 0) {
|
||||
debuggeeResult = DEBUGGEE_FAILED;
|
||||
}
|
||||
|
||||
lastBreak(); // a breakpoint to check value of debuggeeResult
|
||||
|
||||
log.display(debuggeeResult);
|
||||
if (debuggeeResult.equals(DEBUGGEE_PASSED)) {
|
||||
return set001.PASSED;
|
||||
} else {
|
||||
return set001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
static String errorMessage = "";
|
||||
static private int myStaticField;
|
||||
protected long myInstanceField;
|
||||
|
||||
}
|
137
test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set002/set002.java
Normal file
137
test/hotspot/jtreg/vmTestbase/nsk/jdb/set/set002/set002.java
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/set/set002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'set <lvalue> = <expr>' command.
|
||||
* The test checks if jdb correctly sets value for the following
|
||||
* fields and variables:
|
||||
* - element of array field,
|
||||
* - local variable
|
||||
* Probably needs to be merged with set001
|
||||
* The jdb suspends the debuggee inside the method runIt and then tries
|
||||
* to set new values for the fields and variables using checked command.
|
||||
* Then the debuggee checks if modified fields/variables have expected
|
||||
* values. If not, then special errorMessage variable is appended with
|
||||
* the info of wrong values. The test passes when length of errorMessage
|
||||
* is equal to 0, and fails otherwise.
|
||||
* The test consists of two programs:
|
||||
* set002.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* set002a.java - the debugged application.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.set.set002.set002
|
||||
*
|
||||
* @comment make sure set002a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.set.set002.set002a
|
||||
* @compile -g:lines,source,vars set002a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.set.set002.set002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.set.set002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class set002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
|
||||
return new set002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.set.set002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".set002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String ERROR_MESSAGE = DEBUGGEE_CLASS + ".errorMessage";
|
||||
|
||||
static final String[][] checkedExpr = { //not broken, can be run safely even if 4660158 is not fixed
|
||||
{ DEBUGGEE_CLASS + "._set002a.myArrayField[0][0].line", "\"ABCDE\"" },
|
||||
{ "localInt", "java.lang.Integer.MIN_VALUE"}
|
||||
};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// to get out of lastBreak()
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
|
||||
// set values
|
||||
for (int i = 0; i < checkedExpr.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.set + checkedExpr[i][0] + " = " + checkedExpr[i][1]);
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
// check value of debuggeeResult
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + ERROR_MESSAGE);
|
||||
|
||||
//if everything is OK reply will look like this
|
||||
// nsk.jdb.set.set002.set002a.errorMessage = ""
|
||||
if (!reply[0].contains("\"\"")) {
|
||||
log.complain("jdb failed to set value for expression(s): ");
|
||||
for (int i = 0; i < reply.length; i++) {
|
||||
log.complain(reply[i]);
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.set.set002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class set002a {
|
||||
|
||||
private static final String DEBUGGEE_PASSED = "Debuggee PASSED";
|
||||
private static final String DEBUGGEE_FAILED = "Debuggee FAILED";
|
||||
|
||||
static set002a _set002a = new set002a();
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(set002.JCK_STATUS_BASE + _set002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
String debuggeeResult = DEBUGGEE_PASSED;
|
||||
|
||||
int localInt = 0;
|
||||
lastBreak();
|
||||
/* jdb should change values of fileds and variables */
|
||||
|
||||
if (!_set002a.myArrayField[0][0].toString().equals("ABCDE")) {
|
||||
errorMessage += "\nWrong value of _set002a.myArrayField[0][0]: " + _set002a.myArrayField[0][0] + ", expected: \"ABCDE\"";
|
||||
}
|
||||
if (localInt != Integer.MIN_VALUE) {
|
||||
errorMessage += "\nWrong value of localInt: " + localInt + ", expected: " + Integer.MIN_VALUE;
|
||||
}
|
||||
if (errorMessage.length() > 0) {
|
||||
debuggeeResult = DEBUGGEE_FAILED;
|
||||
}
|
||||
|
||||
lastBreak(); // a breakpoint to check value of debuggeeResult
|
||||
|
||||
log.display(debuggeeResult);
|
||||
if (debuggeeResult.equals(DEBUGGEE_PASSED)) {
|
||||
return set002.PASSED;
|
||||
} else {
|
||||
return set002.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
static String errorMessage = "";
|
||||
public MyClass[][] myArrayField;
|
||||
|
||||
private set002a () {
|
||||
myArrayField = new MyClass[][] {new MyClass[] {new MyClass("")}};
|
||||
}
|
||||
|
||||
static class MyClass {
|
||||
private String line;
|
||||
|
||||
public MyClass (String s) {
|
||||
line = s;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
}
|
139
test/hotspot/jtreg/vmTestbase/nsk/jdb/step/step002/step002.java
Normal file
139
test/hotspot/jtreg/vmTestbase/nsk/jdb/step/step002/step002.java
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/step/step002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* The test for the 'step' command.
|
||||
* The test checks the following cases:
|
||||
* - step inside current method,
|
||||
* - step into called method,
|
||||
* - step up to calling method.
|
||||
* The test works as follows. The jdb sets breakpoint at the line
|
||||
* where new value is assigned to local variable. The jdb issues
|
||||
* 'step' command. Then the test checks whether a step is done by
|
||||
* requesting a value of local variable using 'eval' command.
|
||||
* The next two cases are checked with a pair of 'step' and
|
||||
* 'where' commands. The test checks a stack trace after step
|
||||
* using 'where' command.
|
||||
* The test consists of two program:
|
||||
* step002.java - test driver, i.e. launches jdb and debuggee,
|
||||
* writes commands to jdb, reads the jdb output,
|
||||
* step002a.java - the debugged application.
|
||||
* COMMENTS
|
||||
* This test replaces the nsk/jdb/step/step002 one.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.step.step002.step002
|
||||
*
|
||||
* @comment make sure step002a is compiled w/ full debug info
|
||||
* @clean nsk.jdb.step.step002.step002a
|
||||
* @compile -g:lines,source,vars step002a.java
|
||||
*
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.step.step002.step002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.step.step002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class step002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new step002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.step.step002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".step002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final int BREAKPOINT_LINE = 50;
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + BREAKPOINT_LINE);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
// case #1 : step inside frame;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + "intVar");
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("1234") == 0) {
|
||||
failure("CASE #1 FAILED: Wrong location after step inside current method");
|
||||
}
|
||||
|
||||
// case #1 : step into called frame;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("foo") == 0) {
|
||||
failure("CASE #2 FAILED: Wrong location after step into called method");
|
||||
}
|
||||
|
||||
// case #1 : step out to calling frame;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
grep = new Paragrep(reply);
|
||||
if (grep.find("foo") > 0) {
|
||||
failure("CASE #2 FAILED: Wrong location after step up to calling method");
|
||||
}
|
||||
if (grep.find("runIt") == 0) {
|
||||
failure("CASE #2 FAILED: Wrong location after step up to calling method");
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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.
|
||||
*/
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
package nsk.jdb.step.step002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class step002a {
|
||||
public static void main(String args[]) {
|
||||
step002a _step002a = new step002a();
|
||||
System.exit(step002.JCK_STATUS_BASE + _step002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
int intVar = 0;
|
||||
intVar += 1234; // step002.BREAKPOINT_LINE
|
||||
intVar = foo(2);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return step002.PASSED;
|
||||
}
|
||||
|
||||
int foo (int i) {
|
||||
return i*i;
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/step_up/step_up001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* A positive test for the 'step up' command.
|
||||
* The debuggee program (step_up001a.java) creates two additional
|
||||
* threads of MyThread type and starts them. The jdb sets up breakpoint
|
||||
* inside the method 'func2' which is invoked in these addional threads.
|
||||
* When breakpoint is hitted the checked command is called. After this,
|
||||
* the stack trace of the current method is checked by 'where' command.
|
||||
* The test passes if only caller method ('func1') presents in stack
|
||||
* trace, but neither of 'func2' nor 'func3' methods.
|
||||
* The test consists of two program:
|
||||
* step_up001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* step_up001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.step_up.step_up001.step_up001
|
||||
* nsk.jdb.step_up.step_up001.step_up001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.step_up.step_up001.step_up001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.step_up.step_up001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class step_up001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new step_up001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.step_up.step_up001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".step_up001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
|
||||
|
||||
static final String[] checkedMethods = {"func1", "func2", "func3"};
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
|
||||
int breakCount = 0;
|
||||
int stepupCount = 0;
|
||||
for (int i = 0; i < step_up001a.numThreads; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
if (jdb.isAtBreakpoint(reply, LAST_BREAK)) {
|
||||
breakCount++;
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step); // to get out of lastBreak;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.step_up);
|
||||
if (!checkSteppedUp()) {
|
||||
success = false;
|
||||
} else {
|
||||
stepupCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
if (stepupCount != step_up001a.numThreads) {
|
||||
log.complain("Wrong number of step up events: " + stepupCount);
|
||||
log.complain("Must be equal to : " + step_up001a.numThreads);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkSteppedUp () {
|
||||
Paragrep grep;
|
||||
String found;
|
||||
int count;
|
||||
boolean result = true;
|
||||
String[] reply;
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.where);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 1 /* !!! */; i < checkedMethods.length; i++) {
|
||||
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[i]);
|
||||
if (count > 0) {
|
||||
log.complain("Wrong method in thread stack trace: " + DEBUGGEE_THREAD + "." + checkedMethods[i]);
|
||||
result= false;
|
||||
}
|
||||
}
|
||||
|
||||
count = grep.find(DEBUGGEE_THREAD + "." + checkedMethods[0]);
|
||||
if (count != 1) {
|
||||
log.complain("Checked method does not exist in thread stack trace: " + DEBUGGEE_THREAD + "." + checkedMethods[0]);
|
||||
result= false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.step_up.step_up001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class step_up001a {
|
||||
public static void main(String args[]) {
|
||||
step_up001a _step_up001a = new step_up001a();
|
||||
System.exit(step_up001.JCK_STATUS_BASE + _step_up001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
static final String MYTHREAD = "MyThread";
|
||||
static final int numThreads = 2; // number of threads.
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
static Object waitnotify = new Object();
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread();
|
||||
holder[i].start();
|
||||
try {
|
||||
holder[i].join();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for finish of " + MYTHREAD + "-" + i);
|
||||
return step_up001.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return step_up001.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyThread extends Thread {
|
||||
public void run() {
|
||||
int runLocal = func1(100);
|
||||
}
|
||||
|
||||
public int func1(int i) {
|
||||
return func2(i);
|
||||
}
|
||||
|
||||
public int func2(int i) {
|
||||
step_up001a.lastBreak();
|
||||
|
||||
return func3(i);
|
||||
}
|
||||
|
||||
public int func3(int i) {
|
||||
return i*i;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/stop_at/stop_at002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* Regression test for:
|
||||
* Bug ID: 4299394
|
||||
* Synopsis: TTY: Deferred breakpoints can't be set on inner classes
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.stop_at.stop_at002.stop_at002
|
||||
* nsk.jdb.stop_at.stop_at002.stop_at002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.stop_at.stop_at002.stop_at002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.stop_at.stop_at002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* Regression test for:
|
||||
* Bug ID: 4299394
|
||||
* Synopsis: TTY: Deferred breakpoints can't be set on inner classes
|
||||
*
|
||||
*/
|
||||
|
||||
public class stop_at002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new stop_at002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.stop_at.stop_at002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".stop_at002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String DEBUGGEE_LOCATION1 = DEBUGGEE_CLASS + "$Nested$DeeperNested$DeepestNested:43";
|
||||
static final String DEBUGGEE_LOCATION2 = DEBUGGEE_CLASS + "$Inner$MoreInner:57";
|
||||
static final String FAILURE_PATTERN = "Unable to set";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
if (!checkStop(DEBUGGEE_LOCATION1)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!checkStop(DEBUGGEE_LOCATION2)) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
jdb.contToExit(3);
|
||||
}
|
||||
|
||||
private boolean checkStop (String location) {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
log.display("Trying to set breakpoint at line: " + location);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + location);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(FAILURE_PATTERN);
|
||||
if (found.length() > 0) {
|
||||
log.complain("jdb failed to set line breakpoint at line: " + found);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.stop_at.stop_at002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class stop_at002a {
|
||||
public static void main(String args[]) {
|
||||
stop_at002a _stop_at002a = new stop_at002a();
|
||||
lastBreak();
|
||||
System.exit(stop_at002.JCK_STATUS_BASE + _stop_at002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
new Nested(true).new DeeperNested().new DeepestNested().foo(false);
|
||||
Immersible var = new Inner().new MoreInner();
|
||||
var.foo("whatever");
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return stop_at002.PASSED;
|
||||
}
|
||||
|
||||
class Nested {
|
||||
boolean flag;
|
||||
Nested (boolean b) {
|
||||
flag = b;
|
||||
}
|
||||
class DeeperNested {
|
||||
class DeepestNested {
|
||||
public void foo(boolean input) {
|
||||
flag = input; /* <-------- This is line number 43 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Inner {
|
||||
class MoreInner implements Immersible {
|
||||
String content;
|
||||
|
||||
public MoreInner() {
|
||||
content = "";
|
||||
}
|
||||
public void foo(String input) {
|
||||
content += input; /* <-------- This is line number 57 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Immersible {
|
||||
public void foo(String input);
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/stop_at/stop_at003.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the jdb "stop at <class:line>" command.
|
||||
* The test driver sets three breakpoints in debugged 'stop_at003b'
|
||||
* class:
|
||||
* - at line in static initilizer,
|
||||
* - at line in instance initilizer,
|
||||
* - at line in constructor,
|
||||
* - at line in exception handler.
|
||||
* The test passes if the debuggee is suspended at every breakpoint
|
||||
* had been set and "Breakpoint hit" message had been printed in
|
||||
* jdb's output stream.
|
||||
* The test consists of:
|
||||
* nsk.jdb.stop_at.stop_at003.java - test driver,
|
||||
* nsk.jdb.stop_at.stop_at003a.java - debugged application.
|
||||
* COMMENTS
|
||||
* This test functionally covers to nsk/jdb/stop_at/stop_at001 test
|
||||
* and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.stop_at.stop_at003.stop_at003
|
||||
* nsk.jdb.stop_at.stop_at003.stop_at003a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.stop_at.stop_at003.stop_at003
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.stop_at.stop_at003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* Regression test for:
|
||||
* Bug ID: 4299394
|
||||
* Synopsis: TTY: Deferred breakpoints can't be set on inner classes
|
||||
*
|
||||
*/
|
||||
|
||||
public class stop_at003 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new stop_at003().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.stop_at.stop_at003";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".stop_at003";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String[][] LOCATIONS = new String[][] {
|
||||
{ PACKAGE_NAME + ".stop_at003b:61", PACKAGE_NAME + ".stop_at003b.<clinit>()" },
|
||||
{ PACKAGE_NAME + ".stop_at003b:63", PACKAGE_NAME + ".stop_at003b.<init>()" },
|
||||
{ PACKAGE_NAME + ".stop_at003b:66", PACKAGE_NAME + ".stop_at003b.<init>()" },
|
||||
{ PACKAGE_NAME + ".stop_at003b:72", PACKAGE_NAME + ".stop_at003b.foo()" }
|
||||
};
|
||||
static final String FAILURE_PATTERN = "Unable to set";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
for (int i = 0; i < LOCATIONS.length; i++) {
|
||||
if (!checkStop(LOCATIONS[i][0])) {
|
||||
failure("jdb failed to set line breakpoint at : " + LOCATIONS[i][0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < LOCATIONS.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
if (!jdb.isAtBreakpoint(reply, LOCATIONS[i][1])) {
|
||||
failure("Missed breakpoint at : " + LOCATIONS[i][0]);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkStop (String location) {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
log.display("Trying to set breakpoint at line: " + location);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_at + location);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(FAILURE_PATTERN);
|
||||
if (found.length() > 0) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
// THIS TEST IS LINE NUMBER SENSITIVE
|
||||
|
||||
package nsk.jdb.stop_at.stop_at003;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class stop_at003a {
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
stop_at003a _stop_at003a = new stop_at003a();
|
||||
// lastBreak();
|
||||
System.exit(stop_at003.JCK_STATUS_BASE + _stop_at003a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
stop_at003b b = new stop_at003b();
|
||||
b.foo();
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return stop_at003.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class stop_at003b {
|
||||
static int intField = 0;
|
||||
|
||||
static { intField = 1; } // stop_at003.LOCATIONS[0]
|
||||
|
||||
{ intField = 2; } // stop_at003.LOCATIONS[1]
|
||||
|
||||
stop_at003b () {
|
||||
intField++; // stop_at003.LOCATIONS[2]
|
||||
}
|
||||
|
||||
void foo () {
|
||||
try {
|
||||
throw new Exception("Exception in foo()");
|
||||
} catch (Exception e) { // stop_at003.LOCATIONS[3]
|
||||
System.out.println("Exception in foo() is catched.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/stop_in/stop_in002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* This is a test for the jdb "stop at <class:line>" command.
|
||||
* The test driver sets three breakpoints in debugged 'stop_in002b'
|
||||
* class:
|
||||
* - in static initilizer,
|
||||
* - in constructor,
|
||||
* - in a method of static nested class,
|
||||
* - in a method of instance nested class,
|
||||
* - in final method.
|
||||
* The test passes if the debuggee is suspended at every breakpoint
|
||||
* had been set and "Breakpoint hit" message had been printed in
|
||||
* jdb's output stream.
|
||||
* The test consists of:
|
||||
* nsk.jdb.stop_in.stop_in002.java - test driver,
|
||||
* nsk.jdb.stop_in.stop_in002a.java - debugged application.
|
||||
* COMMENTS
|
||||
* This test functionally covers nsk/jdb/stop_in/stop_in001 test
|
||||
* and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.stop_in.stop_in002.stop_in002
|
||||
* nsk.jdb.stop_in.stop_in002.stop_in002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.stop_in.stop_in002.stop_in002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.stop_in.stop_in002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* Regression test for:
|
||||
* Bug ID: 4299394
|
||||
* Synopsis: TTY: Deferred breakpoints can't be set on inner classes
|
||||
*
|
||||
*/
|
||||
|
||||
public class stop_in002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new stop_in002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.stop_in.stop_in002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".stop_in002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
static final String[] LOCATIONS = new String[] {
|
||||
PACKAGE_NAME + ".stop_in002b.<clinit>",
|
||||
PACKAGE_NAME + ".stop_in002b.<init>",
|
||||
PACKAGE_NAME + ".stop_in002b$StaticNested.m1",
|
||||
PACKAGE_NAME + ".stop_in002b$Inner.m2",
|
||||
PACKAGE_NAME + ".stop_in002b.foo"
|
||||
};
|
||||
static final String FAILURE_PATTERN = "Unable to set";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
for (int i = 0; i < LOCATIONS.length; i++) {
|
||||
if (!checkStop(LOCATIONS[i])) {
|
||||
failure("jdb failed to set line breakpoint at : " + LOCATIONS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < LOCATIONS.length; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
if (!jdb.isAtBreakpoint(reply, LOCATIONS[i])) {
|
||||
failure("Missed breakpoint at : " + LOCATIONS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
|
||||
private boolean checkStop (String location) {
|
||||
Paragrep grep;
|
||||
String[] reply;
|
||||
String found;
|
||||
boolean result = true;
|
||||
|
||||
log.display("Trying to set breakpoint at : " + location);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.stop_in + location);
|
||||
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(FAILURE_PATTERN);
|
||||
if (found.length() > 0) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.stop_in.stop_in002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class stop_in002a {
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
stop_in002a _stop_in002a = new stop_in002a();
|
||||
// lastBreak();
|
||||
System.exit(stop_in002.JCK_STATUS_BASE + _stop_in002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
stop_in002b b = new stop_in002b();
|
||||
stop_in002b.StaticNested.m1();
|
||||
b.inn.m2();
|
||||
b.foo(1);
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return stop_in002.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
class stop_in002b {
|
||||
static int intField = 0;
|
||||
Inner inn = null;
|
||||
|
||||
static { intField = 1; }
|
||||
|
||||
stop_in002b () {
|
||||
intField++;
|
||||
inn = new Inner();
|
||||
}
|
||||
|
||||
static class StaticNested {
|
||||
public static void m1() {}
|
||||
}
|
||||
|
||||
class Inner {
|
||||
public void m2() {}
|
||||
}
|
||||
|
||||
final int foo (int i) {return i++;}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/suspend/suspend001.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* A positive test case for the 'suspend <thread id>' command.
|
||||
* The debugged application (suspend001a.java) creates two addional threads.
|
||||
* First thead is of Suspended class, second one is of MyThread class.
|
||||
* The jdb stops debuggee at a moment after addional thread have started and
|
||||
* before their completion. Then jdb calls 'suspend' command with id of
|
||||
* the Suspended thread and resumes debuggee. The suspended thread should
|
||||
* not modify special int 'notSuspended' variable of the suspend001a class.
|
||||
* The test passes if suspend001a.notSuspended variable equals to 1, i.e.
|
||||
* only not-suspended MyThread thread had modified it.
|
||||
* The test consists of two program:
|
||||
* suspend001.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
|
||||
* suspend001a.java - the debugged application.
|
||||
* COMMENTS
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.suspend.suspend001.suspend001
|
||||
* nsk.jdb.suspend.suspend001.suspend001a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.suspend.suspend001.suspend001
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.suspend.suspend001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class suspend001 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new suspend001().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.suspend.suspend001";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".suspend001";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere";
|
||||
|
||||
static final String SUSPENDED = "Suspended";
|
||||
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + SUSPENDED;
|
||||
static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notSuspended";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
String[] threads;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
while (true) {
|
||||
threads = jdb.getThreadIds(DEBUGGEE_THREAD);
|
||||
if (threads.length != 1) {
|
||||
log.complain("jdb should report 1 instance of " + DEBUGGEE_THREAD);
|
||||
log.complain("Found: " + threads.length);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.suspend + threads[0]);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.cont);
|
||||
if (!jdb.isAtBreakpoint(reply)) {
|
||||
log.complain("Debugge does not reached second breakHere breakpoint");
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.eval + DEBUGGEE_RESULT);
|
||||
grep = new Paragrep(reply);
|
||||
found = grep.findFirst(DEBUGGEE_RESULT + " =" );
|
||||
if (found.length() > 0 && found.indexOf(DEBUGGEE_RESULT + " = null") < 0) {
|
||||
if (found.indexOf(DEBUGGEE_RESULT + " = 1") < 0) {
|
||||
log.complain("Wrong value of " + DEBUGGEE_RESULT);
|
||||
log.complain(found);
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
log.complain("TEST BUG: not found value for " + DEBUGGEE_RESULT);
|
||||
success = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
jdb.contToExit(2);
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.suspend.suspend001;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class suspend001a {
|
||||
static suspend001a _suspend001a = new suspend001a();
|
||||
|
||||
static JdbArgumentHandler argumentHandler;
|
||||
static Log log;
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.exit(suspend001.JCK_STATUS_BASE + _suspend001a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void breakHere () {}
|
||||
|
||||
static Object lock = new Object();
|
||||
static Object waitnotify = new Object();
|
||||
public static volatile int notSuspended = 0;
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
argumentHandler = new JdbArgumentHandler(args);
|
||||
log = new Log(out, argumentHandler);
|
||||
|
||||
Thread suspended = new Suspended("Suspended");
|
||||
Thread myThread = new MyThread("MyThread");
|
||||
|
||||
// lock monitor to prevent threads from finishing after they started
|
||||
synchronized (lock) {
|
||||
synchronized (waitnotify) {
|
||||
suspended.start();
|
||||
try {
|
||||
waitnotify.wait();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for start of Suspended thread");
|
||||
return suspend001.FAILED;
|
||||
}
|
||||
|
||||
myThread.start();
|
||||
try {
|
||||
waitnotify.wait();
|
||||
} catch (InterruptedException e) {
|
||||
log.complain("Main thread was interrupted while waiting for start of MyThread thread");
|
||||
return suspend001.FAILED;
|
||||
}
|
||||
}
|
||||
breakHere(); // a break to get thread ids and then to suspend Suspended thread.
|
||||
}
|
||||
|
||||
// wait for MyThread completion
|
||||
if (myThread.isAlive()) {
|
||||
try {
|
||||
myThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
log.display("Main thread was interrupted while waiting for finish of MyThread thread");
|
||||
}
|
||||
}
|
||||
|
||||
// give 3 seconds for suspended thread to finish (if it is not really suspended).
|
||||
try {
|
||||
Thread.currentThread().sleep(3 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
log.display("Main thread was interrupted while sleeping");
|
||||
}
|
||||
|
||||
breakHere(); // a break to check if Suspended was suspended
|
||||
|
||||
log.display("notSuspended == " + notSuspended);
|
||||
log.display("Debuggee PASSED");
|
||||
return suspend001.PASSED;
|
||||
}
|
||||
|
||||
public static int getResult() {
|
||||
return notSuspended;
|
||||
}
|
||||
}
|
||||
|
||||
class Suspended extends Thread {
|
||||
String name;
|
||||
|
||||
public Suspended (String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Concatenate strings in advance to avoid lambda calculations later
|
||||
final String ThreadFinished = "Thread finished: " + this.name;
|
||||
suspend001a.log.display("Thread started: " + this.name);
|
||||
|
||||
synchronized (suspend001a.waitnotify) {
|
||||
suspend001a.waitnotify.notify();
|
||||
}
|
||||
// prevent thread from early finish
|
||||
synchronized (suspend001a.lock) {}
|
||||
|
||||
suspend001a.notSuspended++;
|
||||
|
||||
suspend001a.log.display(ThreadFinished);
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
String name;
|
||||
|
||||
public MyThread (String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Concatenate strings in advance to avoid lambda calculations later
|
||||
final String ThreadFinished = "Thread finished: " + this.name;
|
||||
suspend001a.log.display("Thread started: " + this.name);
|
||||
|
||||
synchronized (suspend001a.waitnotify) {
|
||||
suspend001a.waitnotify.notify();
|
||||
}
|
||||
// prevent thread from early finish
|
||||
synchronized (suspend001a.lock) {}
|
||||
|
||||
suspend001a.notSuspended++;
|
||||
|
||||
suspend001a.log.display(ThreadFinished);
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/thread/thread002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This is a test for jdb 'thread <thread id>' command.
|
||||
* The debugee starts 5 'MyThreads' that are all suspended on the lock
|
||||
* that the main thread posseses. The 'threads' command is issued
|
||||
* at this point to obtain ids' od auxiliary threads. Then for each id
|
||||
* the 'thread' command is issued. The test checks that jdb correctly
|
||||
* switches between threads using 'eval <expr>' command. The expression
|
||||
* must return a string containing the name of current thread.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/threads/threads001 test
|
||||
* and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.thread.thread002.thread002
|
||||
* nsk.jdb.thread.thread002.thread002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.thread.thread002.thread002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.thread.thread002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class thread002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new thread002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.thread.thread002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".thread002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
static final String THREAD_NAME = "MyThread";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
String[] threadIds = jdb.getThreadIds(PACKAGE_NAME + "." + THREAD_NAME);
|
||||
|
||||
for (int i = 0; i < thread002a.numThreads; i++) {
|
||||
jdb.receiveReplyFor(JdbCommand.thread + threadIds[i]);
|
||||
jdb.receiveReplyFor(JdbCommand.print + DEBUGGEE_CLASS + ".holder[" + i + "].name");
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
|
||||
reply = jdb.getTotalReply();
|
||||
grep = new Paragrep(reply);
|
||||
for (int i = 0; i < threadIds.length; i++) {
|
||||
count = grep.find(THREAD_NAME + "#" + i);
|
||||
if (count != 1) {
|
||||
failure("jdb failed to switch to thread: " + threadIds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.thread.thread002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class thread002a {
|
||||
public static void main(String args[]) {
|
||||
thread002a _thread002a = new thread002a();
|
||||
System.exit(thread002.JCK_STATUS_BASE + _thread002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
static int numThreads = 5; // number of threads
|
||||
static Thread holder [] = new Thread[numThreads];
|
||||
|
||||
static Object waitnotify = new Object();
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
Lock lock = new Lock();
|
||||
|
||||
try {
|
||||
lock.setLock();
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
holder[i] = new MyThread(lock, "MyThread#" + i);
|
||||
synchronized (waitnotify) {
|
||||
holder[i].start();
|
||||
waitnotify.wait();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in main thread: " +
|
||||
e.getMessage());
|
||||
System.exit(thread002.FAILED);
|
||||
}
|
||||
|
||||
lastBreak(); // When jdb stops here, there should be 5 running MyThreads.
|
||||
lock.releaseLock();
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
try {
|
||||
holder[i].join(argumentHandler.getWaitTime() * 60000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Unexpected InterruptedException catched while waiting for join of: " + holder[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return thread002.PASSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Lock {
|
||||
boolean lockSet;
|
||||
|
||||
synchronized void setLock() throws InterruptedException {
|
||||
while (lockSet == true)
|
||||
wait();
|
||||
lockSet = true;
|
||||
}
|
||||
|
||||
synchronized void releaseLock() {
|
||||
if (lockSet == true) {
|
||||
lockSet = false;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
Lock lock;
|
||||
String name;
|
||||
|
||||
MyThread (Lock l, String name) {
|
||||
this.lock = l;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (thread002a.waitnotify) {
|
||||
thread002a.waitnotify.notifyAll();
|
||||
}
|
||||
try {
|
||||
lock.setLock();
|
||||
} catch(Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in MyThread: " +
|
||||
e.getMessage());
|
||||
System.exit(thread002.FAILED);
|
||||
}
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
106
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java
Normal file
106
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/threadgroup/threadgroup002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This is a test for jdb 'threadgroup <threadgroup_name>' command.
|
||||
* The main thread creates 3 threadgroups of 5 threads each.
|
||||
* All threads are locked in their 'run' method on a lock that the main
|
||||
* thread holds. The test passes if jdb correctly switches between
|
||||
* three user-defined threadgroups using 'threadgroup' command.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/threadgroup/threadgroup001
|
||||
* test and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.threadgroup.threadgroup002.threadgroup002
|
||||
* nsk.jdb.threadgroup.threadgroup002.threadgroup002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.threadgroup.threadgroup002.threadgroup002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.threadgroup.threadgroup002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class threadgroup002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new threadgroup002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.threadgroup.threadgroup002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".threadgroup002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
jdb.receiveReplyFor(JdbCommand.threadgroups);
|
||||
|
||||
for (int i = 0; i < threadgroup002a.numThreadGroups; i++) {
|
||||
reply = jdb.receiveReplyFor(JdbCommand.threadgroup + threadgroup002a.THREADGROUP_NAME + i);
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find("not a valid threadgroup name");
|
||||
if (count > 0) {
|
||||
failure("jdb cannot switch to valid threadgroup: " + threadgroup002a.THREADGROUP_NAME + i);
|
||||
}
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
134
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002a.java
Normal file
134
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002a.java
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.threadgroup.threadgroup002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class threadgroup002a {
|
||||
public static void main(String args[]) {
|
||||
threadgroup002a _threadgroup002a = new threadgroup002a();
|
||||
System.exit(threadgroup002.JCK_STATUS_BASE + _threadgroup002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
static int numThreadGroups = 3;
|
||||
static int numThreads = 15;
|
||||
static Object waitnotify = new Object();
|
||||
final static String THREADGROUP_NAME = "MyThreadGroup#";
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
ThreadGroup tgHolder[] = new ThreadGroup[numThreadGroups];
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
Lock lock = new Lock();
|
||||
|
||||
for (int i = 0; i < numThreadGroups ; i++ )
|
||||
tgHolder[i] = new ThreadGroup(THREADGROUP_NAME + i);
|
||||
|
||||
try {
|
||||
lock.setLock();
|
||||
int factor = numThreads / numThreadGroups;
|
||||
int k;
|
||||
for (int i = 0; i < numThreadGroups ; i++) {
|
||||
for (int j = 0; j < factor ; j++) {
|
||||
k = i * factor + j;
|
||||
holder[k] = new MyThread(lock, tgHolder[i], "MyThread#");
|
||||
synchronized (waitnotify) {
|
||||
holder[k].start();
|
||||
waitnotify.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in main thread: " +
|
||||
e.getMessage());
|
||||
System.exit(threadgroup002.FAILED);
|
||||
}
|
||||
|
||||
lastBreak(); // When jdb stops here, there should be 5 running MyThreads.
|
||||
lock.releaseLock();
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
try {
|
||||
holder[i].join(argumentHandler.getWaitTime() * 60000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Unexpected InterruptedException catched while waiting for join of: " + holder[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return threadgroup002.PASSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Lock {
|
||||
boolean lockSet;
|
||||
|
||||
synchronized void setLock() throws InterruptedException {
|
||||
while (lockSet == true)
|
||||
wait();
|
||||
lockSet = true;
|
||||
}
|
||||
|
||||
synchronized void releaseLock() {
|
||||
if (lockSet == true) {
|
||||
lockSet = false;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
Lock lock;
|
||||
MyThread (Lock l, ThreadGroup group, String name) {
|
||||
super(group, name);
|
||||
this.lock = l;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (threadgroup002a.waitnotify) {
|
||||
threadgroup002a.waitnotify.notifyAll();
|
||||
}
|
||||
try {
|
||||
lock.setLock();
|
||||
} catch(Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in MyThread: " +
|
||||
e.getMessage());
|
||||
System.exit(threadgroup002.FAILED);
|
||||
}
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
104
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroups/threadgroups002/threadgroups002.java
Normal file
104
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroups/threadgroups002/threadgroups002.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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
|
||||
*
|
||||
* @summary converted from VM Testbase nsk/jdb/threadgroups/threadgroups002.
|
||||
* VM Testbase keywords: [jpda, jdb]
|
||||
* VM Testbase readme:
|
||||
* DECSRIPTION
|
||||
* This is a test for jdb 'threadgroups' command.
|
||||
* The main thread creates 3 threadgroups of 5 threads each.
|
||||
* All threads are locked in their 'run' method on a lock that the main
|
||||
* thread holds. The 'threadgroups' command is issued at this point.
|
||||
* The test passes if three user-defined threadgroups are reported.
|
||||
* COMMENTS
|
||||
* This test functionally equals to nsk/jdb/threadgroups/threadgroups001
|
||||
* test and replaces it.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build nsk.jdb.threadgroups.threadgroups002.threadgroups002
|
||||
* nsk.jdb.threadgroups.threadgroups002.threadgroups002a
|
||||
* @run main/othervm PropertyResolvingWrapper nsk.jdb.threadgroups.threadgroups002.threadgroups002
|
||||
* -arch=${os.family}-${os.simpleArch}
|
||||
* -waittime=5
|
||||
* -debugee.vmkind=java
|
||||
* -transport.address=dynamic
|
||||
* -jdb=${test.jdk}/bin/jdb
|
||||
* -java.options="${test.vm.opts} ${test.java.opts}"
|
||||
* -workdir=.
|
||||
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
|
||||
*/
|
||||
|
||||
package nsk.jdb.threadgroups.threadgroups002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class threadgroups002 extends JdbTest {
|
||||
|
||||
public static void main (String argv[]) {
|
||||
System.exit(run(argv, System.out) + JCK_STATUS_BASE);
|
||||
}
|
||||
|
||||
public static int run(String argv[], PrintStream out) {
|
||||
debuggeeClass = DEBUGGEE_CLASS;
|
||||
firstBreak = FIRST_BREAK;
|
||||
lastBreak = LAST_BREAK;
|
||||
return new threadgroups002().runTest(argv, out);
|
||||
}
|
||||
|
||||
static final String PACKAGE_NAME = "nsk.jdb.threadgroups.threadgroups002";
|
||||
static final String TEST_CLASS = PACKAGE_NAME + ".threadgroups002";
|
||||
static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
|
||||
static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";
|
||||
static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";
|
||||
|
||||
protected void runCases() {
|
||||
String[] reply;
|
||||
Paragrep grep;
|
||||
int count;
|
||||
Vector v;
|
||||
String found;
|
||||
|
||||
jdb.setBreakpointInMethod(LAST_BREAK);
|
||||
jdb.receiveReplyFor(JdbCommand.cont);
|
||||
|
||||
reply = jdb.receiveReplyFor(JdbCommand.threadgroups);
|
||||
grep = new Paragrep(reply);
|
||||
count = grep.find(threadgroups002a.THREADGROUP_NAME);
|
||||
if (count != threadgroups002a.numThreadGroups ) {
|
||||
failure("Unexpected number of " + threadgroups002a.THREADGROUP_NAME + " was listed: " + count +
|
||||
"\n\texpected value: " + threadgroups002a.numThreadGroups);
|
||||
}
|
||||
|
||||
jdb.contToExit(1);
|
||||
}
|
||||
}
|
134
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroups/threadgroups002/threadgroups002a.java
Normal file
134
test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroups/threadgroups002/threadgroups002a.java
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
|
||||
package nsk.jdb.threadgroups.threadgroups002;
|
||||
|
||||
import nsk.share.*;
|
||||
import nsk.share.jpda.*;
|
||||
import nsk.share.jdb.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/* This is debuggee aplication */
|
||||
public class threadgroups002a {
|
||||
public static void main(String args[]) {
|
||||
threadgroups002a _threadgroups002a = new threadgroups002a();
|
||||
System.exit(threadgroups002.JCK_STATUS_BASE + _threadgroups002a.runIt(args, System.out));
|
||||
}
|
||||
|
||||
static void lastBreak () {}
|
||||
|
||||
static int numThreadGroups = 3;
|
||||
static int numThreads = 15;
|
||||
static Object waitnotify = new Object();
|
||||
final static String THREADGROUP_NAME = "MyThreadGroup#";
|
||||
|
||||
public int runIt(String args[], PrintStream out) {
|
||||
JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
|
||||
Log log = new Log(out, argumentHandler);
|
||||
|
||||
ThreadGroup tgHolder[] = new ThreadGroup[numThreadGroups];
|
||||
Thread holder [] = new Thread[numThreads];
|
||||
Lock lock = new Lock();
|
||||
|
||||
for (int i = 0; i < numThreadGroups ; i++ )
|
||||
tgHolder[i] = new ThreadGroup(THREADGROUP_NAME + i);
|
||||
|
||||
try {
|
||||
lock.setLock();
|
||||
int factor = numThreads / numThreadGroups;
|
||||
int k;
|
||||
for (int i = 0; i < numThreadGroups ; i++) {
|
||||
for (int j = 0; j < factor ; j++) {
|
||||
k = i * factor + j;
|
||||
holder[k] = new MyThread(lock, tgHolder[i], "MyThread#");
|
||||
synchronized (waitnotify) {
|
||||
holder[k].start();
|
||||
waitnotify.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in main thread: " +
|
||||
e.getMessage());
|
||||
System.exit(threadgroups002.FAILED);
|
||||
}
|
||||
|
||||
lastBreak(); // When jdb stops here, there should be 5 running MyThreads.
|
||||
lock.releaseLock();
|
||||
|
||||
for (int i = 0; i < numThreads ; i++) {
|
||||
if (holder[i].isAlive()) {
|
||||
try {
|
||||
holder[i].join(argumentHandler.getWaitTime() * 60000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new Failure("Unexpected InterruptedException catched while waiting for join of: " + holder[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.display("Debuggee PASSED");
|
||||
return threadgroups002.PASSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Lock {
|
||||
boolean lockSet;
|
||||
|
||||
synchronized void setLock() throws InterruptedException {
|
||||
while (lockSet == true)
|
||||
wait();
|
||||
lockSet = true;
|
||||
}
|
||||
|
||||
synchronized void releaseLock() {
|
||||
if (lockSet == true) {
|
||||
lockSet = false;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyThread extends Thread {
|
||||
|
||||
Lock lock;
|
||||
MyThread (Lock l, ThreadGroup group, String name) {
|
||||
super(group, name);
|
||||
this.lock = l;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized (threadgroups002a.waitnotify) {
|
||||
threadgroups002a.waitnotify.notifyAll();
|
||||
}
|
||||
try {
|
||||
lock.setLock();
|
||||
} catch(Exception e) {
|
||||
System.err.println("TEST ERROR: Caught unexpected Exception while waiting in MyThread: " +
|
||||
e.getMessage());
|
||||
System.exit(threadgroups002.FAILED);
|
||||
}
|
||||
lock.releaseLock();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user