8282691: add jdb "-R" option for passing any argument to the launched debuggee process

Reviewed-by: alanb, kevinw
This commit is contained in:
Chris Plummer 2022-03-14 18:15:40 +00:00
parent f66070b00d
commit 5bf6a7f7d7
4 changed files with 35 additions and 6 deletions
src/jdk.jdi/share
classes/com/sun/tools/example/debug/tty
man
test/jdk/com/sun/jdi

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, 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
@ -993,6 +993,8 @@ public class TTY implements EventNotifier {
token.startsWith("-ss") || token.startsWith("-oss") ) {
javaArgs = addArgument(javaArgs, token);
} else if (token.startsWith("-R")) {
javaArgs = addArgument(javaArgs, token.substring(2));
} else if (token.equals("-tclassic")) {
usageError("Classic VM no longer supported.");
return;

@ -477,8 +477,9 @@ public class TTYResources extends java.util.ListResourceBundle {
" -dbgtrace [flags] print info for debugging {0}\n" +
" -tclient run the application in the HotSpot(TM) Client Compiler\n" +
" -tserver run the application in the HotSpot(TM) Server Compiler\n" +
" -R<option> forward <option> to debuggee process if launched by jdb, otherwise ignored\n" +
"\n" +
"options forwarded to debuggee process:\n" +
"options forwarded to debuggee process if lauched by jdb (shorthand instead of using -R):\n" +
" -v -verbose[:class|gc|jni]\n" +
" turn on verbose mode\n" +
" -D<name>=<value> set a system property\n" +

@ -1,4 +1,4 @@
.\" Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1995, 2022, 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
@ -230,8 +230,9 @@ Runs the application in the Java HotSpot VM server.
.RE
.TP
.B \f[CB]\-J\f[R]\f[I]option\f[R]
Passes \f[I]option\f[R] to the JVM, where option is one of the options
described on the reference page for the Java application launcher.
Passes \f[I]option\f[R] to the JDB JVM, where option is one of the
options described on the reference page for the Java application
launcher.
For example, \f[CB]\-J\-Xms48m\f[R] sets the startup memory to 48 MB.
See \f[I]Overview of Java Options\f[R] in \f[B]java\f[R].
.RS
@ -239,6 +240,15 @@ See \f[I]Overview of Java Options\f[R] in \f[B]java\f[R].
.PP
The following options are forwarded to the debuggee process:
.TP
.B \f[CB]\-R\f[R]\f[I]option\f[R]
Passes \f[I]option\f[R] to the debuggee JVM, where option is one of the
options described on the reference page for the Java application
launcher.
For example, \f[CB]\-R\-Xms48m\f[R] sets the startup memory to 48 MB.
See \f[I]Overview of Java Options\f[R] in \f[B]java\f[R].
.RS
.RE
.TP
.B \f[CB]\-v\f[R] or \f[CB]\-verbose\f[R][\f[CB]:\f[R]\f[I]class\f[R]|\f[CB]gc\f[R]|\f[CB]jni\f[R]]
Turns on the verbose mode.
.RS

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, 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
@ -151,6 +151,22 @@ public class JdbOptions {
.expectedArg("-XX:StartFlightRecording:dumponexit=true,maxsize=500M")
.expectedArg("-XX:FlightRecorderOptions:repository=jfrrep");
// -R is tested to see if options are passed through.
test("-R-Dprop1=val1",
"-R-Dprop2=val 2",
"-R-Xmixed",
"-R--add-modules", "-Rjdk.attach",
"-R-Xcheck:jni",
"-R--enable-preview",
"-connect",
"com.sun.jdi.CommandLineLaunch:vmexec=java,main=" + targ + " " + outFilename + " prop1 prop2")
.expectedProp("prop1", "val1")
.expectedProp("prop2", "val 2")
.expectedArg("-Xmixed")
.expectedArg("--add-modules=jdk.attach")
.expectedArg("-Xcheck:jni")
.expectedArg("--enable-preview");
}
private static class TestResult {