[erlang-questions] dbg:fun2ms and matching any arity?
T Ty
tty.erlang@REDACTED
Thu May 15 12:00:39 CEST 2014
dbg:fun2ms(fun(_X) -> return_trace() end).
might be what you are looking for.
On Thu, May 15, 2014 at 10:18 AM, Roger Lipscombe <roger@REDACTED>wrote:
> 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.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140515/a2e53049/attachment.htm>
More information about the erlang-questions
mailing list