File tree 5 files changed +57
-1
lines changed
src/debugAgentTest/kotlin
kotlinx-coroutines-core/jvm
5 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ sourceSets {
33
33
}
34
34
}
35
35
36
+ compileDebugAgentTestKotlin {
37
+ kotlinOptions {
38
+ freeCompilerArgs + = [" -Xallow-kotlin-package" ]
39
+ }
40
+ }
41
+
36
42
task npmTest (type : Test ) {
37
43
def sourceSet = sourceSets. npmTest
38
44
environment " projectRoot" , project. rootDir
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+ @file:Suppress(" INVISIBLE_MEMBER" , " INVISIBLE_REFERENCE" )
5
+ package kotlin.coroutines.jvm.internal
6
+
7
+ import kotlinx.coroutines.debug.internal.*
8
+ import kotlin.coroutines.*
9
+
10
+ internal fun <T > probeCoroutineCreated (completion : Continuation <T >): Continuation <T > = DebugProbesImpl .probeCoroutineCreated(completion)
11
+
12
+ internal fun probeCoroutineResumed (frame : Continuation <* >) = DebugProbesImpl .probeCoroutineResumed(frame)
13
+
14
+ internal fun probeCoroutineSuspended (frame : Continuation <* >) = DebugProbesImpl .probeCoroutineSuspended(frame)
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+ import org.junit.Test
5
+ import kotlin.test.*
6
+
7
+ /*
8
+ * This is intentionally put here instead of coreAgentTest to avoid accidental classpath replacing
9
+ * and ruining core agent test.
10
+ */
11
+ class PrecompiledDebugProbesTest {
12
+
13
+ @Test
14
+ fun testClassFileContent () {
15
+ val clz = Class .forName(" kotlin.coroutines.jvm.internal.DebugProbesKt" )
16
+ val className: String = clz.getName()
17
+ val classFileResourcePath = className.replace(" ." , " /" ) + " .class"
18
+ val stream = clz.classLoader.getResourceAsStream(classFileResourcePath)!!
19
+ val array = stream.readBytes()
20
+ val binFile = clz.classLoader.getResourceAsStream(" DebugProbesKt.bin" )!!
21
+ val binContent = binFile.readBytes()
22
+ assertTrue(array.contentEquals(binContent))
23
+ }
24
+
25
+ private fun diffpos (a : ByteArray , b : ByteArray , typeLenght : Int ): Int {
26
+ if (a.size == b.size) {
27
+ for (i in a.indices) {
28
+ if (a[i] != b[i]) {
29
+ println (i)
30
+ }
31
+ }
32
+ }
33
+ return - 1
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ internal object AgentPremain {
41
41
* DebugProbesKt.bin contains `kotlin.coroutines.jvm.internal.DebugProbesKt` class
42
42
* with method bodies that delegate all calls directly to their counterparts in
43
43
* kotlinx.coroutines.debug.DebugProbesImpl. This is done to avoid classfile patching
44
- * on the fly (-> get rid of ASM dependency)
44
+ * on the fly (-> get rid of ASM dependency).
45
+ * You can verify its content either by using javap on it or looking at out integration test module.
45
46
*/
46
47
return loader.getResourceAsStream(" DebugProbesKt.bin" ).readBytes()
47
48
}
You can’t perform that action at this time.
0 commit comments