Skip to content

Commit a68376c

Browse files
committed
Add section about Android in debug agent readme
1 parent 418ba80 commit a68376c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

docs/debugging.md

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ To improve user experience, `kotlinx.coroutines` comes with additional features
1717
and debug agent.
1818

1919
## Debug mode
20+
2021
The first debugging feature of `kotlinx.coroutines` is debug mode.
2122
It can be enabled either by setting system property [DEBUG_PROPERTY_NAME] or by running Java with enabled assertions (`-ea` flag).
2223
The latter is helpful to have debug mode enabled by default in unit tests.
@@ -26,6 +27,7 @@ a string representation of coroutine and thread name executing named coroutine.
2627
Overhead of this feature is negligible and it can be safely turned on by default to simplify logging and diagnostic.
2728

2829
## Stacktrace recovery
30+
2931
Stacktrace recovery is another useful feature of debug mode. It is enabled by default in the debug mode,
3032
but can be separately disabled by setting `kotlinx.coroutines.stacktrace.recovery` system property to `false`.
3133

@@ -41,6 +43,7 @@ It is easy to demonstrate with actual stacktraces of the same program that await
4143
The only downside of this approach is losing referential transparency of the exception.
4244

4345
### Stacktrace recovery machinery
46+
4447
This section explains the inner mechanism of stacktrace recovery and can be skipped.
4548

4649
When an exception is rethrown between coroutines (e.g. through `withContext` or `Deferred.await` boundary), stacktrace recovery
@@ -54,14 +57,31 @@ Exception copy logic is straightforward:
5457
3) Otherwise, one of the public exception's constructor is invoked reflectively with optional an `initCause` call.
5558

5659
## Debug agent
60+
5761
[kotlinx-coroutines-debug](../kotlinx-coroutines-debug) module provides one of the most powerful debug capabilities in `kotlinx.coroutines`.
5862

5963
This is a separate module with a JVM agent that keeps track of all alive coroutines, introspect and dump them similar to thread dump command,
6064
additionally enhancing stacktraces with information where coroutine was created.
6165

6266
The full tutorial of how to use debug agent can be found in a corresponding [readme](../kotlinx-coroutines-debug/README.md).
6367

68+
### Debug agent and Android
69+
70+
Unfortunately, Android runtime does not support Instrument API necessary for `kotlinx-coroutines-debug` to function, triggering `java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;`.
71+
72+
Nevertheless, it will be possible to support debug agent on Android as soon as [GradleAspectJ-Android](https://github.com/Archinamon/android-gradle-aspectj) will support androin-gradle 3.3
6473

74+
<!---
75+
Make an exception googlable
76+
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;
77+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent$ProcessProvider$ForCurrentVm$ForLegacyVm.resolve(ByteBuddyAgent.java:1055)
78+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent$ProcessProvider$ForCurrentVm.resolve(ByteBuddyAgent.java:1038)
79+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:374)
80+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:342)
81+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:328)
82+
at kotlinx.coroutines.debug.internal.DebugProbesImpl.install(DebugProbesImpl.kt:39)
83+
at kotlinx.coroutines.debug.DebugProbes.install(DebugProbes.kt:49)
84+
-->
6585

6686
<!--- MODULE kotlinx-coroutines-core -->
6787
<!--- INDEX kotlinx.coroutines -->

kotlinx-coroutines-debug/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ Dumping only deferred
100100
API is purely experimental and it is not guaranteed that it won't be changed (while it is marked as `@ExperimentalCoroutinesApi`).
101101
Do not use this module in production environment and do not rely on the format of the data produced by [DebugProbes].
102102

103+
### Debug agent and Android
104+
105+
Unfortunately, Android runtime does not support Instrument API necessary for `kotlinx-coroutines-debug` to function, triggering `java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;`.
106+
107+
Nevertheless, it will be possible to support debug agent on Android as soon as [GradleAspectJ-Android](https://github.com/Archinamon/android-gradle-aspectj) will support androin-gradle 3.3
108+
109+
<!---
110+
Make an exception googlable
111+
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;
112+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent$ProcessProvider$ForCurrentVm$ForLegacyVm.resolve(ByteBuddyAgent.java:1055)
113+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent$ProcessProvider$ForCurrentVm.resolve(ByteBuddyAgent.java:1038)
114+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:374)
115+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:342)
116+
at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:328)
117+
at kotlinx.coroutines.debug.internal.DebugProbesImpl.install(DebugProbesImpl.kt:39)
118+
at kotlinx.coroutines.debug.DebugProbes.install(DebugProbes.kt:49)
119+
-->
120+
103121
<!--- MODULE kotlinx-coroutines-core -->
104122
<!--- INDEX kotlinx.coroutines -->
105123
[Job]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html

0 commit comments

Comments
 (0)