看multitrace代码学习如何定制自己的dbg信息
multitrace是ttb应用带的一个例子,给了个例子让用户来格式化和定制自己的dbg信息。 文档在这里:
The module multitrace.erl which can be found in the src directory of the Ob** 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
002
003
/home/chuba/otp/lib/ob**/src
004
005
$ erlc multitrace.erl
006
007
$ erl
008
009
Erlang R14B04 (erts-5.8.5) 1
010
011
012
013
Eshell V5.8.5 (abort with ^G)
014
015
1> multitrace:schedule(self()).
016
017
ok
018
019
2> erlang:ports().
020
021
024
025
3> multitrace:stop().
026
027
stopped
028
029
4> multitrace:format("nonode@nohost-schedule_trace").
030
031
032
033
Tracing started on node nonode@nohost at 2011-10-27 16:29:40,984702
034
035
Flags: [{,}]
036
037
038
039
040
041
in:
042
043
Process : <0.47.0>
044
045
Time : 2011-10-27 16:29:40,984453
046
047
Function : {dbg,req,1}
048
049
050
051
out:
052
053
Process : <0.47.0>
054
055
Time : 2011-10-27 16:29:40,984528
056
057
Function : {io,wait_io_mon_reply,2}
058
059
060
061
in:
062
063
Process : <0.47.0>
064
065
Time : 2011-10-27 16:29:40,984582
066
067
Function : {io,wait_io_mon_reply,2}
068
069
070
071
out:
072
073
Process : <0.47.0>
074
075
Time : 2011-10-27 16:29:40,984635
076
077
Function : {io,wait_io_mon_reply,2}
078
079
080
081
in:
082
083
Process : <0.47.0>
084
085
Time : 2011-10-27 16:29:40,984662
086
087
Function : {io,wait_io_mon_reply,2}
088
089
090
091
out:
092
093
Process : <0.47.0>
094
095
Time : 2011-10-27 16:29:40,984720
096
097
Function : {shell,eval_loop,3}
098
099
100
101
in:
102
103
Process : <0.47.0>
104
105
Time : 2011-10-27 16:30:32,215798
106
107
Function : {shell,eval_loop,3}
108
109
110
111
out:
112
113
Process : <0.47.0>
114
115
Time : 2011-10-27 16:30:32,216096
116
117
Function : {code_**,call,2}
118
119
120
121
in:
122
123
Process : <0.47.0>
124
125
Time : 2011-10-27 16:30:32,216155
126
127
Function : {code_**,call,2}
128
129
130
131
Total time 'in' for process <0.47.0>: 484 micro seconds
132
133
ok
134
135
13>
我们可以在自己的项目里面结合ttb做些调试模块,方便在出现问题的时候定位问题。
祝玩得开心!
The module multitrace.erl which can be found in the src directory of the Ob** 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
002
003
/home/chuba/otp/lib/ob**/src
004
005
$ erlc multitrace.erl
006
007
$ erl
008
009
Erlang R14B04 (erts-5.8.5) 1
010
011
012
013
Eshell V5.8.5 (abort with ^G)
014
015
1> multitrace:schedule(self()).
016
017
ok
018
019
2> erlang:ports().
020
021
024
025
3> multitrace:stop().
026
027
stopped
028
029
4> multitrace:format("nonode@nohost-schedule_trace").
030
031
032
033
Tracing started on node nonode@nohost at 2011-10-27 16:29:40,984702
034
035
Flags: [{,}]
036
037
038
039
040
041
in:
042
043
Process : <0.47.0>
044
045
Time : 2011-10-27 16:29:40,984453
046
047
Function : {dbg,req,1}
048
049
050
051
out:
052
053
Process : <0.47.0>
054
055
Time : 2011-10-27 16:29:40,984528
056
057
Function : {io,wait_io_mon_reply,2}
058
059
060
061
in:
062
063
Process : <0.47.0>
064
065
Time : 2011-10-27 16:29:40,984582
066
067
Function : {io,wait_io_mon_reply,2}
068
069
070
071
out:
072
073
Process : <0.47.0>
074
075
Time : 2011-10-27 16:29:40,984635
076
077
Function : {io,wait_io_mon_reply,2}
078
079
080
081
in:
082
083
Process : <0.47.0>
084
085
Time : 2011-10-27 16:29:40,984662
086
087
Function : {io,wait_io_mon_reply,2}
088
089
090
091
out:
092
093
Process : <0.47.0>
094
095
Time : 2011-10-27 16:29:40,984720
096
097
Function : {shell,eval_loop,3}
098
099
100
101
in:
102
103
Process : <0.47.0>
104
105
Time : 2011-10-27 16:30:32,215798
106
107
Function : {shell,eval_loop,3}
108
109
110
111
out:
112
113
Process : <0.47.0>
114
115
Time : 2011-10-27 16:30:32,216096
116
117
Function : {code_**,call,2}
118
119
120
121
in:
122
123
Process : <0.47.0>
124
125
Time : 2011-10-27 16:30:32,216155
126
127
Function : {code_**,call,2}
128
129
130
131
Total time 'in' for process <0.47.0>: 484 micro seconds
132
133
ok
134
135
13>
我们可以在自己的项目里面结合ttb做些调试模块,方便在出现问题的时候定位问题。
祝玩得开心!
没有找到相关结果
已邀请:
0 个回复