Elixir/Erlang -跟踪邮件何时到达邮箱

jaxagkaj  于 2022-12-16  发布在  Erlang
关注(0)|答案(1)|浏览(123)

一个非常直接的问题是,是否可以跟踪到达Process/GenServer(邮箱)的消息?注意,这与跟踪received(一旦消息离开邮箱并被处理)的消息是不同的。直到现在,我还没有找到这样做的方法。

mum43rcc

mum43rcc1#

在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}

相关问题