enso/docs/debugger/chrome-devtools.md

1.9 KiB

Chrome Developer Tools Debugger

As a well written citizen of the GraalVM project the Enso language can be used with existing tools available for the overall platform. One of them is Chrome Debugger and Enso language is fully integrated with it. Launch the bin/enso executable with additional --inspect option and debug your Enso programs in Chrome Developer Tools.

enso$ ./built-distribution/enso-engine-*/enso-*/bin/enso --inspect --run ./test/Base_Tests/src/Data/Numbers_Spec.enso
Debugger listening on ws://127.0.0.1:9229/Wugyrg9
For help, see: https://www.graalvm.org/tools/chrome-debugger
E.g. in Chrome open: devtools://devtools/bundled/js_app.html?ws=127.0.0.1:9229/Wugyrg9

copy the printed URL into chrome browser and you should see:

Chrome Debugger

Step in, step over, set breakpoints, watch values of the variables as well as evaluate arbitrary expressions in the console. Note that as of December 2022, with GraalVM 22.3.0, there is a well-known bug in Truffle that causes NullPointerException when a host object gets into the chrome inspector. There is a workaround for that, but it may not work in certain situations. Therefore, if you encounter NullPointerException thrown from

at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextImpl.getContext(PolyglotContextImpl.java:685)

simply ignore it. It will be handled within the debugger and should not affect the rest of the environment.

Tips and tricks

  • Use env JAVA_OPTS=-Dpolyglot.inspect.Path=enso_debug to set the chrome to use a fixed URL. In this case the URL is devtools://devtools/bundled/js_app.html?ws=127.0.0.1:9229/enso_debug