Avoiding output of huge binary parameters when tracing with dbg

I need to debug some code that bypasses huge binary files in parameters.

To do this, I want to use a combination of dbg:tracer/0, dbg:p/2, dbg:tpl/3.

But if I do this, all binaries are output every time they output in one mess, so important information is hard to find.

Even worse, the output of these binaries spoiled the time of the code. This makes him behave in a completely different way that I cannot reproduce the behavior that I want dbg.

I still want to see other options, but I don't need to see the binaries (shortened binaries will also be fine).

+3
source share
1 answer

, - :

-module(test).

-compile(export_all).

foo(_LongBinary, _OtherParam) ->
    ok.

test() ->
    dbg:tracer(process, {
         fun({trace, Pid, call, {M,F,A}}, _) ->
             NewA = lists:map(fun(<<Reduced:5/binary, _/binary>>) ->
                          Reduced;
                         (Else) ->
                          Else
                      end, A),
             erlang:display({Pid, "->", M, F, NewA});       
            ({trace, Pid, return_from, {M,F,A}, R}, _) ->
             erlang:display({Pid, "<-", M, F, A, R})        
         end, unused}),
    dbg:p(all,c),
    dbg:tpl(test, foo, x).

, dbg:tracer, . - ( . Doc). - ( , ), .

, , .

, - :

1> test:test().                               
{ok,[{matched,nonode@nohost,1},{saved,x}]}
2> test:foo(<<"aa">>,b).                      
ok
3> {<0.45.0>,"->",test,foo,[<<2 bytes>>,b]}
{<0.45.0>,"<-",test,foo,2,ok}
4> test:foo(<<"aaaaaaa">>,b).
ok
5> {<0.45.0>,"->",test,foo,[<<5 bytes>>,b]}
{<0.45.0>,"<-",test,foo,2,ok}
6> test:foo(<<"aaaaaaasdaaaaaaaaa">>,b).
ok
7> {<0.45.0>,"->",test,foo,[<<5 bytes>>,b]}
{<0.45.0>,"<-",test,foo,2,ok}

, . dbg, ( , ).

+3

All Articles