您可能知道,现在可以使用简短形式跟踪Erlang函数:
dbg:tpl(Module, Function, x).
而不是通常的:
dbg:tpl(Module, Function, dbg:fun2ms(fun(_) -> exception_trace() end)).
我实际上想知道return_trace()
是否有类似的简短表格。类似的东西:
dbg:tpl(Module, Function, r).
而不是:
dbg:tpl(Module, Function, dbg:fun2ms(fun(_) -> return_trace() end)).
dbg
模块中的源代码似乎不建议:
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.
但我可能错了。你知道吗?
答案 0 :(得分:5)
不是,但您可以记住saved
结果中的dbg:tpl
号并重复使用它:
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