Erlang Function Tracing - Short Forms

As you know, you can now track Erlang functions using a short form:

dbg:tpl(Module, Function, x). 

Instead of the usual:

 dbg:tpl(Module, Function, dbg:fun2ms(fun(_) -> exception_trace() end)). 

I'm really wondering if the same short form is available for return_trace() . Sort of:

 dbg:tpl(Module, Function, r). 

Instead:

 dbg:tpl(Module, Function, dbg:fun2ms(fun(_) -> return_trace() end)). 

The source code in the dbg module does not seem to imply:

 new_pattern_table() -> PT = ets:new(dbg_tab, [ordered_set, public]), ets:insert(PT, {x, term_to_binary([{'_',[],[{exception_trace}]}])}), ets:insert(PT, {exception_trace, term_to_binary(x)}), PT. 

But I could be wrong. Do you know anything?

+4
source share
1 answer

Not really, but you can remember the saved number as a result of dbg:tpl and reuse it:

 1> dbg:tracer(). {ok,<0.33.0>} 2> dbg:p(all,c). {ok,[{matched, nonode@nohost ,25}]} 3> dbg:tpl(lists, sort, dbg:fun2ms(fun(_) -> return_trace() end)). {ok,[{matched, nonode@nohost ,2},{saved,1}]} 4> dbg:tpl(lists, sum, 1). {ok,[{matched, nonode@nohost ,2},{saved,1}]} 5> lists:sum([1,2,3]). 6 6> (<0.31.0>) call lists:sum([1,2,3]) (<0.31.0>) call lists:sum([1,2,3],0) (<0.31.0>) call lists:sum([2,3],1) (<0.31.0>) call lists:sum([3],3) (<0.31.0>) call lists:sum([],6) (<0.31.0>) returned from lists:sum/2 -> 6 (<0.31.0>) returned from lists:sum/2 -> 6 (<0.31.0>) returned from lists:sum/2 -> 6 (<0.31.0>) returned from lists:sum/2 -> 6 (<0.31.0>) returned from lists:sum/1 -> 6 
+5
source

Source: https://habr.com/ru/post/1303937/


All Articles