cdlf
cdlf

Reputation: 763

How to trace for all functions in an Erlang module except for one?

I wanted to trace for all functions in an erlang module, with dbg:tpl, but one of the internal functions took up 95% of the trace file. I then wanted to exclude only that single function and found that it was not as easy as I thought it would be.

I know there are great pattern matching possibilities for arguments when tracing.

I am open for outside-the-box solutions as well!

Thank You!

Upvotes: 3

Views: 659

Answers (2)

Adam Lindberg
Adam Lindberg

Reputation: 16577

It can be achieved as one statement with a list comprehension:

[dbg:tpl(Mod, F, []) || {F, _Ar} <- Mod:module_info(functions), not lists:member(F, DontTrace)].

Where Mod is the module you want to trace on, and DontTrace is a list of functions names that should not be traced on.

Upvotes: 6

Lukas
Lukas

Reputation: 5327

dbg:tpl(mod,[]).
dbg:ctpl(mod,notthisfunction).

Haven't tested this but shouldn't this do the trick? Don't know of a way to do it in one line.

Upvotes: 1

Related Questions