Bug 355572 - Trace JDI request/response times
diff --git a/org.eclipse.jdt.debug/.options b/org.eclipse.jdt.debug/.options index 2eb48a6..66f229c 100644 --- a/org.eclipse.jdt.debug/.options +++ b/org.eclipse.jdt.debug/.options
@@ -1,2 +1,3 @@ org.eclipse.jdt.debug/debug=false -org.eclipse.jdt.debug/debug/jdiEvents=false \ No newline at end of file +org.eclipse.jdt.debug/debug/jdiEvents=false +org.eclipse.jdt.debug/debug/jdiRequestTimes=false
diff --git a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/MirrorImpl.java b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/MirrorImpl.java index 4c15198..a3b0048 100644 --- a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/MirrorImpl.java +++ b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/MirrorImpl.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.util.Date; import java.util.Map; import org.eclipse.jdi.Bootstrap; @@ -23,7 +24,10 @@ import org.eclipse.jdi.internal.jdwp.JdwpPacket; import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket; import org.eclipse.jdi.internal.jdwp.JdwpString; +import org.eclipse.jdt.internal.debug.core.JDIDebugOptions; +import com.ibm.icu.text.DateFormat; +import com.ibm.icu.text.SimpleDateFormat; import com.sun.jdi.ClassNotPreparedException; import com.sun.jdi.InternalException; import com.sun.jdi.InvalidStackFrameException; @@ -51,7 +55,10 @@ protected VerboseWriter fVerboseWriter = null; /** True if a Jdwp request has been sent to the VM and the response is not yet (fully) processed. */ private boolean fPendingJdwpRequest = false; - + + // used for debug messages + private static final DateFormat LOCAL_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); //$NON-NLS-1$ + /** * Constructor only to be used by Virtual Machine objects: stores description of Mirror object and Virtual Machine. */ @@ -167,11 +174,25 @@ public JdwpReplyPacket requestVM(int command, byte[] outData) { JdwpCommandPacket commandPacket = new JdwpCommandPacket(command); commandPacket.setData(outData); + long sent = System.currentTimeMillis(); fVirtualMachineImpl.packetSendManager().sendPacket(commandPacket); fPendingJdwpRequest = true; writeVerboseCommandPacketHeader(commandPacket); JdwpReplyPacket reply = fVirtualMachineImpl.packetReceiveManager().getReply(commandPacket); + long recieved = System.currentTimeMillis(); + if (JDIDebugOptions.DEBUG_JDI_REQUEST_TIMES) { + StringBuffer buf = new StringBuffer(); + buf.append(LOCAL_SDF.format(new Date(sent))); + buf.append(" JDI Request: "); //$NON-NLS-1$ + buf.append(commandPacket.toString()); + buf.append("\n\tResponse Time: "); //$NON-NLS-1$ + buf.append(recieved - sent); + buf.append("ms"); //$NON-NLS-1$ + buf.append(" length: "); //$NON-NLS-1$ + buf.append(reply.getLength()); + System.out.println(buf.toString()); + } if (fVerboseWriter != null) { fVerboseWriter.println(); fVerboseWriter.println("Received reply"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JDIDebugOptions.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JDIDebugOptions.java index 9f1fdc3..71bdecc 100644 --- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JDIDebugOptions.java +++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JDIDebugOptions.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,10 +21,13 @@ // debug option flags public static boolean DEBUG = false; public static boolean DEBUG_JDI_EVENTS = false; + public static boolean DEBUG_JDI_REQUEST_TIMES = false; public static void initDebugOptions() { DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.jdt.debug/debug")); //$NON-NLS-1$//$NON-NLS-2$ DEBUG_JDI_EVENTS = DEBUG && "true".equals( //$NON-NLS-1$ Platform.getDebugOption("org.eclipse.jdt.debug/debug/jdiEvents")); //$NON-NLS-1$ + DEBUG_JDI_REQUEST_TIMES = DEBUG && "true".equals( //$NON-NLS-1$ + Platform.getDebugOption("org.eclipse.jdt.debug/debug/jdiRequestTimes")); //$NON-NLS-1$ } }