[coroutine stepping]: obtain coroutines running on the current thread without evaluation.

[coroutine-stepping]: Temporarily revert evaluation of computing ids of coroutines running on the current thread. Replaced evaluation with a direct call to the method in DebugProbesImpl. Used helper class as a fast path.

Currently, evaluation does not work for K2.


Co-authored-by: Egor Ushakov <Egor.Ushakov@jetbrains.com>


Merge-request: IJ-MR-126011
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>

GitOrigin-RevId: 940fdde35b88950ebe535e37d53fe20a1da5906f
This commit is contained in:
Maria Sokolova
2024-02-14 21:11:25 +00:00
committed by intellij-monorepo-bot
parent 501ff1c58b
commit 09f2e12232
7 changed files with 97 additions and 65 deletions

View File

@@ -34,5 +34,6 @@
</library>
</orderEntry>
<orderEntry type="library" name="JUnit4" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
</component>
</module>

View File

@@ -0,0 +1,23 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.rt.debugger;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings({"KotlinInternalInJava", "UnnecessaryFullyQualifiedName"})
public final class CoroutinesDebugHelper {
public static long[] getCoroutinesRunningOnCurrentThread(kotlinx.coroutines.debug.internal.DebugProbesImpl instance) {
Thread currentThread = Thread.currentThread();
List<Long> coroutinesIds = new ArrayList<>();
for (kotlinx.coroutines.debug.internal.DebugCoroutineInfo info : instance.dumpCoroutinesInfo()) {
if (info.getLastObservedThread() == currentThread) {
coroutinesIds.add(info.getSequenceNumber());
}
}
long[] res = new long[coroutinesIds.size()];
for (int i = 0; i < res.length; i++) {
res[i] = coroutinesIds.get(i).longValue();
}
return res;
}
}