Hello,
Perhaps a little bit more of a fundamental debugging question, but is there a reason why consecutive IEx.pry
's in a recursive context are being skipped after 2 times?
system information output:
System information
> $ elixir -v
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.10.3 (compiled with Erlang/OTP 21)
> $ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Example code:
defmodule Example do
require IEx
def recursive_hi(0), do: IO.puts("hi0")
def recursive_hi(n) do
IEx.pry()
IO.puts("hi#{n}")
recursive_hi(n - 1)
end
end
Output when trying to debug with iex -S mix run (compiled module in mix project):
iex(1)> recompile;
Compiling 1 file (.ex)
:ok
iex(2)> Example.recursive_hi 5
Break reached: Example.recursive_hi/1 (lib/ex_gherkin/example/example.ex:7)
5:
6: def recursive_hi(n) do
7: IEx.pry()
8: IO.puts("hi#{n}")
9: recursive_hi(n - 1)
pry(1)> n
5
pry(2)> continue
hi5
Break reached: Example.recursive_hi/1 (lib/ex_gherkin/example/example.ex:7)
5:
6: def recursive_hi(n) do
7: IEx.pry()
8: IO.puts("hi#{n}")
9: recursive_hi(n - 1)
pry(1)> n
4
pry(2)> continue
hi4
Break reached: Example.recursive_hi/1 (lib/ex_gherkin/example/example.ex:7)
5:
6: def recursive_hi(n) do
7: IEx.pry()
8: IO.puts("hi#{n}")
9: recursive_hi(n - 1)
hi3
Break reached: Example.recursive_hi/1 (lib/ex_gherkin/example/example.ex:7)
5:
6: def recursive_hi(n) do
7: IEx.pry()
8: IO.puts("hi#{n}")
9: recursive_hi(n - 1)
hi2
Break reached: Example.recursive_hi/1 (lib/ex_gherkin/example/example.ex:7)
5:
6: def recursive_hi(n) do
7: IEx.pry()
8: IO.puts("hi#{n}")
9: recursive_hi(n - 1)
hi1
hi0
:ok
As you can see in the last “output” section, it is possible to pry into it the first 2 times, but after that it just keeps executing without “freezing”. Am I understanding some fundamentals wrong here or?
Right now I’m using the Erlang debugger (:debugger.start / :int.break(__ MODULE __, line) / etc…) to work around this “issue”.
Thank you in advance.