Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoint on outer loop won't stop when using Resume (F5) after breaking once #1407

Open
LeducNic opened this issue Nov 3, 2023 · 7 comments
Assignees

Comments

@LeducNic
Copy link

LeducNic commented Nov 3, 2023

When you put a breakpoint on a outer while loop in a method, the debugger break only once instead of for each loop executed. Also, a loop in a if won't work correctly. But if you have an inner loop (loop in a loop), the breakpoint work as expected, so the debugger break after each execution of the inner loop.

Environment
  • Operating System: Windows 10
  • JDK version: 17.0.8
  • Visual Studio Code version: 1.83.1
  • Java extension version: 1.24.0
  • Java Debugger extension version: 0.55.0
Steps To Reproduce

Using this code:
package sandbox;

public class At09Ex05 {
public static void main(String[] args) {
int nb1, nb2, som1, som2;

	som1 = nb1 = 17;
	som2 = nb2 = 7;
	while (som1 != som2) {
		while (som1 < som2) {
			som1 += nb1;
		}
		while (som2 < som1) {
			som2 += nb2;
		}
	}
	System.out.println("Le PPCM de " + nb1 + " et " + nb2 + " est " + som1);
}

}

  1. Place a breakpoint on line : while (som1 != som2) {
  2. Run the debugger and the program stop at the breakpoint
  3. Use Resume (F5)
Current Result

The program run until the end when using F5 on the outer loop

Expected Result

Since the loop should execute a few times, Resume (F5) should stop again at the breakpoint after executing the loop.

Additional Informations

If you do the same test with a brepoint on the while (som1 < som2) { , the behaviour is correct.
If you change while (som1 != som2) { for if (som1 != som2) { then the two inner loops have the problem.

@testforstephen
Copy link
Contributor

@LeducNic I cannot reproduce it. See the screenshot below:

bug_1407.mp4

@LeducNic
Copy link
Author

Do you use Oracle JDK or OpenJDK?

@LeducNic
Copy link
Author

Hello,

I installed Oracle JDK 17.0.9 on a clean Windows 10 VM with VSCode 1.84.2 (user) and Java Extension Pack. I created a new text file named At09Ex05.java in my home directory and copied the main() as above. I don't use any project manager (like Maven) for my Java code. With only one breackpoint the code doesn't stop after reaching the breackpoint once. After that, I have put three breakpoints and you can see that only the last two breakpoints are working correctly. Can you give me more infos about your configuration?

Thank you very much for your help
Nicolas

Win10-Test-screen.mp4

@testforstephen
Copy link
Contributor

I don't use any project manager (like Maven) for my Java code.

@LeducNic thanks for the information. The screenshot I shared is based on a gradle project, which delegates the build to the javac and the outer loop breakpoint works well.

And then I tried it with a no buildtool folder again, I can reproduce it. The no buildtool project will use the built-in compiler (ECJ) in Java language server to compile java files. Looks like the ECJ result is somehow different with javac. Anyway, I see the final running result is not affected, just the outer loop breakpoint is somehow broken in the ECJ case.

@LeducNic
Copy link
Author

Thanks. Do you know if it is possible to use javac to compile the source when running/debugging with no build tools?

@testforstephen
Copy link
Contributor

Thanks. Do you know if it is possible to use javac to compile the source when running/debugging with no build tools?

This requires a change in the infrastructure to use Javac instead of ECJ, which is a big decision that we need to evaluate more. At the moment we need to investigate this issue further to see if it's a common or corner case.

@LeducNic
Copy link
Author

After some experimentation, I have found that the java assembly code generated for the loops by ECJ and javac are different. The ECJ code won't debug correctly with jdb, but the javac code work fine. Also, even the Eclipse debugger don't work correctly with the loops because the first press on continue won't do anything but after that Eclipse stop after each loop correctly. So maybe ECJ needs to generate code like javac for the loops?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants