views:

118

answers:

2

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.

  • Is there a similar possibility to apply pattern matching for functions?

    eg.: {'=/=', '$2', function_name}

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

Thank You!

+1  A: 
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.

Lukas
This definitely is promising!Still not a one liner, but the shortest version I have yet.Problem is if I want to disable tracing on 5 functions, I will have to use dbg:ctpl 5 times...
Dlf
+3  A: 

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.

Adam Lindberg
The final solution was: >>> [dbg:ctp(Mod, F, []) || F <- [dontTrace1,dontTrace2,dontTrace3]]. <<< I used this since I wanted to know immediately if I messed up a functions name.
Dlf
Ah, I've updated the code to actually trace instead of clear. :-)
Adam Lindberg