Home > Erlang探索 > 看multitrace代码学习如何定制自己的dbg信息

看multitrace代码学习如何定制自己的dbg信息

October 27th, 2011

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: 看multitrace代码学习如何定制自己的dbg信息

multitrace是ttb应用带的一个例子,给了个例子让用户来格式化和定制自己的dbg信息。 文档在这里

The module multitrace.erl which can be found in the src directory of the Observer application implements a small tool with three possible trace settings. The trace messages are written to binary files which can be formatted with the function multitrace:format/1/2.

代码太长,我就不贴了,可以点这里查看.

我演示下如何使用:

$ pwd
/home/chuba/otp/lib/observer/src
$ erlc multitrace.erl
$ erl
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:16:16] [rq:16] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.5  (abort with ^G)
1> multitrace:schedule(self()).                
ok
2> erlang:ports().
[#Port<0.1>,#Port<0.49>,#Port<0.406>,#Port<0.415>,
 #Port<0.714>,#Port<0.720>]
3> multitrace:stop().                          
stopped
4> multitrace:format("nonode@nohost-schedule_trace").

Tracing started on node nonode@nohost at 2011-10-27 16:29:40,984702
Flags: [{[<0.47.0>],[running,timestamp]}]


in:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984453
Function : {dbg,req,1}

out:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984528
Function : {io,wait_io_mon_reply,2}

in:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984582
Function : {io,wait_io_mon_reply,2}

out:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984635
Function : {io,wait_io_mon_reply,2}

in:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984662
Function : {io,wait_io_mon_reply,2}

out:
Process  : <0.47.0>
Time     : 2011-10-27 16:29:40,984720
Function : {shell,eval_loop,3}

in:
Process  : <0.47.0>
Time     : 2011-10-27 16:30:32,215798
Function : {shell,eval_loop,3}

out:
Process  : <0.47.0>
Time     : 2011-10-27 16:30:32,216096
Function : {code_server,call,2}

in:
Process  : <0.47.0>
Time     : 2011-10-27 16:30:32,216155
Function : {code_server,call,2}

Total time 'in' for process <0.47.0>: 484 micro seconds
ok
13> 

我们可以在自己的项目里面结合ttb做些调试模块,方便在出现问题的时候定位问题。

祝玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Erlang探索 Tags: ,
Comments are closed.