Skip to content

Commit f2d20c4

Browse files
Show warning message when debuggee and debugger run at different jvms (microsoft#92)
* Show warning message when debuggee and debugger run at different jvms Signed-off-by: Jinbo Wang <[email protected]> * improve message per review comment Signed-off-by: Jinbo Wang <[email protected]>
1 parent 4a744df commit f2d20c4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/AttachRequestHandler.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.microsoft.java.debug.core.adapter.IDebugRequestHandler;
3030
import com.microsoft.java.debug.core.adapter.ISourceLookUpProvider;
3131
import com.microsoft.java.debug.core.adapter.IVirtualMachineManagerProvider;
32+
import com.microsoft.java.debug.core.protocol.Events;
3233
import com.microsoft.java.debug.core.protocol.Messages.Response;
3334
import com.microsoft.java.debug.core.protocol.Requests.Arguments;
3435
import com.microsoft.java.debug.core.protocol.Requests.AttachArguments;
@@ -58,6 +59,20 @@ public void handle(Command command, Arguments arguments, Response response, IDeb
5859
attachArguments.timeout);
5960
context.setDebugSession(debugSession);
6061
logger.info("Attaching to debuggee VM succeeded.");
62+
63+
// If the debugger and debuggee run at the different JVM platforms, show a warning message.
64+
if (debugSession != null) {
65+
String debuggeeVersion = debugSession.getVM().version();
66+
String debuggerVersion = System.getProperty("java.version");
67+
if (!debuggerVersion.equals(debuggeeVersion)) {
68+
String warnMessage = String.format("[Warn] The debugger and the debuggee are running in different versions of JVMs. "
69+
+ "You could see wrong source mapping results.\n"
70+
+ "Debugger JVM version: %s\n"
71+
+ "Debuggee JVM version: %s", debuggerVersion, debuggeeVersion);
72+
logger.warning(warnMessage);
73+
context.sendEvent(Events.OutputEvent.createConsoleOutput(warnMessage));
74+
}
75+
}
6176
} catch (IOException | IllegalConnectorArgumentsException e) {
6277
AdapterUtils.setErrorResponse(response, ErrorCode.ATTACH_FAILURE,
6378
String.format("Failed to attach to remote debuggee VM. Reason: %s", e.toString()));

0 commit comments

Comments
 (0)