MedicineMan
MedicineMan

Reputation: 15314

During debugging in Eclipse, is it possible to jump to a line and execute it during debugging?

In Visual Studio, it was possible during debugging sessions to jump to the line selected by the cursor and execute that line. After jumping to that line, you can continue debugging from the line that you've jumped to. Does this feature exist on the Java/Eclipse world?

For example:

foo1();

foo2();

foo3();

return true;

In Visual Studio it is possible to break on foo1(), place the cursor on foo3(), execute foo3() without executing foo2. Furthermore, when the debugger is stopped on "return true", I can place the cursor on foo1, and execute foo1 again. Furthermore, I can continue to execute arbitrary lines of code through these actions.

Upvotes: 16

Views: 23529

Answers (3)

Noumenon
Noumenon

Reputation: 6412

You can jump backwards, to the top of the function, using Eclipse's "drop to frame" feature. Right-click the function at top of the stack.

You can't skip foo2(), but you could possibly edit variables to undo whatever effects it has had.

Upvotes: 1

JB Nizet
JB Nizet

Reputation: 691715

Yes. Put a breakpoint on the line, hit F8, wait for the program to execute until this line, and press F6 to go to the next line, or F5 to step into the current line.

EDIT:

Once the thread is paused in the debugger, you may also select some runnable code, right-click, and choose "Display" (Ctll-Shift-D) or "Execute" (Ctrl-U). You may also use the Display view to type any statement, select it, and execute or display it.

Upvotes: -1

travega
travega

Reputation: 8415

Click on the line you want to run to and press Ctrl+R and it will run to that line instead of putting in tons of break points. Also you can use F8 to run to your next break point or F6 to run to the next line.

Upvotes: 7

Related Questions