views:

411

answers:

4

Can I move the instruction pointer directly to a line of my choice (within the current method) while debugging a Java program in Eclipse (Galileo)?

It's straightforward to drag the instruction pointer to the desired line within a method in Visual Studio, but I don't see a way to do that in Eclipse (and don't find anything about it in the docs or on google).

A: 

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.

Jonathan Feinberg
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. It will execute intermediate instructions, and it will never reach the line I selected unless the natural program flow was headed there anyhow. In other words, it does not let me set the instruction pointer inside a branch that would not otherwise be reached.
Eric J.
+3  A: 

This is not possible.

If you simply want to execute some code at the current place you can use the Expressions view and enter your code as an expression. The methods called by the expression evaluation will run in the current debugging context.

ankon
The only thing 'sort of' what he is looking for is step filtering http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-usestepfilters.htm
amischiefr
Looks like there's enough agreement (based on the upvotes) that this isn't possible. Thanks for the info.
Eric J.
A: 

I like ankon's answer best, but another option (that will only work for your specific instance -- if that) is to stop at a breakpoint on your if and modify the variable(s) evaluated in the conditional such that it returns false (from the "Variables" view, right click on a variable and click "Change Value...")

violoncello
Thanks for the suggestion. Generally that would be a work-around. In this instance the **if** statement evaluates the result of a function call, so I would have to step in there and alter the return value.
Eric J.
A: 

Sorry, no. Perhaps you can do it with IKVM.net under Visual Studio.

Thorbjørn Ravn Andersen