Skip to content

Commit 99e4d77

Browse files
committed
8333117: Remove support of remote and manual debuggee launchers
Reviewed-by: cjplummer
1 parent 9ef86da commit 99e4d77

File tree

10 files changed

+105
-1534
lines changed

10 files changed

+105
-1534
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, 2023, 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
/**
@@ -198,11 +167,7 @@ private String[] makeJdbCmdLine (String classToExecute) {
198167
if (argumentHandler.isRawLaunchingConnector()) {
199168

200169
if (argumentHandler.isSocketTransport()) {
201-
if (argumentHandler.isLaunchedLocally()) {
202-
connectorAddress = argumentHandler.getTransportPort();
203-
} else {
204-
connectorAddress = argumentHandler.getDebugeeHost() + ":" + argumentHandler.getTransportPort();
205-
}
170+
connectorAddress = argumentHandler.getTransportPort();
206171
} else if (argumentHandler.isShmemTransport() ) {
207172
connectorAddress = argumentHandler.getTransportSharedName();
208173
} else {
@@ -247,8 +212,6 @@ private String[] makeJdbCmdLine (String classToExecute) {
247212

248213
if (argumentHandler.isSocketTransport()) {
249214
connect.append("port=" + argumentHandler.getTransportPort().trim());
250-
if (argumentHandler.isLaunchedRemotely())
251-
connect.append(",hostname=" + argumentHandler.getDebugeeHost().trim());
252215
} else if (argumentHandler.isShmemTransport()) {
253216
connect.append("name=" + argumentHandler.getTransportSharedName().trim());
254217
} else {
@@ -324,7 +287,7 @@ private String[] makeJdbCmdLine (String classToExecute) {
324287
private void localLaunchAndAttach
325288
(String[] jdbCmdArgs, String classToExecute) throws IOException {
326289

327-
debuggee = new LocalLaunchedDebuggee(this);
290+
debuggee = new Debuggee(this);
328291
String address = makeTransportAddress();
329292
String[] javaCmdArgs = makeCommandLineArgs(classToExecute, address);
330293
debuggee.launch(javaCmdArgs);
@@ -346,57 +309,12 @@ private String[] makeJdbCmdLine (String classToExecute) {
346309
String address = jdb.waitForListeningJdb();
347310
display("Listening address found: " + address);
348311

349-
debuggee = new LocalLaunchedDebuggee(this);
312+
debuggee = new Debuggee(this);
350313
String[] javaCmdArgs = makeCommandLineArgs(classToExecute, address);
351314
debuggee.launch(javaCmdArgs);
352315

353316
// jdb.waitForPrompt(0, false);
354317
}
355318

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

402320
} // 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)