Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: No Pause on Elsif in Debugger

by QM (Parson)
on Jul 23, 2004 at 13:07 UTC ( #376878=note: print w/replies, xml ) Need Help??

in reply to •Re: No Pause on Elsif in Debugger
in thread No Pause on Elsif in Debugger

It "pauses" on the beginning of a statement. elsif is not the beginning of a statement.
Is that DWIM? What behavior do we want?

I expect that it will at least pause on the evaluation of interesting conditionals [elsif (0) being an example of an uninteresting one]

Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
•Re^3: No Pause on Elsif in Debugger
by merlyn (Sage) on Jul 23, 2004 at 16:10 UTC
    It doesn't really matter if that's exactly what you want. It would take a major overhaul (major) of the interface between the execution engine and the debugger Perl code to get it to do anything else. It's a very fundamental design choice. It's just like you can't set a breakpoint to see the "middle" of a map operation, other than at a statement boundary in a called subroutine.

    The debugger gets notified only as each statement is entered. That's it.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Any chance of getting a nice little discussion about this decision, or a point to the design discussion? The historian in me is looking for new material.

      There are only 11 people in the world. Those who understand unary, and those who don't.

        My somewhat wild conjecture is that this is related to how line numbers are reported incorrectly for elsif code (the number of the line of the if is reported instead).

        The broken line numbering is clearly a bug and justifies more effort be marshaled to fix it than the debugger issue.

        Further, I conjecture that both are somewhat affected by the Perl4 optimization where a suitable if/elsif/else chain is converted into an efficient 'switch statement' (computed goto).

        - tye        

        I'm no expert on this but I goaded a few experts on this and in the end I don't think they came up with any good reasons why 'elsif' shouldn't just be declared "a statement" as far as opcode generation is concerned so that run-time line numbers can be correct and the debugger can stop on such lines.

        I expected that this would find its way to p5p and someone would post some evidence of that to this thread. Maybe this goading will make that happen. If not, you might want to escalate to p5p yourself (after first searching the archive to see if it has already been discussed).

        - tye        

Re^3: No Pause on Elsif in Debugger
by pemungkah (Priest) on Sep 26, 2006 at 17:56 UTC
    Of course, the Right Place to put the breakpoints is on the code *inside* the if/elsif/else - "right" being "you will actually stop somewhere near where you want to be". I've noticed similar annoying behavior with for loops at times. Just set your breakpoints inside and the problem goes away. This is the least intrusive solution; obviously, you can code to the debugger's limitations by doing things like
    if ($cond1) { ... } else { if ($cond2) { ... } else { if ($cond3) { .. } } }
    and now you can break at every if. (That looks scarily like some of my old PL/1 programs...)
      I started to say
      If I have a long if/elsif/elsif/... chain, then setting breakpoints inside every block is painful (especially when repeating the same breakpoints while doing the debug/edit loop).
      However, more than 3 is a good indicator I'm doing something wrong, and should rethink my attack.

      Quantum Mechanics: The dreams stuff is made of

        Yes indeed. After more than two or three, it's time to consider a hash and coderefs.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://376878]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-07-18 14:52 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (393 votes). Check out past polls.