Getting gen_server/gen_fsm state for debugging

后端 未结 2 825
执笔经年
执笔经年 2021-02-08 01:09

Is it possible to obtain the current state of a gen_server process (presumably by sending some system message)? It could be useful when debugging.

Of cours

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-08 01:29

    Use sys:get_status/1,2 function. It's definition is:

    get_status(Name,Timeout) -> 
        {status, Pid, {module, Mod}, [PDict, SysState, Parent, Dbg, Misc]}
    

    SysState will contain state of the process. It works for all processes using OTP behaviors and other processes implementing proc_lib and sys requirements.

提交回复
热议问题