trace and match_spec

Siri Hansen siri@REDACTED
Mon Feb 18 16:30:29 CET 2002


Fredrik Linder wrote:
> ....
> 
> ---[Working, but no return tracing]---
> erlang:trace(Pid1, true, [call, 'receive', return_to]),
> erlang:trace_pattern({'_', '_', '_'}, true, [local]),

The return_to flag will only tell you when you return to(!) a
function, but you will not get any return values. The message you get
is
{trace,Pid,return_to,MFA}
 
> ---[Working, but too much tracing]---
> erlang:trace(Pid1, true, all),
> erlang:trace_pattern({'_', '_', '_'}, true, [local]),

This should be the same as above when it comes to return tracing
 
> ---[Not Working]---
> erlang:trace(Pid1, true, [call, 'receive', return_to]),
> MatchHead = '_',    % Any arguments
> MatchCond = [],    % Always
> MatchBody = [{return, trace}],    % Trace return values (disables tail
> recursion)
> erlang:trace_pattern({Mod, '_', '_'}, [{MatchHead, MatchCond, MatchBody}],
> [local]),
> 
> =ERROR REPORT==== 18-Feb-2002::15:42:17 ===
> Error in process <0.292.0> with exit value:
> {badarg,[{erlang,trace_pattern,[{'_','_','_'},[{'_',[],[{return,trace}]}]]},
> {t,tracer_init,1}]}

If you change {return,trace} to {return_trace} this should work, and
it will give the return values. The message you get is
{trace,Pid,return_from,MFA,ReturnValue}

/siri



More information about the erlang-questions mailing list