in reply to how to set a breakpoint by a code reference

I can confirm the problem.

from perldebug

b subname [condition] Set a breakpoint before the first line of the named subroutine. subnam +e may be a variable containing a code reference (in this case conditi +on is not supported).

And you are not the first one noticing it, see this thread from 2008: b $var

IMHO the watch expression you get shown from L looks weird...probably a bug!

I'll try to dig later a little bit into the source code of perl5db.pl trying to better understand what is happening.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: how to set a breakpoint by a code reference
by Matq (Initiate) on Nov 19, 2013 at 01:57 UTC

    Hi LanX,

    Thank you for your quick reply.

    Could you let us know if you make any progress?

    This debug feature of Perl can help me a lot.

    BR

      Hi

      I inspected the code and sorry it's not implemented.

      In b $var $var is interpreted as a condition and the breakpoint is set at the current point in code.

      Thats why you see something like this after listing breakpoints

      DB<105> L 10: }; break if ($var)

      you may wanna check cmd_b() on your own.

      There is even no trace that it was even attempted to be implemented.

      cmd_b_sub() explicitely ignores references.

      Though I can find the anonymous sub in %DB::sub as

       "main::__ANON__[/tmp/tst.pl:10]" => "/tmp/tst.pl:6-10"

      But I can't connect it to the subref.

      ... hmm wait ...

      well DB::CvGV_name($mysubref) seems to fix it main::__ANON__[/tmp/tst.pl:10]

      ok I will try to fix it, but this will result in a patch. (update see--> Re: how to set a breakpoint by a code reference (workaround))

      Cheers Rolf

      ( addicted to the Perl Programming Language)