in reply to bug in the debugger? breakpoints in subroutines ignored if attributes present

I tested in 5.8.7, not 5.8.8, but I saw the same results. I tested a few other things about X::a, but I can't see why the debugger gets confused.

One clue as to what's going on might be in the perl -MO=Deparse output:

package X; sub BEGIN { require strict; do { 'strict'->import }; } use Attribute::Handlers; sub a { use strict 'refs'; print "a\n"; } use attributes ('X', sub { use strict 'refs'; print "a\n"; } , 'ATTR(SCALAR)'); sub b { use strict 'refs'; print "b\n"; } package main; use strict 'refs'; X::a(); X::b();
The use attributes after sub a is interesting. If it reassigned *X::a that could explain weird behaviour, but it doesn't. Interesting!

Adding a call to a routine that prints "caller" info instead of the print statements in a and b shows that the caller info is sane, and matches the expected line numbers.


Mike
  • Comment on Re: bug in the debugger? breakpoints in subroutines ignored if attributes present
  • Download Code

Replies are listed 'Best First'.
Re^2: bug in the debugger? breakpoints in subroutines ignored if attributes present
by dragonchild (Archbishop) on Apr 23, 2007 at 15:21 UTC
    The use attributes line is there for two reasons:
    1. Loads attributes.pm if it isn't loaded.
    2. Regardless of if it was loaded, calls attributes->import( ... ) with the params passed.

    I'm willing to bet that what happens is that the breakpoint is set on the "sub a", but that function isn't executed. Instead, it is replaced by the one declared by attributes. Unfortunately, the attributes heavy lifting code is within the Perl source, so it's a little less accessible to one such as I.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?