Skip to content

Instantly share code, notes, and snippets.

@archaelus
Created March 10, 2010 21:45
Show Gist options
  • Save archaelus/328457 to your computer and use it in GitHub Desktop.
Save archaelus/328457 to your computer and use it in GitHub Desktop.
%% @copyright Geoff Cant 2009, 2010
%% @author Geoff Cant <nem@erlang.geek.nz>
%% @version {@vsn}, {@date} {@time}
%% @doc Erlang shell code to trace the messages for one process.
%% @end
dbg:stop_clear(),
f(GL).
GL=group_leader(),
dbg:tracer(process,
{fun (Msg, State) ->
{_,_,Mics} = erlang:now(),
{_,{H, M, Secs}} = calendar:local_time(),
Micros = Mics div 1000,
Seconds = Secs rem 60 + (Micros / 1000),
case Msg of
{trace, Pid, 'receive', TMsg} ->
io:format(GL, "~n~p:~p:~p ~p < ~p~n",
[H, M, Seconds, Pid, TMsg]);
{trace, Pid, 'send', TMsg, ToPid} ->
io:format(GL, "~n~p:~p:~p ~p > ~p: ~p~n",
[H, M, Seconds, Pid, ToPid, TMsg]);
_Else ->
io:format(GL, "~n~p:~p:~p ~p~n",
[H, M, Seconds, Msg])
end,
State
end,
undefined}).
f(Trace).
Trace = fun(Pid) -> dbg:p(Pid, [m]) end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment