Created
March 10, 2010 21:45
-
-
Save archaelus/328457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% @copyright Geoff Cant 2009, 2010 | |
%% @author Geoff Cant <[email protected]> | |
%% @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