1 %%%-------------------------------------------------------------------
3 %%% Author : Mats Cronqvist <etxmacr@cbe2077>
6 %%% Created : 28 Nov 2002 by Mats Cronqvist <etxmacr@cbe2077>
7 %%%-------------------------------------------------------------------
10 -export([go
/0, go
/1]).
13 -define(PID(I
), if integer(I
) -> c:pid(0,127,I
); true
-> pid end).
14 -define(MSG(Tag
, Pid
, MFA
, US
),
15 [{Tag
,{?
PID(Pid
),foo
},MFA
,{0,0,US
}},1,standard_io
]++stat()).
16 -define(FDEVENT(Tag
, US
), put(state
, ?
CB:go(?
MSG(Tag
, pid, 0, US
)))).
17 -define(CEVENT(Tag
, Pid
,F
, US
), put(state
, ?
CB:go(?
MSG(Tag
, Pid
,{m
,F
,0}, US
)))).
18 -define(XEVENT(Tag
, Pid
,X
, US
), put(state
, ?
CB:go(?
MSG(Tag
, Pid
,X
, US
)))).
19 -define(EVENT(Tag
, Pid
, US
), put(state
, ?
CB:go(?
MSG(Tag
, Pid
, info
,US
)))).
20 -define(END
, ?
CB:go([end_of_trace
, 1, standard_io
]++stat())).
29 not_yet_implemented
-> the_end
;
34 io:fwrite("## ~p ######~n", [N
]),
35 catch ets:delete(?MODULE
),
36 ets:new(?MODULE
, [named_table
,public
,ordered_set
]),
41 undefined
-> [initial
, ?MODULE
];
46 case post(Conds
, [])--Conds
of
47 [] -> io:fwrite("ok~n");
48 X
-> io:fwrite("failed~n~p~n~p~n", [Conds
, X
])
51 post([{Pid
,Cs
}|Conds
], O
) ->
52 Ds
= ets:match(?MODULE
,{{{stack
,time},?
PID(Pid
),'$1'},'$2'}),
53 post(Conds
, [{Pid
,do_post(Ds
, [])}|O
]).
54 do_post([], O
) -> lists:reverse(O
);
55 do_post([[Stack
,Time
]|Ds
], O
) ->
56 do_post(Ds
, [{st(Stack
),Time
}|O
]).
57 st(St
) -> [F
||{m
,F
,0}<-St
].
60 ?
CEVENT(in
, 1, f0
, 0),
61 ?
CEVENT(call
, 1, f1
, 3),
62 ?
CEVENT(call
, 1, f2
, 4),
63 ?
CEVENT(return_to
, 1, f1
, 5),
66 post([{1, [{[f0
],3},{[f0
,f1
],3},{[f0
,f1
,f2
],1}]}]);
68 ?
CEVENT(in
, 1, f0
, 0),
69 ?
EVENT(gc_start
, 1, 2),
73 post([{1, [{[f0
],6}]}]);
75 ?
CEVENT(in
, 1, f0
, 0),
76 ?
EVENT(gc_start
, 2, 3),
80 post([{1, [{[f0
],6}]}]);
82 ?
CEVENT(in
, 1, f0
, 0),
84 ?
EVENT(gc_start
, 2, 8),
85 ?
EVENT(gc_end
, 2, 10),
86 ?
CEVENT(in
, 3, f0
, 12),
87 ?
CEVENT(call
, 3, f1
, 14),
90 post([{1, [{[f0
],7}]},
91 {3, [{[f0
],2},{[f0
,f1
],3}]}]);
93 ?
CEVENT(in
, 1, f0
, 0),
94 ?
CEVENT(call
, 1, f1
, 2),
96 ?
EVENT(gc_start
, 2, 5),
99 ?
EVENT(gc_end
, 2, 10),
100 ?
CEVENT(in
, 1, f1
, 12),
101 ?
CEVENT(return_to
, 1, f0
, 14),
104 post([{1, [{[f0
],5},{[f0
,f1
],3}]}]);
106 ?
CEVENT(in
, 1, f0
, 0),
107 ?
EVENT(gc_start
, 2, 5),
110 ?
EVENT(gc_end
, 2, 10),
113 post([{1, [{[f0
],12}]}]);
115 ?
CEVENT(in
, 1, f0
, 0),
120 post([{1, [{[f0
],16}]}]);
122 ?
EVENT(gc_start
, 2, 3),
123 ?
EVENT(gc_end
, 2, 4),
127 ?
EVENT(gc_end
, 2, 4),
132 ?
EVENT(gc_end
, 2, 4),
138 ?
EVENT(gc_end
, 2, 4),
140 ?
CEVENT(in
, 2, f0
, 23),
141 ?
EVENT(gc_start
, 2, 25),
144 post([{2,[{[f0
],2}]}]);
147 ?
EVENT(gc_end
, 2, 4),
149 ?
CEVENT(in
, 3, f0
, 18),
151 ?
CEVENT(in
, 2, f2
, 23),
152 ?
EVENT(gc_start
, 2, 25),
155 post([{3,[{[f0
],3}]},
158 ?
CEVENT(in
, 1, f0
, 0),
162 post([{1, [{[f0
],3}]}]);
164 ?
CEVENT(in
, 1, f0
, 0),
167 post([{1, [{[f0
],6}]}]);
169 ?
CEVENT(in
, 1, f0
, 0),
171 ?
EVENT(gc_start
, 3, 12),
172 ?
EVENT(gc_end
, 3, 14),
173 ?
CEVENT(in
, 2, f2
, 18),
176 post([{1, [{[f0
],6}]},
178 tc(_
) -> not_yet_implemented
.