The Erlang Debugger

The standard Erlang distribution contains a debugger. I’m not going to say a lot about it here, other than to tell you how to start it and to give you pointers to the documentation. Using the debugger once it has been started is pretty easy. You can inspect variables, single-step the code, set breakpoints, and so on.

Because we’ll often want to debug several processes, the debugger can also spawn copies of itself, so we can have several debug windows, one for each process we are debugging.

The only tricky thing is getting the debugger started.

 
1>​ %% recompile lib_misc so we can debug it
 
1>​ c(lib_misc, [debug_info]).
 
{ok, lib_misc}
 
2>​ im(). %% A window will pop up. Ignore it for now
 
<0.42.0>
 
3>​ ii(lib_misc). ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.