Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the current line of execution in the eclipse java debugger?

I want to force the current execution line to a specific line in the same function, possibly skipping intermediate lines. All my old school debuggers had this feature, but I can't find it in eclipse. Is there a way to do it without changing code?

like image 770
stu Avatar asked Oct 10 '08 13:10

stu


People also ask

How do I set Debug level in Eclipse?

Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application. In most cases, users can edit and save the code while debugging without restarting the program.

What is line breakpoint in Eclipse?

Line Breakpoint: This is the most familiar of the breakpoint types, which halts execution when a specified line in the source code is encountered during program execution. To set a line breakpoint in Eclipse, double-click in the margin to the left of the line where you want the breakpoint to be placed.

How do I move the Debug pointer in Eclipse?

Put the cursor on the line of your choice and either hit ctrl-R ("Run to line") or right-click and select "Run to line" from the context menu. That doesn't move the instruction pointer to a line of my choosing, it sets a temporary breakpoint at that line and just starts running again.

What is Eclipse run to line?

Feature Focus: Run to lineThis function allows you to traverse large blocks of code without the need to set new breakpoints or step through all of the code. This feature resumes the execution of code until this point or another breakpoint is reached.


2 Answers

I too have long sought this feature, and "Run to line" is not the same thing.

This may well be a limitation of the JVM. Java does not implement goto, though it does have jump statements, like break and continue. Those are at the block level however. If this is a JVM limitation, my guess is that it is more likely due to the security architecture. Tight control of the program counter is debilitating for interlopers, like viruses -- and sadly debuggers.

like image 30
Chris Noe Avatar answered Sep 27 '22 20:09

Chris Noe


The first two answers seem to miss the topic, unless it is me not understanding the question.

My understanding, a feature I searched myself, is that you want to skip a number of lines (when stepping in code) and set the program counter (to take assembly vocabulary) to the given line. It might be interesting to skip some costly object creation, see some error situations, etc. I used to do that in Visual Studio (C or C++ code).

I haven't found that in Eclipse, nor in NetBean. It might be a limitation of JVM, or an enforcement of some policy...

The Run to line command execute, of course, all lines between the current execution position and the designated one.

like image 83
PhiLho Avatar answered Sep 27 '22 19:09

PhiLho