diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003.java new file mode 100644 index 00000000000..3eed8f6edb5 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025, 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 + * + * @library /vmTestbase + * /test/lib + * @compile -g kill003a.java + * @run driver + * nsk.jdb.kill.kill003.kill003 + * -arch=${os.family}-${os.simpleArch} + * -waittime=5 + * -verbose + * -debugee.vmkind=java + * -transport.address=dynamic + * -jdb=${test.jdk}/bin/jdb + * -java.options="${test.vm.opts} ${test.java.opts}" + * -workdir=. + * -jdb.option="-trackallthreads" + * -debugee.vmkeys="${test.vm.opts} ${test.java.opts}" + */ + +package nsk.jdb.kill.kill003; + +import nsk.share.*; +import nsk.share.jdb.*; + +import java.io.*; +import java.util.*; + +public class kill003 extends JdbTest { + + public static void main (String argv[]) { + debuggeeClass = DEBUGGEE_CLASS; + firstBreak = FIRST_BREAK; + new kill003().runTest(argv); + } + + static final String PACKAGE_NAME = "nsk.jdb.kill.kill003"; + static final String TEST_CLASS = PACKAGE_NAME + ".kill003"; + 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_EXCEPTION = DEBUGGEE_CLASS + ".exception"; + + protected void runCases() { + String[] reply; + String[] threads; + + + // Stopped at kill.main, so step into synchronized block + reply = jdb.receiveReplyFor(JdbCommand.next); + + // At this point we are at the breakpoint triggered by the breakHere() call done + // after creating all the threads. Get the list of debuggee threads. + threads = jdb.getThreadIdsByName("main"); + + if (threads.length != 1) { + log.complain("jdb should report " + 1 + " instance of " + DEBUGGEE_THREAD); + log.complain("Found: " + threads.length); + success = false; + } + + reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[0] + " " + DEBUGGEE_EXCEPTION, + "killed"); + + reply = jdb.receiveReplyFor(JdbCommand.cont); + + reply = jdb.receiveReplyForWithMessageWait(JdbCommand.locals, "locals"); + + if (jdb.terminated()) { + throw new Failure("Debuggee exited"); + } + + jdb.contToExit(1); + } +} diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003a.java new file mode 100644 index 00000000000..15900aba751 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003a.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025, 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.kill003; + +import nsk.share.*; +import nsk.share.jpda.*; +import nsk.share.jdb.*; +import nsk.share.jdi.JDIThreadFactory; +import jdk.test.lib.thread.VThreadPinner; + +import java.io.*; +import java.util.*; + +/* This is debuggee aplication */ +public class kill003a { + static NullPointerException exception = new NullPointerException(); + + public static void main(String args[]) { + synchronized (args) { + } + System.exit(JdbTest.JCK_STATUS_BASE); + } +}