8230303: JDB hangs when running monitor command jdk8u272-b01

Tue, 10 Sep 2019 09:08:52 -0700

author
igerasim
date
Tue, 10 Sep 2019 09:08:52 -0700
changeset 9962
85c9d74850ed
parent 9961
be13f53a2a55
child 9963
741cd0f77fac
child 9964
45ec778a8e8d

8230303: JDB hangs when running monitor command
Reviewed-by: sspitsyn

test/vmTestbase/nsk/jdb/monitor/monitor002/monitor002.java file | annotate | diff | comparison | revisions
test/vmTestbase/nsk/jdb/monitor/monitor002/monitor002a.java file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/vmTestbase/nsk/jdb/monitor/monitor002/monitor002.java	Tue Sep 10 09:08:52 2019 -0700
     1.3 @@ -0,0 +1,136 @@
     1.4 +/*
     1.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +
    1.28 +/*
    1.29 + * @test
    1.30 + *
    1.31 + * @summary JDB problem running monitor command
    1.32 + * VM Testbase keywords: [jpda, jdb]
    1.33 + * VM Testbase readme:
    1.34 + * DESCRIPTION
    1.35 + * Make sure 'monitor unmonitor 1' does not cause ConcurrentModificationException
    1.36 + * in the debugger.
    1.37 + * The jdb sets up line breakpoint at the debugged application. Then one command
    1.38 + * 'monitor unmonitor 1' is set. After resuming the debuggee stops at the breakpoint.
    1.39 + * The test passes if correct reply for "unmonitor 1" commanda is found in jdb stdout
    1.40 + * stream.
    1.41 + * The test consists of two program:
    1.42 + *   monitor002.java - launches jdb and debuggee, writes commands to jdb, reads the jdb output,
    1.43 + *   monitor002a.java - the debugged application.
    1.44 + *
    1.45 + * @library /vmTestbase
    1.46 + *          /test/lib
    1.47 + * @run driver jdk.test.lib.FileInstaller . .
    1.48 + * @build nsk.jdb.monitor.monitor002.monitor002
    1.49 + *        nsk.jdb.monitor.monitor002.monitor002a
    1.50 + * @run main/othervm PropertyResolvingWrapper nsk.jdb.monitor.monitor002.monitor002
    1.51 + *      -arch=${os.family}-${os.simpleArch}
    1.52 + *      -waittime=5
    1.53 + *      -debugee.vmkind=java
    1.54 + *      -transport.address=dynamic
    1.55 + *      -jdb=${test.jdk}/bin/jdb
    1.56 + *      -java.options="${test.vm.opts} ${test.java.opts}"
    1.57 + *      -workdir=.
    1.58 + *      -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
    1.59 + */
    1.60 +
    1.61 +package nsk.jdb.monitor.monitor002;
    1.62 +
    1.63 +import nsk.share.*;
    1.64 +import nsk.share.jdb.*;
    1.65 +
    1.66 +import java.io.*;
    1.67 +import java.util.*;
    1.68 +
    1.69 +public class monitor002 extends JdbTest {
    1.70 +
    1.71 +    public static void main (String argv[]) {
    1.72 +        System.exit(run(argv, System.out) + JCK_STATUS_BASE);
    1.73 +    }
    1.74 +
    1.75 +    public static int run(String argv[], PrintStream out) {
    1.76 +        debuggeeClass =  DEBUGGEE_CLASS;
    1.77 +        firstBreak = FIRST_BREAK;
    1.78 +        lastBreak = LAST_BREAK;
    1.79 +        return new monitor002().runTest(argv, out);
    1.80 +    }
    1.81 +
    1.82 +    static final String PACKAGE_NAME = "nsk.jdb.monitor.monitor002";
    1.83 +    static final String TEST_CLASS = PACKAGE_NAME + ".monitor002";
    1.84 +    static final String DEBUGGEE_CLASS = TEST_CLASS + "a";
    1.85 +    static final String FIRST_BREAK        = DEBUGGEE_CLASS + ".main";
    1.86 +    static final String LAST_BREAK         = DEBUGGEE_CLASS + ".lastBreak";
    1.87 +    static final int    LINE_NUMBER        = 47;
    1.88 +
    1.89 +    static final String[] CHECKED_COMMANDS = {
    1.90 +        JdbCommand.unmonitor + "1"
    1.91 +                                             };
    1.92 +
    1.93 +    protected void runCases() {
    1.94 +        String[] reply;
    1.95 +        Paragrep grep;
    1.96 +        int count;
    1.97 +        Vector v;
    1.98 +        String found;
    1.99 +
   1.100 +        reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + LINE_NUMBER);
   1.101 +
   1.102 +        for (int i = 0; i < CHECKED_COMMANDS.length; i++) {
   1.103 +            reply = jdb.receiveReplyFor(JdbCommand.monitor + CHECKED_COMMANDS[i]);
   1.104 +        }
   1.105 +
   1.106 +        int repliesCount = CHECKED_COMMANDS.length + 1;
   1.107 +        reply = jdb.receiveReplyFor(JdbCommand.cont, true, repliesCount);
   1.108 +
   1.109 +        reply = jdb.receiveReplyFor(JdbCommand.monitor);
   1.110 +        if (reply.length != 1) {
   1.111 +            log.complain("Expected no active monitors after exectuting monitored command: " + CHECKED_COMMANDS[0]);
   1.112 +            success = false;
   1.113 +        }
   1.114 +
   1.115 +        jdb.contToExit(1);
   1.116 +
   1.117 +        reply = jdb.getTotalReply();
   1.118 +
   1.119 +        if (!checkCommands(reply)) {
   1.120 +            success = false;
   1.121 +        }
   1.122 +    }
   1.123 +
   1.124 +    private boolean checkCommands(String[] reply) {
   1.125 +        Paragrep grep;
   1.126 +        boolean result = true;
   1.127 +        int count;
   1.128 +
   1.129 +        grep = new Paragrep(reply);
   1.130 +
   1.131 +        if ((count = grep.find("Unmonitoring 1:  unmonitor 1")) != 1) {
   1.132 +            log.complain("Wrong number of execution of monitored command: " + CHECKED_COMMANDS[0]);
   1.133 +            log.complain("    Expected: 1; found: " + count);
   1.134 +            result = false;
   1.135 +        }
   1.136 +
   1.137 +        return result;
   1.138 +    }
   1.139 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/vmTestbase/nsk/jdb/monitor/monitor002/monitor002a.java	Tue Sep 10 09:08:52 2019 -0700
     2.3 @@ -0,0 +1,52 @@
     2.4 +/*
     2.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +package nsk.jdb.monitor.monitor002;
    2.28 +
    2.29 +import nsk.share.*;
    2.30 +import nsk.share.jpda.*;
    2.31 +import nsk.share.jdb.*;
    2.32 +
    2.33 +import java.io.*;
    2.34 +
    2.35 +//    THIS TEST IS LINE NUMBER SENSITIVE
    2.36 +
    2.37 +/* This is debuggee aplication */
    2.38 +public class monitor002a {
    2.39 +    static monitor002a _monitor002a = new monitor002a();
    2.40 +
    2.41 +    public static void main(String args[]) {
    2.42 +        System.exit(monitor002.JCK_STATUS_BASE + _monitor002a.runIt(args, System.out));
    2.43 +    }
    2.44 +
    2.45 +    static void lastBreak () {}
    2.46 +
    2.47 +    public int runIt(String args[], PrintStream out) {
    2.48 +        JdbArgumentHandler argumentHandler = new JdbArgumentHandler(args);
    2.49 +        Log log = new Log(out, argumentHandler);
    2.50 +        int localInt = 0; // monitor002.LINE_NUMBER
    2.51 +        localInt++; // dummy breakpoint
    2.52 +        log.display("Debuggee PASSED");
    2.53 +        return monitor002.PASSED;
    2.54 +    }
    2.55 +}

mercurial