Skip to content

Commit 309b929

Browse files
committed
8336401: Remove the option onjcmd from the jdwp agent
Reviewed-by: cjplummer, mbaesken
1 parent 401d0d6 commit 309b929

File tree

5 files changed

+2
-241
lines changed

5 files changed

+2
-241
lines changed

src/hotspot/share/services/diagnosticCommand.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "runtime/fieldDescriptor.inline.hpp"
5353
#include "runtime/flags/jvmFlag.hpp"
5454
#include "runtime/handles.inline.hpp"
55-
#include "runtime/interfaceSupport.inline.hpp"
5655
#include "runtime/javaCalls.hpp"
5756
#include "runtime/jniHandles.hpp"
5857
#include "runtime/os.hpp"
@@ -160,11 +159,6 @@ void DCmd::register_dcmds(){
160159
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
161160
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
162161

163-
// Debug on cmd (only makes sense with JVMTI since the agentlib needs it).
164-
#if INCLUDE_JVMTI
165-
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DebugOnCmdStartDCmd>(full_export, true, true));
166-
#endif // INCLUDE_JVMTI
167-
168162
#if INCLUDE_CDS
169163
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DumpSharedArchiveDCmd>(full_export, true, false));
170164
#endif // INCLUDE_CDS
@@ -1058,45 +1052,6 @@ void DumpSharedArchiveDCmd::execute(DCmdSource source, TRAPS) {
10581052
}
10591053
#endif // INCLUDE_CDS
10601054

1061-
#if INCLUDE_JVMTI
1062-
extern "C" typedef char const* (JNICALL *debugInit_startDebuggingViaCommandPtr)(JNIEnv* env, jthread thread, char const** transport_name,
1063-
char const** address, jboolean* first_start);
1064-
static debugInit_startDebuggingViaCommandPtr dvc_start_ptr = nullptr;
1065-
1066-
void DebugOnCmdStartDCmd::execute(DCmdSource source, TRAPS) {
1067-
char const* transport = nullptr;
1068-
char const* addr = nullptr;
1069-
jboolean is_first_start = JNI_FALSE;
1070-
JavaThread* thread = THREAD;
1071-
jthread jt = JNIHandles::make_local(thread->threadObj());
1072-
ThreadToNativeFromVM ttn(thread);
1073-
const char *error = "Could not find jdwp agent.";
1074-
1075-
if (!dvc_start_ptr) {
1076-
JvmtiAgentList::Iterator it = JvmtiAgentList::agents();
1077-
while (it.has_next()) {
1078-
JvmtiAgent* agent = it.next();
1079-
if ((strcmp("jdwp", agent->name()) == 0) && (dvc_start_ptr == nullptr)) {
1080-
char const* func = "debugInit_startDebuggingViaCommand";
1081-
dvc_start_ptr = (debugInit_startDebuggingViaCommandPtr) os::find_agent_function(agent, false, &func, 1);
1082-
}
1083-
}
1084-
}
1085-
1086-
if (dvc_start_ptr) {
1087-
error = dvc_start_ptr(thread->jni_environment(), jt, &transport, &addr, &is_first_start);
1088-
}
1089-
1090-
if (error != nullptr) {
1091-
output()->print_cr("Debugging has not been started: %s", error);
1092-
} else {
1093-
output()->print_cr(is_first_start ? "Debugging has been started." : "Debugging is already active.");
1094-
output()->print_cr("Transport : %s", transport ? transport : "#unknown");
1095-
output()->print_cr("Address : %s", addr ? addr : "#unknown");
1096-
}
1097-
}
1098-
#endif // INCLUDE_JVMTI
1099-
11001055
ThreadDumpToFileDCmd::ThreadDumpToFileDCmd(outputStream* output, bool heap) :
11011056
DCmdWithParser(output, heap),
11021057
_overwrite("-overwrite", "May overwrite existing file", "BOOLEAN", false, "false"),

src/hotspot/share/services/diagnosticCommand.hpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -886,27 +886,6 @@ class ClassesDCmd : public DCmdWithParser {
886886
virtual void execute(DCmdSource source, TRAPS);
887887
};
888888

889-
#if INCLUDE_JVMTI
890-
class DebugOnCmdStartDCmd : public DCmd {
891-
public:
892-
DebugOnCmdStartDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}
893-
static const char* name() {
894-
return "VM.start_java_debugging";
895-
}
896-
static const char* description() {
897-
return "Starts up the Java debugging if the jdwp agentlib was enabled with the option onjcmd=y.";
898-
}
899-
static const char* impact() {
900-
return "High: Switches the VM into Java debug mode.";
901-
}
902-
static const JavaPermission permission() {
903-
JavaPermission p = { "java.lang.management.ManagementPermission", "control", nullptr };
904-
return p;
905-
}
906-
virtual void execute(DCmdSource source, TRAPS);
907-
};
908-
#endif // INCLUDE_JVMTI
909-
910889
class EventLogDCmd : public DCmdWithParser {
911890
protected:
912891
DCmdArgument<char*> _log;

src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ static unsigned logflags = 0; /* Log flags */
8181

8282
static char *names; /* strings derived from OnLoad options */
8383

84-
static jboolean allowStartViaJcmd = JNI_FALSE; /* if true we allow the debugging to be started via a jcmd */
85-
static jboolean startedViaJcmd = JNI_FALSE; /* if false, we have not yet started debugging via a jcmd */
86-
8784
/*
8885
* Elements of the transports bag
8986
*/
@@ -983,7 +980,6 @@ parseOptions(char *options)
983980
int length;
984981
char *str;
985982
char *errmsg;
986-
jboolean onJcmd = JNI_FALSE;
987983

988984
/* Set defaults */
989985
gdata->assertOn = DEFAULT_ASSERT_ON;
@@ -1231,10 +1227,6 @@ parseOptions(char *options)
12311227
if ( !get_boolean(&str, &useStandardAlloc) ) {
12321228
goto syntax_error;
12331229
}
1234-
} else if (strcmp(buf, "onjcmd") == 0) {
1235-
if (!get_boolean(&str, &onJcmd)) {
1236-
goto syntax_error;
1237-
}
12381230
} else {
12391231
goto syntax_error;
12401232
}
@@ -1285,20 +1277,6 @@ parseOptions(char *options)
12851277
}
12861278
}
12871279

1288-
if (onJcmd) {
1289-
if (launchOnInit != NULL) {
1290-
errmsg = "Cannot combine onjcmd and launch suboptions";
1291-
goto bad_option_with_errmsg;
1292-
}
1293-
if (!isServer) {
1294-
errmsg = "Can only use onjcmd with server=y";
1295-
goto bad_option_with_errmsg;
1296-
}
1297-
suspendOnInit = JNI_FALSE;
1298-
initOnStartup = JNI_FALSE;
1299-
allowStartViaJcmd = JNI_TRUE;
1300-
}
1301-
13021280
return JNI_TRUE;
13031281

13041282
syntax_error:
@@ -1367,45 +1345,3 @@ debugInit_exit(jvmtiError error, const char *msg)
13671345
// Last chance to die, this kills the entire process.
13681346
forceExit(EXIT_JVMTI_ERROR);
13691347
}
1370-
1371-
static jboolean getFirstTransport(void *item, void *arg)
1372-
{
1373-
TransportSpec** store = arg;
1374-
*store = item;
1375-
1376-
return JNI_FALSE; /* Want the first */
1377-
}
1378-
1379-
/* Call to start up debugging. */
1380-
JNIEXPORT char const* JNICALL debugInit_startDebuggingViaCommand(JNIEnv* env, jthread thread, char const** transport_name,
1381-
char const** address, jboolean* first_start) {
1382-
jboolean is_first_start = JNI_FALSE;
1383-
TransportSpec* spec = NULL;
1384-
1385-
if (!vmInitialized) {
1386-
return "Not yet initialized. Try again later.";
1387-
}
1388-
1389-
if (!allowStartViaJcmd) {
1390-
return "Starting debugging via jcmd was not enabled via the onjcmd option of the jdwp agent.";
1391-
}
1392-
1393-
if (!startedViaJcmd) {
1394-
startedViaJcmd = JNI_TRUE;
1395-
is_first_start = JNI_TRUE;
1396-
initialize(env, thread, EI_VM_INIT, NULL);
1397-
}
1398-
1399-
bagEnumerateOver(transports, getFirstTransport, &spec);
1400-
1401-
if ((spec != NULL) && (transport_name != NULL) && (address != NULL)) {
1402-
*transport_name = spec->name;
1403-
*address = spec->address;
1404-
}
1405-
1406-
if (first_start != NULL) {
1407-
*first_start = is_first_start;
1408-
}
1409-
1410-
return NULL;
1411-
}

test/jdk/com/sun/jdi/OnJcmdTest.java

Lines changed: 0 additions & 109 deletions
This file was deleted.

test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* jdk.jfr.event.runtime.TestAgentEvent
6666
* testJavaDynamic
6767
*
68-
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -agentlib:jdwp=transport=dt_socket,server=y,address=any,onjcmd=y
68+
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0
6969
* jdk.jfr.event.runtime.TestAgentEvent
7070
* testNativeStatic
7171
*/
@@ -122,7 +122,7 @@ private static void testNativeStatic() throws Throwable {
122122
RecordedEvent e = events.get(1);
123123
System.out.println(e);
124124
Events.assertField(e, "name").equal("jdwp");
125-
Events.assertField(e, "options").equal("transport=dt_socket,server=y,address=any,onjcmd=y");
125+
Events.assertField(e, "options").equal("transport=dt_socket,server=y,suspend=n,address=0");
126126
Events.assertField(e, "dynamic").equal(false);
127127
Instant initializationTime = e.getInstant("initializationTime");
128128
if (initializationTime.isAfter(interval.getStartTime())) {

0 commit comments

Comments
 (0)