[Proposal] debugger statement

48 views
Skip to first unread message

Adam Kirk

unread,
Mar 24, 2018, 8:29:54 AM3/24/18
to elixir-lang-core
Ok so this is just an idea and it might be ignorant:

What is `iex` had a `—debug` option that could be:

1) called with no value and by default elixir would find all `debugger` statements in your code, strip them out and set breakpoints on them. Maybe `debugger(3)` would skip 3 times

2) allow `—debug=file.ex:45` to set a breakpoint

3) maybe also a `—gui` option too?

The reason is, I write tests to debug things. I write a test that reproduces a problem and then I get the test to pass. Then it’ll never regress. But I’m stuck with IO.inspect and IEx.pry because Its not obvious how to use the step debugger when starting with `iex -S mix test`

Iex.pry is fine for stopping and looking around and trying things in context, so we’re half way there, but being able to just as easily step through code so i dont have to litter io.inspect everywhere would be so awesome.

One of the main reasons I’d love this is that while it requires me to edit my source, putting debugger where i want to stop is sooooooooo much easier than the setup work currently required (type file and line number or entire module and function name)

A debugger statement is so super easy to remember and use and people are familiar with it from ruby and javascript. It is the number one thing by far I miss from Ruby.

OvermindDL1

unread,
Mar 27, 2018, 4:47:26 PM3/27/18
to elixir-lang-core
Doesn't `IEX.pry` work well for that?  You can even gate it behind a configuration variable or so too.

Adam Kirk

unread,
Mar 27, 2018, 4:50:05 PM3/27/18
to elixir-lang-core
It does not allow stepping. If you're not sure what code path a test scenario is triggering, pry won't help you, you have to litter inspect statements everywhere

OvermindDL1

unread,
Mar 27, 2018, 7:03:17 PM3/27/18
to elixir-lang-core
Ah I missed that part entirely.  ^.^;

I guess in that case, what are you wanting to do and how do you want it to appear of something that the built-in `:debugger` or `:dbg` modules do not already do, or if you just want to wrap some of their functionality (as pry does a tiny bit), why not write a library for it so we can play with your idea to see how it works?  :-)

Onorio Catenacci

unread,
Mar 30, 2018, 3:57:41 PM3/30/18
to elixir-lang-core
You may also find this blog post (which I created with some help from a friend more familiar with Erlang than myself) apropos to this conversation.

https://onor.io/2016/02/17/quick-elixir-debugging-tip/
Reply all
Reply to author
Forward
0 new messages