@@ -44,7 +44,8 @@ groups() ->
4444 {range , [ranges ,
4545 ranges_max_depth ,
4646 range ,
47- ranges_with_messages ]},
47+ ranges_with_messages ,
48+ incomplete_ranges ]},
4849 {traceback , [single_tb ,
4950 single_tb_with_messages ,
5051 tb ,
@@ -243,6 +244,37 @@ ranges_with_messages(_Config) ->
243244 Range1 = [hd (Traces ), lists :last (Traces )],
244245 [Range1 ] = tr :ranges (fun (# tr {}) -> true end , #{max_depth => 1 }).
245246
247+ incomplete_ranges (_Config ) ->
248+ Self = self (),
249+ tr :trace (#{modules => [MFA = {? MODULE , wait_and_reply , 1 }]}),
250+ Pid1 = spawn_link (? MODULE , wait_and_reply , [self ()]),
251+ Pid2 = spawn_link (? MODULE , wait_and_reply , [self ()]),
252+ receive {started , Pid1 } -> ok end ,
253+ receive {started , Pid2 } -> ok end ,
254+ Pid2 ! reply ,
255+ receive {finished , Pid2 } -> ok end ,
256+
257+ % % Pid1 finished, but Pid1 didn't
258+ wait_for_traces (3 ),
259+ tr :stop_tracing (),
260+ Pid1 ! reply ,
261+ receive {finished , Pid1 } -> ok end ,
262+
263+ [# tr {index = 1 , pid = Pid1 , event = call , mfa = MFA , data = [Self ]},
264+ # tr {index = 2 , pid = Pid2 , event = call , mfa = MFA , data = [Self ]},
265+ # tr {index = 3 , pid = Pid2 , event = return , mfa = MFA , data = {finished , Pid2 }}] =
266+ [T1 , T2 , T3 ] = tr :select (),
267+
268+ % % Ranges with missing returns are included at the end
269+ [[T2 , T3 ], [T1 ]] = tr :ranges (fun (# tr {}) -> true end ),
270+ [[T2 , T3 ], [T1 ]] = tr :ranges (fun (# tr {}) -> true end , #{output => all }),
271+
272+ % % Skip ranges with missing returns
273+ [[T2 , T3 ]] = tr :ranges (fun (# tr {}) -> true end , #{output => complete }),
274+
275+ % % Skip ranges with missing returns
276+ [[T1 ]] = tr :ranges (fun (# tr {}) -> true end , #{output => incomplete }).
277+
246278do (_Config ) ->
247279 tr :trace ([{? MODULE , fib , 1 }]),
248280 ? MODULE :fib (2 ),
0 commit comments