You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+20
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ To improve user experience, `kotlinx.coroutines` comes with additional features
17
17
and debug agent.
18
18
19
19
## Debug mode
20
+
20
21
The first debugging feature of `kotlinx.coroutines` is debug mode.
21
22
It can be enabled either by setting system property [DEBUG_PROPERTY_NAME] or by running Java with enabled assertions (`-ea` flag).
22
23
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.
26
27
Overhead of this feature is negligible and it can be safely turned on by default to simplify logging and diagnostic.
27
28
28
29
## Stacktrace recovery
30
+
29
31
Stacktrace recovery is another useful feature of debug mode. It is enabled by default in the debug mode,
30
32
but can be separately disabled by setting `kotlinx.coroutines.stacktrace.recovery` system property to `false`.
31
33
@@ -41,6 +43,7 @@ It is easy to demonstrate with actual stacktraces of the same program that await
41
43
The only downside of this approach is losing referential transparency of the exception.
42
44
43
45
### Stacktrace recovery machinery
46
+
44
47
This section explains the inner mechanism of stacktrace recovery and can be skipped.
45
48
46
49
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:
54
57
3) Otherwise, one of the public exception's constructor is invoked reflectively with optional an `initCause` call.
55
58
56
59
## Debug agent
60
+
57
61
[kotlinx-coroutines-debug](../kotlinx-coroutines-debug) module provides one of the most powerful debug capabilities in `kotlinx.coroutines`.
58
62
59
63
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,
60
64
additionally enhancing stacktraces with information where coroutine was created.
61
65
62
66
The full tutorial of how to use debug agent can be found in a corresponding [readme](../kotlinx-coroutines-debug/README.md).
63
67
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
Copy file name to clipboardExpand all lines: kotlinx-coroutines-debug/README.md
+18
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,24 @@ Dumping only deferred
100
100
API is purely experimental and it is not guaranteed that it won't be changed (while it is marked as `@ExperimentalCoroutinesApi`).
101
101
Do not use this module in production environment and do not rely on the format of the data produced by [DebugProbes].
102
102
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
0 commit comments