•Re^3: No Pause on Elsif in Debugger
by merlyn (Sage) on Jul 23, 2004 at 16:10 UTC
|
| [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.
-QM
--
There are only 11 people in the world. Those who understand unary, and those who don't.
| [reply] |
|
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).
| [reply] |
|
|
|
/me points at "Larry's Head".
| [reply] |
|
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).
| [reply] |
|
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...) | [reply] [d/l] |
|
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.
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] [d/l] |
|
Yes indeed. After more than two or three, it's time to consider a hash and coderefs.
| [reply] |