Using ‘IEx.pry’ lets you block an operation and access its bindings. Unlike pdb and pry in Ruby, it’s not a full-fledged debugger but it’s a quick way to look into your execution.

require IEx; # First, require the IEx module

defmodule Bob do
  def say(message) do
  	 IEx.pry # debug this line
    IO.puts "[#{inspect self}] Bob says: #{message}"

Running the above code in iex will now block at the specified line. You can continue with respawn.

An alternative method of debugging which gives you a full fledged debugger is to use the Erlang :debugger.

iex> c "bob.ex"
iex> :debugger.start # opens a GUI debugger
iex> :int.break(Bob, 4) # creates breakpoint at line 4
iex> Bob.say("Hello there")

After we call our function, we can see our process with break status in the debugger. We can add a new breakpoint in the monitor window, inspect the code, see the variables and navigate it in steps.

Additional reading: