Using `dbg:tpe` to trace messages received by a process

I’m trying to understand how to use dbg:tpe to trace all messages received by a process, but the documentation is a bit too terse for me to grasp. I want to trace all messages sent to the process named cover_server, but what should the match-spec look like?

dbg:tracer(),
dbg:tpe('receive', ...).
2 Likes

Try using dbg:p(Pid, [r]) instead which will trace all received messages to a specific process or set of processes.

2 Likes

Thanks. Unfortunately I need to filter on specific messages (or some messages will drown out the interesting ones). Trying

  dbg:p(whereis(cover_server), r),
  dbg:tpe('receive', dbg:fun2ms(fun ([_, _, {nodeup, _}]) -> ok;
                                    ([_, _, {'DOWN', _, _, _, _}]) -> ok
                                end)),
2 Likes

You could use nuntius (GitHub - 2Latinos/nuntius: An Erlang/OTP library to mock registered processes) and handle the stuff you want (or do something else): we call it an expectation. It can act as a middleware between the mock and the registered process. Not yet production ready, though, but usable in its current state. Let us know if you feel we could add something to it that maybe fits its purpose.

3 Likes