/* * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 6202891 * @summary TTY: Add support for method exit event return values to jdb * @comment converted from test/jdk/com/sun/jdi/JdbMethodExitTest.sh * * @library /test/lib * @compile -g JdbMethodExitTest.java * @run main/othervm JdbMethodExitTest
*/
class JdbMethodExitTestTarg { // These are the values that will be returned by the methods static URL[] urls = new URL[1]; publicstaticbyte byteValue = 89; publicstaticchar charValue = 'x'; publicstaticdouble doubleValue = 2.2; publicstaticfloat floatValue = 3.3f; publicstaticint intValue = 1; publicstaticshort shortValue = 8; publicstaticboolean booleanValue = false;
// test all possible return types
execCommand(JdbCommand.run())
.shouldContain("Breakpoint hit");
Integer threadId = Integer.parseInt( new OutputAnalyzer(getDebuggeeOutput())
.firstMatch("^threadid=(.*)$", 1));
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.traceMethods(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace methods in effect");
jdb.command(JdbCommand.traceMethods(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go methods in effect");
jdb.command(JdbCommand.traceMethodExits(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace method exits in effect");
jdb.command(JdbCommand.traceMethodExits(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go method exits in effect");
jdb.command(JdbCommand.traceMethodExit(false, null));
execCommand(JdbCommand.trace())
.shouldContain("trace method exit in effect for JdbMethodExitTestTarg.bkpt");
jdb.command(JdbCommand.traceMethodExit(true, null));
execCommand(JdbCommand.trace())
.shouldContain("trace go method exit in effect for JdbMethodExitTestTarg.bkpt");
// trace exit of methods with all the return values // (but just check a couple of them)
jdb.command(JdbCommand.traceMethodExits(true, threadId));
execCommand(JdbCommand.cont())
.shouldContain("instance of JdbMethodExitTestTarg")
.shouldContain("return value = 8");
// Get out of bkpt back to the call to traceMethods
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.step())); // step into traceExit()
reply.addAll(jdb.command(JdbCommand.traceMethodExit(false, threadId)));
reply.addAll(jdb.command(JdbCommand.cont())); new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldContain("Method exited: return value = \"traceExit\"");
jdb.command(JdbCommand.untrace());
jdb.command(JdbCommand.stepUp());
reply.clear();
reply.addAll(jdb.command(JdbCommand.step()));
reply.addAll(jdb.command(JdbCommand.step())); // skip over setting return value in caller :-(
reply.addAll(jdb.command(JdbCommand.traceMethodExit(true, threadId)));
reply.addAll(jdb.command(JdbCommand.cont())); new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
.shouldMatch("Method exited: .*JdbMethodExitTestTarg.traceExit1");
new OutputAnalyzer(getJdbOutput())
.shouldContain("Breakpoint hit");
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.