tracing

Ulf Wiger <>
Sat Sep 10 00:14:48 CEST 2005


Den 2005-09-09 21:23:26 skrev Serge Aleynikov <>:

> foo_trace(Args) ->
>     dbg:tracer(process, {fun trace_handler/2, []}),
>     dbg:p(self(), call),
>     dbg:tpl(?MODULE, [{'_',[],[{return_trace}]}]),
>     R = foo(Args),
>     dbg:stop(),
>     R.
>  trace_handler(Msg, Acc) ->
>     [Msg | Acc].
>  Is there a way to retrieve the content of this accumulator before  
> calling dbg:stop()?


The only thing I could think of is this:

8> dbg:tracer(process, {fun(Msg,Acc) -> [Msg|Acc] end, [foo]}).
{ok,<0.43.0>}
9> dbg:get_tracer().
{ok,<0.44.0>}
10> pid(0,44,0) ! {self(),stop}.
{<0.30.0>,stop}** dbg got EXIT - terminating: normal

11> flush().
Shell got {stop,[foo]}
ok

That is, if you send the tracer process a {From, stop}
message, it will stop and return the accumulator in
the stop message.

/Uffe
-- 
Ulf Wiger



More information about the erlang-questions mailing list