Skip to content

Commit 6ca70cd

Browse files
committed
8333117: Remove support of remote and manual debuggee launchers
Reviewed-by: mbaesken Backport-of: 99e4d77aac72cdddb4973805d28c225f17ea965f
1 parent 48c70ec commit 6ca70cd

File tree

10 files changed

+104
-1540
lines changed

10 files changed

+104
-1540
lines changed

test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Debuggee.java

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,55 +30,15 @@
3030
import java.io.*;
3131

3232
/**
33-
* Interface defining methods to control mirror of debuggee (i.e. debugged VM).
33+
* Class defining methods to control mirror of debuggee (i.e. debugged VM).
3434
*/
35-
public interface Debuggee {
35+
public class Debuggee extends LocalProcess {
3636

3737
/** Default prefix for log messages. */
3838
public static final String LOG_PREFIX = "debuggee> ";
3939
public static final String DEBUGEE_STDOUT_LOG_PREFIX = "debuggee.stdout> ";
4040
public static final String DEBUGEE_STDERR_LOG_PREFIX = "debuggee.stderr> ";
4141

42-
/**
43-
* Launch debuggee.
44-
*
45-
* @throws IOException
46-
*/
47-
public void launch (String[] args) throws IOException;
48-
49-
/** Return exit status. */
50-
public int getStatus ();
51-
52-
/** Check whether the process has been terminated. */
53-
public boolean terminated();
54-
55-
/** Kill the debuggee VM. */
56-
public void killDebuggee ();
57-
58-
/** Wait until the debuggee VM shutdown or crash. */
59-
public int waitForDebuggee () throws InterruptedException;
60-
61-
/** Get a pipe to write to the debuggee's stdin stream. */
62-
public OutputStream getInPipe ();
63-
64-
/** Get a pipe to read the debuggee's stdout stream. */
65-
public InputStream getOutPipe ();
66-
67-
/** Get a pipe to read the debuggee's stderr stream. */
68-
public InputStream getErrPipe ();
69-
70-
/** Redirect stdout stream to <code>Log</code> */
71-
public void redirectStdout(Log log, String prefix);
72-
73-
/** Redirect stderr stream to <code>Log</code> */
74-
public void redirectStderr(Log log, String prefix);
75-
}
76-
77-
/**
78-
* Mirror of locally launched debuggee.
79-
*/
80-
final class LocalLaunchedDebuggee extends LocalProcess implements Debuggee {
81-
8242
private IORedirector stdoutRedirector = null;
8343
private IORedirector stderrRedirector = null;
8444
private IORedirector stdinRedirector = null;
@@ -90,7 +50,7 @@ final class LocalLaunchedDebuggee extends LocalProcess implements Debuggee {
9050
private Launcher launcher = null;
9151

9252
/** Enwrap the existing <code>VM</code> mirror. */
93-
LocalLaunchedDebuggee (Launcher launcher) {
53+
Debuggee(Launcher launcher) {
9454
super();
9555
this.launcher = launcher;
9656
}
@@ -235,70 +195,3 @@ public void redirectStderr(Log log, String prefix) {
235195
}
236196

237197

238-
/**
239-
* Mirror of remotely launched debuggee.
240-
*/
241-
final class RemoteLaunchedDebuggee implements Debuggee {
242-
243-
/** Launcher that creates this debuggee. */
244-
private Launcher launcher = null;
245-
246-
/** Enwrap the existing <code>VM</code> mirror. */
247-
RemoteLaunchedDebuggee (Launcher launcher) {
248-
super();
249-
this.launcher = launcher;
250-
}
251-
252-
/**
253-
* Launch debugee on remote host via <code>Launcher</code> object.
254-
*/
255-
public void launch(String[] args) throws IOException {
256-
String cmdLine = ArgumentHandler.joinArguments(args, "\"");
257-
launcher.display("Starting remote java process:\n" + cmdLine);
258-
launcher.launchRemoteProcess(args);
259-
}
260-
261-
/** Return exit status of the debuggee VM. */
262-
public int getStatus () {
263-
return launcher.getRemoteProcessStatus();
264-
}
265-
266-
/** Check whether the debuggee VM has been terminated. */
267-
public boolean terminated () {
268-
return launcher.isRemoteProcessTerminated();
269-
}
270-
271-
// ---------------------------------------------- //
272-
273-
/** Kill the debuggee VM. */
274-
public void killDebuggee () {
275-
launcher.killRemoteProcess();
276-
}
277-
278-
/** Wait until the debuggee VM shutdown or crash. */
279-
public int waitForDebuggee () {
280-
return launcher.waitForRemoteProcess();
281-
}
282-
283-
/** Get a pipe to write to the debuggee's stdin stream. */
284-
public OutputStream getInPipe () {
285-
return null;
286-
}
287-
288-
/** Get a pipe to read the debuggee's stdout stream. */
289-
public InputStream getOutPipe () {
290-
return null;
291-
}
292-
293-
/** Get a pipe to read the debuggee's stderr stream. */
294-
public InputStream getErrPipe () {
295-
return null;
296-
}
297-
298-
public void redirectStdout(Log log, String prefix) {
299-
}
300-
301-
public void redirectStderr(Log log, String prefix) {
302-
}
303-
304-
}

test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java

Lines changed: 17 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -103,52 +103,21 @@ public void launchJdbAndDebuggee (String classToExecute) throws IOException {
103103

104104
String[] jdbCmdArgs = makeJdbCmdLine(classToExecute);
105105

106-
if (argumentHandler.isLaunchedLocally()) {
107-
108-
if (argumentHandler.isDefaultConnector()) {
109-
110-
localDefaultLaunch(jdbCmdArgs, classToExecute);
111-
112-
} else if (argumentHandler.isRawLaunchingConnector()) {
113-
114-
localRawLaunch(jdbCmdArgs, classToExecute);
115-
116-
} else if (argumentHandler.isLaunchingConnector()) {
117-
118-
localLaunch(jdbCmdArgs, classToExecute);
119-
120-
} else if (argumentHandler.isAttachingConnector()) {
121-
122-
localLaunchAndAttach(jdbCmdArgs, classToExecute);
123-
124-
} else if (argumentHandler.isListeningConnector()) {
125-
126-
localLaunchAndListen(jdbCmdArgs, classToExecute);
127-
128-
} else {
129-
throw new TestBug("Unexpected connector type for local launch mode"
130-
+ argumentHandler.getConnectorType());
131-
}
132-
133-
} else if (argumentHandler.isLaunchedRemotely()) {
134-
135-
connectToBindServer(classToExecute);
136-
137-
if (argumentHandler.isAttachingConnector()) {
138-
139-
remoteLaunchAndAttach(jdbCmdArgs, classToExecute);
140-
141-
} else if (argumentHandler.isListeningConnector()) {
142-
143-
remoteLaunchAndListen(jdbCmdArgs, classToExecute);
144-
145-
} else {
146-
throw new TestBug("Unexpected connector type for remote launch mode"
147-
+ argumentHandler.getConnectorType());
148-
}
106+
if (argumentHandler.isDefaultConnector()) {
107+
localDefaultLaunch(jdbCmdArgs, classToExecute);
108+
} else if (argumentHandler.isRawLaunchingConnector()) {
109+
localRawLaunch(jdbCmdArgs, classToExecute);
110+
} else if (argumentHandler.isLaunchingConnector()) {
111+
localLaunch(jdbCmdArgs, classToExecute);
112+
} else if (argumentHandler.isAttachingConnector()) {
113+
localLaunchAndAttach(jdbCmdArgs, classToExecute);
114+
} else if (argumentHandler.isListeningConnector()) {
115+
localLaunchAndListen(jdbCmdArgs, classToExecute);
149116
} else {
150-
throw new Failure("Unexpected launching mode: " + argumentHandler.getLaunchMode());
117+
throw new TestBug("Unexpected connector type for local launch mode"
118+
+ argumentHandler.getConnectorType());
151119
}
120+
152121
}
153122

154123
/**
@@ -189,11 +158,7 @@ private String[] makeJdbCmdLine (String classToExecute) {
189158
if (argumentHandler.isRawLaunchingConnector()) {
190159

191160
if (argumentHandler.isSocketTransport()) {
192-
if (argumentHandler.isLaunchedLocally()) {
193-
connectorAddress = argumentHandler.getTransportPort();
194-
} else {
195-
connectorAddress = argumentHandler.getDebugeeHost() + ":" + argumentHandler.getTransportPort();
196-
}
161+
connectorAddress = argumentHandler.getTransportPort();
197162
} else if (argumentHandler.isShmemTransport() ) {
198163
connectorAddress = argumentHandler.getTransportSharedName();
199164
} else {
@@ -235,8 +200,6 @@ private String[] makeJdbCmdLine (String classToExecute) {
235200

236201
if (argumentHandler.isSocketTransport()) {
237202
connect.append("port=" + argumentHandler.getTransportPort().trim());
238-
if (argumentHandler.isLaunchedRemotely())
239-
connect.append(",hostname=" + argumentHandler.getDebugeeHost().trim());
240203
} else if (argumentHandler.isShmemTransport()) {
241204
connect.append("name=" + argumentHandler.getTransportSharedName().trim());
242205
} else {
@@ -312,7 +275,7 @@ private String[] makeJdbCmdLine (String classToExecute) {
312275
private void localLaunchAndAttach
313276
(String[] jdbCmdArgs, String classToExecute) throws IOException {
314277

315-
debuggee = new LocalLaunchedDebuggee(this);
278+
debuggee = new Debuggee(this);
316279
String address = makeTransportAddress();
317280
String[] javaCmdArgs = makeCommandLineArgs(classToExecute, address);
318281
debuggee.launch(javaCmdArgs);
@@ -334,57 +297,12 @@ private String[] makeJdbCmdLine (String classToExecute) {
334297
String address = jdb.waitForListeningJdb();
335298
display("Listening address found: " + address);
336299

337-
debuggee = new LocalLaunchedDebuggee(this);
300+
debuggee = new Debuggee(this);
338301
String[] javaCmdArgs = makeCommandLineArgs(classToExecute, address);
339302
debuggee.launch(javaCmdArgs);
340303

341304
// jdb.waitForPrompt(0, false);
342305
}
343306

344-
/**
345-
* Run test in remote mode using attaching connector.
346-
*/
347-
private void remoteLaunchAndAttach
348-
(String[] jdbCmdArgs, String classToExecute) throws IOException {
349-
350-
debuggee = new RemoteLaunchedDebuggee(this);
351-
String address = makeTransportAddress();
352-
String[] javaCmdArgs = makeCommandLineArgs(classToExecute, address);
353-
try {
354-
debuggee.launch(javaCmdArgs);
355-
} catch (IOException e) {
356-
throw new Failure("Caught exception while launching debuggee VM process:\n\t"
357-
+ e);
358-
};
359-
360-
display("Start jdb attaching to remote debuggee");
361-
jdb = Jdb.startAttachingJdb (this, jdbCmdArgs, JDB_STARTED);
362-
// jdb.waitForPrompt(0, false);
363-
}
364-
365-
/**
366-
* Run test in remote mode using listening connector.
367-
*/
368-
private void remoteLaunchAndListen
369-
(String[] jdbCmdArgs, String classToExecute) throws IOException {
370-
371-
jdb = new Jdb(this);
372-
display("Starting jdb listening to remote debuggee");
373-
jdb.launch(jdbCmdArgs);
374-
String address = jdb.waitForListeningJdb();
375-
display("Listening address found: " + address);
376-
377-
debuggee = new RemoteLaunchedDebuggee(this);
378-
String[] javaCmdArgs = makeCommandLineArgs(classToExecute);
379-
try {
380-
debuggee.launch(javaCmdArgs);
381-
} catch (IOException e) {
382-
throw new Failure("Caught exception while launching debuggee VM process:\n\t"
383-
+ e);
384-
};
385-
386-
jdb.waitForMessage(0, JDB_STARTED);
387-
// jdb.waitForPrompt(0, false);
388-
}
389307

390308
} // End of Launcher

test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -457,18 +457,6 @@ protected void checkOptions() {
457457
}
458458
*/
459459

460-
if (! isLaunchedLocally() && ! isDefaultDebugeeSuspendMode()) {
461-
throw new BadOption("inconsistent options: "
462-
+ "-debugee.launch=" + getLaunchMode()
463-
+ " and -debugee.suspend=" + getDebugeeSuspendMode());
464-
}
465-
466-
if (! isLaunchedLocally() && isLaunchingConnector()) {
467-
throw new BadOption("inconsistent options: "
468-
+ "-debugee.launch=" + getLaunchMode()
469-
+ " and -connector=" + getConnectorType());
470-
}
471-
472460
if (isLaunchingConnector() && ! isDefaultTransport()) {
473461
throw new BadOption("inconsistent options: "
474462
+ "-connector=" + getConnectorType()

0 commit comments

Comments
 (0)