jkahrman has asked for the wisdom of the Perl Monks concerning the following question:

Reported as RT 130361

The perl debugger is not stopping at postponed breakpoints in a perl 5.20.2 that we've built from source on CPAN.

I'm not sure where to begin debugging the issue. I've examined the perldoc for perldebug and perldebguts, and grepped through the perldelta's in our build and haven't found anything (though I barely understand a lot of perldebguts).

It was suggested to me via "Chatterbox" that 1163165 is related, but I don't follow how.

% < perl5.20.2 > -dwe0 main::(-e:1): 0 DB<1> b File::Temp->new Subroutine File::Temp not found. DB<2> b postpone File::Temp::new DB<3> use File::Temp DB<4> x File::Temp->new 0 File::Temp=GLOB(0x283db48) -> *File::Temp::$fh FileHandle({*File::Temp::$fh}) => fileno(3)
UNEXPECTEDLY did not stop at File::Temp::new
DB<5> b postpone File::Temp::new DB<6> x File::Temp->new 0 File::Temp=GLOB(0x216aa78) -> *File::Temp::$fh FileHandle({*File::Temp::$fh}) => fileno(3)
UNEXPECTEDLY did not stop at File::Temp::new
DB<7> B * Deleting all breakpoints... DB<8> b postpone File::Temp::new DB<9> x File::Temp->new 0 File::Temp=GLOB(0x216abc8) -> *File::Temp::$fh FileHandle({*File::Temp::$fh}) => fileno(3)
UNEXPECTEDLY did not stop at File::Temp::new
DB<10> b File::Temp::new DB<11> x File::Temp->new File::Temp::new(/.../lib/5.20.2/File/Temp.pm:885): 885: my $proto = shift; DB<<12>> c 0 File::Temp=GLOB(0x216aeb0) -> *File::Temp::$fh FileHandle({*File::Temp::$fh}) => fileno(3)
STOPPED at File::Temp::new as EXPECTED

Update

I'm not sure why it didn't occur to me before, but we have local perl installations (that we don't use) that come with our Linux machines. The local install of perl 5.20.2 has the same issue. I'm going to report this as a bug.

Update 2

Reported as https://rt.perl.org/Ticket/Display.html?id=130361

Replies are listed 'Best First'.
Re: debugger is not stopping at postponed breakpoints (Signatures and PERL5DB)
by LanX (Saint) on Nov 19, 2016 at 13:16 UTC
    I have no possibility to test, but I suspect it's related to new features like function signatures.

    In a compilation phase they are rewriting the first lines of a functions body.*

    Probably your postponed breakpoint happens earlier and points to a line which disappears then.

    > I'm not sure where to begin debugging the issue

    Otherwise in order to narrow down the cause, you can easily test if it's a problem in the debugger's code.

    Perl evaluates (if present) at start up an environment variable pointing to the debugger script to use, normally named perl5db.pl .

    It should be possible to run a newer Perl version with an older perl5db.pl, and vice versa.

    IIRC the variable is named PERLDB. (to be updated)

    HTH! :)

    edit

    from perlrun#ENVIRONMENT

    • PERL5DB

      The command used to load the debugger code. The default is:

      BEGIN { require "perl5db.pl" }

      The PERL5DB environment variable is only used when Perl is started with a bare -d switch.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    footnotes

    *) See http://www.effectiveperlprogramming.com/2015/04/use-v5-20-subroutine-signatures/ she Brian is using B::Deparse to analyze the generated code.

      File::Temp->new doesn't use 'signatures' and hasn't been modified since 2013. Were you suggesting that it (or a new feature like it) may be loaded when starting the debugger? Or that the debugger has been broken in the process of adding the feature.

      Thanks for the suggestion about focusing on debugging perl5db.pl. I'll have to explore that more.
        This post was by me. I forgot to login.
Re: debugger is not stopping at postponed breakpoints
by stevieb (Canon) on Nov 19, 2016 at 03:06 UTC

    For those of us who set breakpoints within the code then run it under the debugger, can you please explain how the breakpoints are being set?

      b postpone subname [condition] Set breakpoint at first line of subroutine after it is compiled.

        Cheers. Somehow I didn't grab immediately what was happening. I do now :)

Re: debugger is not stopping at postponed breakpoints
by 5haun (Scribe) on Mar 10, 2017 at 20:54 UTC
    I stumbled into this one today on Perl 5.22.1. The issue with this defect is 'b postpone' is the only way I'm aware of setting a breakpoint before a required module is loaded (in the case of code which uses runtime loading of module via Module::Load::load()). Anyone have any workarounds?

    update: the quickest workaround really isn't one, but it works - if one can continue to just after where the module(s) are loaded, then one can set a normal breakpoint. I'm still going to have engineers who whine about having to enter one more command though until this gets fixed and backported to 5.22. :-/