From 6df21dca930976bc2a0d18bae0ad521d7d27ec9e Mon Sep 17 00:00:00 2001 From: Pierfrancesco Soffritti Date: Wed, 12 May 2021 14:40:34 +0100 Subject: [PATCH 1/2] Move DebugProbesKt from debug to core module --- .../jvm/src/debug/internal/DebugProbes.kt | 14 ++++++++++++++ kotlinx-coroutines-debug/src/DebugProbes.kt | 7 ------- kotlinx-coroutines-debug/src/internal/Attach.kt | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt diff --git a/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt new file mode 100644 index 0000000000..14747acbd1 --- /dev/null +++ b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.coroutines.debug.internal + +import kotlin.coroutines.* + +// Stubs which are injected as coroutine probes. Require direct match of signatures +internal fun probeCoroutineResumed(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineResumed(frame) + +internal fun probeCoroutineSuspended(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineSuspended(frame) +internal fun probeCoroutineCreated(completion: Continuation): Continuation = + DebugProbesImpl.probeCoroutineCreated(completion) \ No newline at end of file diff --git a/kotlinx-coroutines-debug/src/DebugProbes.kt b/kotlinx-coroutines-debug/src/DebugProbes.kt index 373864adb8..ed346d8136 100644 --- a/kotlinx-coroutines-debug/src/DebugProbes.kt +++ b/kotlinx-coroutines-debug/src/DebugProbes.kt @@ -143,10 +143,3 @@ public object DebugProbes { */ public fun dumpCoroutines(out: PrintStream = System.out): Unit = DebugProbesImpl.dumpCoroutines(out) } - -// Stubs which are injected as coroutine probes. Require direct match of signatures -internal fun probeCoroutineResumed(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineResumed(frame) - -internal fun probeCoroutineSuspended(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineSuspended(frame) -internal fun probeCoroutineCreated(completion: Continuation): Continuation = - DebugProbesImpl.probeCoroutineCreated(completion) diff --git a/kotlinx-coroutines-debug/src/internal/Attach.kt b/kotlinx-coroutines-debug/src/internal/Attach.kt index f38447f72a..f1cc96e6d3 100644 --- a/kotlinx-coroutines-debug/src/internal/Attach.kt +++ b/kotlinx-coroutines-debug/src/internal/Attach.kt @@ -20,7 +20,7 @@ internal class ByteBuddyDynamicAttach : Function1 { private fun attach() { ByteBuddyAgent.install(ByteBuddyAgent.AttachmentProvider.ForEmulatedAttachment.INSTANCE) val cl = Class.forName("kotlin.coroutines.jvm.internal.DebugProbesKt") - val cl2 = Class.forName("kotlinx.coroutines.debug.DebugProbesKt") + val cl2 = Class.forName("kotlinx.coroutines.debug.internal.DebugProbesKt") ByteBuddy() .redefine(cl2) From 8c24b35023bd9c3e86df2cca739194b671c14f56 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Tue, 18 May 2021 15:38:19 +0300 Subject: [PATCH 2/2] Add additional comment --- .../jvm/src/debug/internal/DebugProbes.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt index 14747acbd1..8dc5b7c23d 100644 --- a/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt +++ b/kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbes.kt @@ -2,13 +2,21 @@ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ +@file:Suppress("unused") + package kotlinx.coroutines.debug.internal import kotlin.coroutines.* +/* + * This class is used by ByteBuddy from kotlinx-coroutines-debug as kotlin.coroutines.jvm.internal.DebugProbesKt replacement. + * In theory, it should belong to kotlinx-coroutines-debug, but placing it here significantly simplifies the + * Android AS debugger that does on-load DEX transformation + */ + // Stubs which are injected as coroutine probes. Require direct match of signatures internal fun probeCoroutineResumed(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineResumed(frame) internal fun probeCoroutineSuspended(frame: Continuation<*>) = DebugProbesImpl.probeCoroutineSuspended(frame) internal fun probeCoroutineCreated(completion: Continuation): Continuation = - DebugProbesImpl.probeCoroutineCreated(completion) \ No newline at end of file + DebugProbesImpl.probeCoroutineCreated(completion)