Search code examples
perlperldb

continue command ignores breakpoints


I'm getting errors using CPAN and, as output is rather unhelpful, resorted to debugging this.

$ perl -d /usr/bin/cpan CPAN

Loading DB routines from perl5db.pl version 1.33
<...>
main::(/usr/bin/cpan:2):            eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
main::(/usr/bin/cpan:3):                if $running_under_some_shell;
  DB<1> b /usr/lib/perl5/5.14/HTTP/Tiny.pm:125
  DB<2> L
/usr/bin/cpan:
 2:         eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
   break if (/usr/lib/perl5/5.14/HTTP/Tiny.pm:125)
  DB<2> c

After c, the program runs to completion, ignoring the breakpoint.

/usr/lib/perl5/5.14/HTTP/Tiny.pm:125 is the following line, outside any conditional blocks.

my $request = {
    method    => $method,
    scheme    => $scheme,
    host_port => ($port == $DefaultPort{$scheme} ? $host : "$host:$port"),
    uri       => $path_query,
    headers   => {},
};

Setting a break on line 142 (that's causing errors that I'm debugging) makes no difference.

From the L output, it looks like the breakpoint is set on the current line rather than the one I need. But, perldebug lists b file:line as valid syntax.


Solution

  • That syntax might be a newer addition, I wasn't able to get it working here either. I have 5.8.8 on Unix and 5.10.1 on Windows and both don't seem to work. I get the breakpoint on my current line as you do (it treats the whole string as a condition).

    I'd suggest using another syntax as below.

    Break on the method:

    b HTTP::Tiny::some_method
    

    Select the file, break on the line (it matches on paths, not module namespaces):

    f HTTP/Tiny
    b 125
    

    If they are loaded at runtime with require or eval, the debugger won't know about the module yet so you can just type use HTTP::Tiny in the debugger first to force it to load.