<div dir="ltr"><div>I'd like to use sequential tracing and trace out huge number of the functions if trace token is set.<br>so far I came out with 2 solutions:<br><br> --enabling tracing per process using match spec for send event:<br><br> dbg:tracer(),<br> dbg:tp('_',[{'_',[{is_seq_trace}],[{message,{get_seq_token}}]}]),<br> dbg:tpe(send,[{['$1','$2'],[{is_seq_trace}],[<br> {enable_trace,'$1',procs},<br> {enable_trace,'$1',call},<br> {enable_trace,'$1',send}]}]),<br> dbg:tp(<b>some_module,some_func</b>,<br> dbg:fun2ms(fun(_) -> set_seq_token(label,1) end)),<br> dbg:p(<b>PID</b>,[call,send,procs,sos]).%% <b>need to know PID (or parent PID)</b><br> %%%%%%%%%%%%%%%%%%%%%%%%%%%<br> %% after tracing is done %%<br> %%%%%%%%%%%%%%%%%%%%%%%%%%%<br> seq_trace:reset_trace(), dbg:stop_clear(). <br><br> --enabling tracing for all the processes at once:<br><br> dbg:tracer(),<br> seq_trace:set_system_tracer(begin {ok,Pid}=dbg:get_tracer(), Pid end),<br> dbg:tp('_',[{'_',[{is_seq_trace}],[<br> {message,{get_seq_token}},<br> {enable_trace,{self},procs}]}]),<br> dbg:tp(<b>some_module,some_func</b>, <br> dbg:fun2ms(fun(_) -> <br> enable_trace(self(),procs),<br> set_seq_token(send,true),<br> set_seq_token(label,1)<br> end)),<br> dbg:p(<b>all</b>,call).<br> %%%%%%%%%%%%%%%%%%%%%%%%%%%<br> %% after tracing is done %%<br> %%%%%%%%%%%%%%%%%%%%%%%%%%%<br> seq_trace:set_system_tracer(false),<br> seq_trace:reset_trace(),dbg:stop_clear().<br><br>I personally prefer the second solution as I don't need to know the
exact (or parent) PID of the process that initially calls
some_module:some_func(), but I’m afraid to affect the system with too-much tracing.<br><br>from the first look, it seems that first solution is faster as only limited amount of processes traced.<br><br>however as Mats Cronqvist explains in "Taking the printf out of printf Debugging" presentation, Erlang injects function tracing logic as function's first instruction.<br>does it mean that per process enabling of call tracing has no real sense and barely affects the performance?<br><br></div><div>any comments are appreciated.<br><br></div><div></div>P.S.: no, I’m not enabling tracing for all of the modules in the system, but I wish to enable it for ~65 modules that I have in the system, so still a big number.<br></div>