[erlang-questions] dbg:fun2ms and matching any arity?

Roger Lipscombe roger@REDACTED
Thu May 15 11:18:01 CEST 2014


This answer on StackOverflow --
http://stackoverflow.com/a/1954980/8446 -- gives an example of tracing
return values:

dbg:tpl(M, F, A, [{'_', [], [{return_trace}]}]).

That match spec is scary, so I was looking at dbg:fun2ms:

Here's a single parameter:
14> dbg:fun2ms(fun(['_']) -> return_trace() end).
[{['_'],[],[{return_trace}]}]

Here's two parameters:
15> dbg:fun2ms(fun(['_', '_']) -> return_trace() end).
[{['_','_'],[],[{return_trace}]}]

But when I attempt to match _any_ parameters:

16> dbg:fun2ms(fun('_') -> return_trace() end).
Error: dbg:fun2ms requires fun with single variable or list parameter
{error,transform_error}

Or no parameters:

17> dbg:fun2ms(fun([]) -> return_trace() end).
Error: dbg:fun2ms requires fun with single variable or list parameter
{error,transform_error}

... I get errors.

Is it possible to get dbg:fun2ms to generate the match spec in the SO
answer? Or is there not a 1:1 fidelity between what tracing will
accept and what fun2ms will generate?

Cheers,
Roger.



More information about the erlang-questions mailing list