Debugging the Gleam code rather than the compilation output #4710
-
When questions about debugging Gleam code were posted in the Gleam Discord, the response was that we should use the debugger provided by our project's runtime (debugging generated Erlang or JavaScript code). This makes sense, but I see that the Elixir LSP provides an implementation for the Debug Adapter Protocol. If I understand correctly, it allows us to debug Elixir code when running the Erlang code it was compiled to under the hood. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'm not familiar with the protocol but I'm sure we could somehow implement DAP for Gleam as well seeing how it's implemented for Elixir and many other languages. |
Beta Was this translation helpful? Give feedback.
-
JavaScript supports sourcemaps, which means if we implement those on the JavaScript target, JavaScript debuggers will be able to step through the generated code as if it's Gleam code. Some work was done on that, but the PR's author did not complete it. |
Beta Was this translation helpful? Give feedback.
-
Elixir has a canonical runtime so they can wrap its debugger. Gleam does not. A community project could implement the protocol and expose the BEAM debugger for Gleam, there's nothing that would be needed from the core team to do this. Note that's how it is in Elixir, it is a community project and not provided by core. |
Beta Was this translation helpful? Give feedback.
Elixir has a canonical runtime so they can wrap its debugger. Gleam does not.
A community project could implement the protocol and expose the BEAM debugger for Gleam, there's nothing that would be needed from the core team to do this.
Note that's how it is in Elixir, it is a community project and not provided by core.