erlang dbg - trace calls to all functions by all functions

716 views Asked by At

From Using trace and dbg in Erlang, I'm aware that one can trace calls to specified functions from all functions using

1>dbg:p(all, c).

However, how does one trace calls to all functions from all functions? e.g:

1>dbg:foo().
*ALL Erlang function calls will be traced from here on out. Prepare yourself.*
2>lists:append("abc", "def").
*trace*
1

There are 1 answers

0
Steve Vinoski On BEST ANSWER

Tracing all calls to all functions is not something you want to do, as that would easily swamp your output and make your shell unusable. After all, the shell calls functions to perform its duties too, as does dbg, so you'd end up seeing endless traces of calls to io functions involved in generating and displaying the trace.

Instead, take a look at the various dbg:tp and dbg:tpl functions. Apply them after your call to dbg:p(all, c). They allow you to trace specific modules and specific functions. Start by tracing a particular function or module, and then based on the trace you see, widen your trace to callers of that function. You can also use dbg:ctp and dbg:ctpl to turn off tracing for specific functions or modules once they're no longer relevant to your debugging efforts. With this approach, you can use dbg to iteratively zero in on whatever it is you're looking for.