[erlang-questions] tracing huge number of functions from EXACT vs ALL processes.

Gonchar Denis <>
Mon Oct 24 16:45:32 CEST 2016


I'd like to use sequential tracing and trace out huge number of the
functions if trace token is set.
so far I came out with 2 solutions:

    --enabling tracing per process using match spec for send event:

        dbg:tracer(),
        dbg:tp('_',[{'_',[{is_seq_trace}],[{message,{get_seq_token}}]}]),
        dbg:tpe(send,[{['$1','$2'],[{is_seq_trace}],[
            {enable_trace,'$1',procs},
            {enable_trace,'$1',call},
            {enable_trace,'$1',send}]}]),
        dbg:tp(*some_module,some_func*,
            dbg:fun2ms(fun(_) -> set_seq_token(label,1) end)),
        dbg:p(*PID*,[call,send,procs,sos]).%% *need to know PID (or parent
PID)*
        %%%%%%%%%%%%%%%%%%%%%%%%%%%
        %% after tracing is done %%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%
        seq_trace:reset_trace(), dbg:stop_clear().

    --enabling tracing for all the processes at once:

        dbg:tracer(),
        seq_trace:set_system_tracer(begin {ok,Pid}=dbg:get_tracer(), Pid
end),
        dbg:tp('_',[{'_',[{is_seq_trace}],[
            {message,{get_seq_token}},
            {enable_trace,{self},procs}]}]),
        dbg:tp(*some_module,some_func*,
            dbg:fun2ms(fun(_) ->
                enable_trace(self(),procs),
                set_seq_token(send,true),
                set_seq_token(label,1)
            end)),
        dbg:p(*all*,call).
        %%%%%%%%%%%%%%%%%%%%%%%%%%%
        %% after tracing is done %%
        %%%%%%%%%%%%%%%%%%%%%%%%%%%
        seq_trace:set_system_tracer(false),
        seq_trace:reset_trace(),dbg:stop_clear().

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.

from the first look, it seems that first solution is faster as only limited
amount of processes traced.

however as Mats Cronqvist explains in "Taking the printf out of printf
Debugging" presentation, Erlang injects function tracing logic as
function's first instruction.
does it mean that per process enabling of call tracing has no real sense
and barely affects the performance?

any comments are appreciated.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161024/57979574/attachment.html>


More information about the erlang-questions mailing list