massemanet / eper

Erlang performance and debugging tools
MIT License
437 stars 128 forks source link

How to specify binary to match in start spec? #25

Closed maximvl closed 10 years ago

maximvl commented 10 years ago

I'm trying to debug cowboy requests, and watch particular header values, but what i get is

> redbug:start("cowboy_req:header(<<\"origin\">>, _) -> return").
{bad_type,{bin,[{bin_element,1,
                             {string,1,"origin"},
                             default,default}]}}

> redbug:start("cowboy_req:header(<<\\\"origin\\\">>, _) -> return").
{{badmatch,{more,{erl_scan_continuation,[],no_col,
                                        [{'\\',1},
                                         {'<<',1},
                                         {'(',1},
                                         {atom,1,header},
                                         {':',1},
                                         {atom,1,cowboy_req}],
                                        1,
                                        {erl_scan,#Fun<erl_scan.3.23802282>,false,false,false},
                                        {" . )_ ,>>\"nigiro"," . )_ ,>>\"\\nigiro",1,no_col},
                                        #Fun<erl_scan.29.23802282>}}},
 {parse_body,"cowboy_req:header(<<\\\"origin\\\">>, _) -> return"},
 [{redbug_msc,'-body_fun/1-fun-0-',1,
              [{file,"src/redbug_msc.erl"},{line,168}]},
  {redbug_msc,assert,2,
              [{file,"src/redbug_msc.erl"},{line,237}]},
  {redbug_msc,parse,1,
              [{file,"src/redbug_msc.erl"},{line,142}]},
  {redbug_msc,transform,1,
              [{file,"src/redbug_msc.erl"},{line,18}]},
  {redbug,chk_trc,2,[{file,"src/redbug.erl"},{line,518}]},
  {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
  {redbug,pack,1,[{file,"src/redbug.erl"},{line,469}]},
  {redbug,do_start,1,[{file,"src/redbug.erl"},{line,317}]}]}

I found no examples with binaries or strings in documentation. so how can I make spec with them?

ingsoc commented 10 years ago

I am also having problems with binaries in RTP trace patterns

massemanet commented 10 years ago

This is a flaw in the redbug match spec compiler. I will definitely fix this. Unfortunately, the OTP documentation is a bit vague on binaries in match specs :<

massemanet commented 10 years ago

for the brave, a quick hack to address this can be found in the "binaries_in_rtp" branch.

On Mon, Jul 7, 2014 at 9:43 AM, Maxim V notifications@github.com wrote:

I'm trying to debug cowboy requests, and watch particular header values, but what i get is

redbug:start("cowboyreq:header(<<\"origin\">>, ) -> return"). {bad_type,{bin,[{bin_element,1, {string,1,"origin"}, default,default}]}}

redbug:start("cowboyreq:header(<<\"origin\">>, ) -> return"). {{badmatch,{more,{erl_scan_continuation,[],no_col, [{'\',1}, {'<<',1}, {'(',1}, {atom,1,header}, {':',1}, {atom,1,cowboy_req}], 1, {erl_scan,#Fun,false,false,false}, {" . ) ,>>\"nigiro"," . ) ,>>\"\nigiro",1,no_col},

Fun}}},

{parse_body,"cowboyreq:header(<<\"origin\">>, ) -> return"}, [{redbug_msc,'-body_fun/1-fun-0-',1, [{file,"src/redbug_msc.erl"},{line,168}]}, {redbug_msc,assert,2, [{file,"src/redbug_msc.erl"},{line,237}]}, {redbug_msc,parse,1, [{file,"src/redbug_msc.erl"},{line,142}]}, {redbug_msc,transform,1, [{file,"src/redbug_msc.erl"},{line,18}]}, {redbug,chk_trc,2,[{file,"src/redbug.erl"},{line,518}]}, {lists,foldl,3,[{file,"lists.erl"},{line,1261}]}, {redbug,pack,1,[{file,"src/redbug.erl"},{line,469}]}, {redbug,do_start,1,[{file,"src/redbug.erl"},{line,317}]}]}

I found no examples with binaries or strings in documentation. so how can I make spec with them?

— Reply to this email directly or view it on GitHub https://github.com/massemanet/eper/issues/25.

massemanet commented 10 years ago

fixed in 0.86.0

ingsoc commented 10 years ago

Seems to work now, thanks !