[Debugging] How to dump the state of all the MicroEJ threads

Sometimes you want to dump the state of all the MicroEJ threads: name, priority, stack trace, etc…
There are two way to do it:

From the native code

The internal MicroEJ OS Core Engine function called LLMJVM_dump allows to do it. This function can be called at any time and from an interrupt routine (for instance from a button interrupt).

Refer to section 7.4.6 Debugging of the DeviceDeveloperGuide

From the Java code

LLMJVM_dump can be reproduced in Java following those steps

  1. Add the ivy dependency <dependency org="com.microej.library" name="profiling" rev="[0.0.0-RC0,1.0.0-RC0[" />
  2. Call ThreadsProfiler.printStackTraces();

However as this will require some computation time from the JVM, if the VM is blocked by another Thread, the function won’t be executed.

1 Like