Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 515
MedicineMan Avatar asked Jan 16 '12 23:01

MedicineMan


People also ask

How do you go to the next line in debug mode?

A solution to this is to place the cursor into the next line and hit Ctrl+R ( Run to Line ) but this is not quite as comfortable as simply hitting a button (like hitting F6 for stepping over the line).

Can we go back while debugging in Eclipse?

Yes, Eclipse CDT has support of historical debugger feature. Open Debug Configuration -> Debugger -> Enable Reverse Debugging at startup . Than you can press shift+F5 or shift+F6 for step back like F5 or F6 for step forward.

How do I complete debugging in Eclipse?

To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.


2 Answers

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.

like image 165
travega Avatar answered Sep 27 '22 21:09

travega


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.

like image 42
JB Nizet Avatar answered Sep 27 '22 22:09

JB Nizet