Merge "Remove 1.3s "Waiting for Debugger" delay" am: e5527c234e am: 7f45627502

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2305923

Change-Id: I148078dd054ed8efa38e8aff06ffdd40216a9882
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Fabien Sanglard
2022-12-21 20:13:54 +00:00
committed by Automerger Merge Worker

View File

@@ -981,6 +981,43 @@ public final class Debug
}
/**
* Wait until a debugger attaches. As soon as a debugger attaches,
* suspend all Java threads and send VM_START (a.k.a VM_INIT)
* packet.
*
* @hide
*/
public static void suspendAllAndSendVmStart() {
if (!VMDebug.isDebuggingEnabled()) {
return;
}
// if DDMS is listening, inform them of our plight
System.out.println("Sending WAIT chunk");
byte[] data = new byte[] { 0 }; // 0 == "waiting for debugger"
Chunk waitChunk = new Chunk(ChunkHandler.type("WAIT"), data, 0, 1);
DdmServer.sendChunk(waitChunk);
// We must wait until a debugger is connected (debug socket is
// open and at least one non-DDM JDWP packedt has been received.
// This guarantees that oj-libjdwp has been attached and that
// ART's default implementation of suspendAllAndSendVmStart has
// been replaced with an implementation that will suspendAll and
// send VM_START.
System.out.println("Waiting for debugger first packet");
while (!isDebuggerConnected()) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
}
}
System.out.println("Debug.suspendAllAndSentVmStart");
VMDebug.suspendAllAndSendVmStart();
System.out.println("Debug.suspendAllAndSendVmStart, resumed");
}
/**
* Wait until a debugger attaches. As soon as the debugger attaches,
* this returns, so you will need to place a breakpoint after the