Elixir/Erlang - 跟踪邮件何时到达邮箱
Elixir/Erlang - Trace when a message arrives in the mailbox
相当直接的问题,是否可以跟踪到达 Process
/GenServer
(的邮箱)的邮件?请注意,这不同于当邮件为 received
时的跟踪(一旦它离开邮箱并被处理)。直到现在我还没有找到这样做的方法。
在 erlang 中,您在 dbg:p/2 中有它的标志,s
用于发送,r
用于接收:
1> dbg:tracer().
{ok,<0.82.0>}
2> dbg:p(self(), r).
(<0.80.0>) << {dbg,{ok,[{matched,nonode@nohost,1}]}}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.183997>,319}
{ok,[{matched,nonode@nohost,1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184000>,
[{expand_fun,#Fun<group.0.82824323>},
{echo,true},
{binary,false},
{encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184002>,ok}
3> self() ! trace_me.
(<0.80.0>) << {shell_cmd,<0.73.0>,
{eval,[{op,{1,8},
'!',
{call,{1,1},{atom,{1,1},self},[]},
{atom,{1,10},trace_me}}]},
cmd}
(<0.80.0>) << trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184006>,319}
trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184008>,
[{expand_fun,#Fun<group.0.82824323>},
{echo,true},
{binary,false},
{encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184011>,ok}
相当直接的问题,是否可以跟踪到达 Process
/GenServer
(的邮箱)的邮件?请注意,这不同于当邮件为 received
时的跟踪(一旦它离开邮箱并被处理)。直到现在我还没有找到这样做的方法。
在 erlang 中,您在 dbg:p/2 中有它的标志,s
用于发送,r
用于接收:
1> dbg:tracer().
{ok,<0.82.0>}
2> dbg:p(self(), r).
(<0.80.0>) << {dbg,{ok,[{matched,nonode@nohost,1}]}}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.183997>,319}
{ok,[{matched,nonode@nohost,1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184000>,
[{expand_fun,#Fun<group.0.82824323>},
{echo,true},
{binary,false},
{encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184002>,ok}
3> self() ! trace_me.
(<0.80.0>) << {shell_cmd,<0.73.0>,
{eval,[{op,{1,8},
'!',
{call,{1,1},{atom,{1,1},self},[]},
{atom,{1,10},trace_me}}]},
cmd}
(<0.80.0>) << trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184006>,319}
trace_me
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184008>,
[{expand_fun,#Fun<group.0.82824323>},
{echo,true},
{binary,false},
{encoding,latin1}]}
(<0.80.0>) << {io_reply,#Ref<0.2586582558.1779957764.184011>,ok}