开发者

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

开发者 https://www.devze.com 2022-12-30 18:15 出处:网络
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 tha

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开发者_Go百科 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消