#220 : Bug - Inconsistant line step / breakpoint response

rated by 0 users
This post has 4 Replies | 3 Followers

Top 10 Contributor
Posts 333
LFS Posted: Thu, Feb 18 2010 11:10 AM

Given the following program:

 4 Method Main()
 5    Define A As Integer
 6    For A = 1 To 3
 7       Trace("" + A)
 8    Next
 9 End Method

Putting a breakpoint on line 7 will cause the program to go into debug mode for each iteration of the loop. In other words, to get through the program, you have to hit the run button 4 times before the program stops running. That acts as expected. Putting a breakpoint on line 6 however, only breaks into debug mode for the first iteration through the loop. In other words, to get through the program, you have to hit the run button 2 times before the program stops running.

In short, while stepping through the code, the entire loop (lines 6, 7, and 8) gets repeated, but putting a breakpoint on line 6 only gets honored once.

Top 25 Contributor
Posts 204
Megahand replied on Sat, Feb 20 2010 7:56 PM

This also happens with whiles.

1.618033988749894848204586834365
Top 10 Contributor
Posts 688
ZMan replied on Mon, Feb 22 2010 11:36 AM
I agree that seems illogical... even more so for a 'while' loop where the condition is clearly on the 1st line of the loop. I'm also pretty sure that Visual Studio doesn't work this way. I'm going to guess that its the way Phrogram generates the .Net code underneath. Your computer isn't really running Phrogram code. Its running IL (Yes I know its really running x86 but for the purpose of the .Net debugger its not). Each IL statement gets tagged back to the 'original' line of source code so we know when to breakpoint and error etc. So I'm betting the IL for the 'for' line is actually only run once.. and the loop consists of the inner code and the 'next'. I shall investigate and I think the right thing to do is match visual studios behaviour.
Managed DirectX and XNA ? Check out http://www.thezbuffer.com
Top 10 Contributor
Posts 333
LFS replied on Tue, Feb 23 2010 2:26 PM
If that were the case, that the For line is executed only once, shouldn't stepping through the code only hit the for line once? As I indicated, stepping through the code correctly hits all the lines, including the For line, which is why the breakpoint response seems inappropreate.
Top 10 Contributor
Posts 688
ZMan replied on Tue, Feb 23 2010 3:11 PM
Sorry I missed that part of your post... yes it does make it seem even more wrong.. I'll be sure to update it when I find the issue.
Managed DirectX and XNA ? Check out http://www.thezbuffer.com
Page 1 of 1 (5 items) | RSS