-
Notifications
You must be signed in to change notification settings - Fork 62
Add support for statement-level Stepping #894
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
org.eclipse.jdt.debug.tests/testprograms/StatementStep.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 IBM Corporation. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| public class StatementStep { | ||
|
|
||
| public static void main(String[] args) { | ||
| String s = ";;"; | ||
| String s2 = ";;"; | ||
| String s3 = ";;"; | ||
| String s4 = ";;"; | ||
| String s5 = ";;"; | ||
| tet( | ||
| 1.0f, | ||
| s2, | ||
| s3, | ||
| tet2(s4,s4), | ||
| s5); | ||
| s2 = s + s2; | ||
| s2 = s + s2; | ||
| } | ||
|
|
||
| public static String tet(float s, String s2,String s3,String s4,String s5) { | ||
| return "sou"; | ||
| } | ||
| public static String tet2(String s, String s2) { | ||
| return "sous"; | ||
| } | ||
|
|
||
| } |
38 changes: 38 additions & 0 deletions
38
org.eclipse.jdt.debug.tests/testprograms/StatementStepArgument.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 IBM Corporation. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| public class StatementStepArgument { | ||
|
|
||
| public static void method1(String firstName, String lastName) | ||
| { | ||
| System.out.println("Method1 " + | ||
| " : first name: " + firstName + | ||
| " : last name: " + lastName); | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
| String firstName = "John"; | ||
| String lastName = "Smith"; | ||
|
|
||
| lastName = "Smith"; | ||
|
|
||
| method1(firstName, | ||
| lastName | ||
| ); | ||
|
|
||
| System.out.println("End call method1"); | ||
|
|
||
| } /* main( args ) */ | ||
|
|
||
| } /* TestApp */ |
47 changes: 47 additions & 0 deletions
47
org.eclipse.jdt.debug.tests/testprograms/StatementStepNested.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 IBM Corporation. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| public class StatementStepNested { | ||
|
|
||
| public static void main(String[] args) { | ||
| String s1 = "A"; | ||
| String s2 = "B"; | ||
| String s3 = "C"; | ||
| String s4 = "D"; | ||
|
|
||
| test( | ||
| s1, | ||
| helper1( | ||
| s2, | ||
| helper1(s3, | ||
| helper1(s2, | ||
| s3) | ||
| ) | ||
| ), | ||
| s4 | ||
| ); | ||
|
|
||
| System.out.println("Sou"); | ||
| } | ||
|
|
||
| static String helper1(String a, String b) { | ||
| return a + b; | ||
| } | ||
|
|
||
| static String helper2(String a) { | ||
| return a; | ||
| } | ||
|
|
||
| static void test(String a, String b, String c) { | ||
| } | ||
| } |
186 changes: 186 additions & 0 deletions
186
...pse.jdt.debug.tests/tests/org/eclipse/jdt/debug/test/stepping/StatementSteppingTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 IBM Corporation. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.jdt.debug.test.stepping; | ||
|
|
||
| import org.eclipse.core.runtime.ISafeRunnable; | ||
| import org.eclipse.debug.core.DebugEvent; | ||
| import org.eclipse.debug.core.model.ILineBreakpoint; | ||
| import org.eclipse.jdt.debug.core.IJavaDebugTarget; | ||
| import org.eclipse.jdt.debug.core.IJavaStackFrame; | ||
| import org.eclipse.jdt.debug.core.IJavaThread; | ||
| import org.eclipse.jdt.debug.testplugin.DebugElementKindEventWaiter; | ||
| import org.eclipse.jdt.debug.testplugin.DebugEventWaiter; | ||
| import org.eclipse.jdt.debug.tests.AbstractDebugTest; | ||
| import org.eclipse.jdt.debug.tests.TestUtil; | ||
| import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants; | ||
| import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; | ||
| import org.eclipse.jface.preference.IPreferenceStore; | ||
|
|
||
| public class StatementSteppingTests extends AbstractDebugTest { | ||
|
|
||
| private boolean originalPreferenceValue; | ||
|
|
||
| public StatementSteppingTests(String name) { | ||
| super(name); | ||
| } | ||
|
|
||
| @Override | ||
| protected void setUp() throws Exception { | ||
| super.setUp(); | ||
| originalPreferenceValue = getPrefStore().getBoolean(IJDIPreferencesConstants.PREF_STATEMENT_LEVEL_STEPPING); | ||
| if (!originalPreferenceValue) { | ||
| getPrefStore().setValue(IJDIPreferencesConstants.PREF_STATEMENT_LEVEL_STEPPING, true); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void tearDown() throws Exception { | ||
| if (originalPreferenceValue != getPrefStore().getBoolean(IJDIPreferencesConstants.PREF_STATEMENT_LEVEL_STEPPING)) { | ||
| getPrefStore().setValue(IJDIPreferencesConstants.PREF_STATEMENT_LEVEL_STEPPING, originalPreferenceValue); | ||
| } | ||
| super.tearDown(); | ||
| } | ||
|
|
||
| /** | ||
| * Tests a step over with lots of arguments | ||
| */ | ||
| public void testLotsOfMultilineArguments() throws Exception { | ||
|
|
||
| String typeName = "StatementStep"; | ||
| ILineBreakpoint bp = createLineBreakpoint(21, typeName); | ||
| IJavaDebugTarget javaDebugTarget = null; | ||
| IJavaThread t = null; | ||
| boolean originalStepFilter = false; | ||
| try { | ||
| IJavaThread thread = launchToLineBreakpoint(typeName, bp, true); | ||
| t = thread; | ||
| IJavaStackFrame stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| javaDebugTarget = (IJavaDebugTarget) stackFrame.getDebugTarget(); | ||
| originalStepFilter = javaDebugTarget.isStepFiltersEnabled(); | ||
|
|
||
| javaDebugTarget.setStepFiltersEnabled(true); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 26, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepInto()); | ||
|
|
||
| stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| assertEquals("Suspended at wrong line", 36, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepReturn()); | ||
|
|
||
| stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| assertEquals("Suspended at wrong line", 22, stackFrame.getLineNumber()); | ||
|
|
||
| thread.stepOver(); | ||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
|
|
||
| assertEquals("Suspended at wrong line", 28, stackFrame.getLineNumber()); | ||
| } finally { | ||
| terminateAndRemove(t); | ||
| removeAllBreakpoints(); | ||
| javaDebugTarget.setStepFiltersEnabled(originalStepFilter); | ||
| } | ||
| } | ||
|
|
||
| public void testStepOverWithSingleMultilineArgument() throws Exception { | ||
|
|
||
| String typeName = "StatementStepArgument"; | ||
| ILineBreakpoint bp = createLineBreakpoint(28, typeName); | ||
| IJavaDebugTarget javaDebugTarget = null; | ||
| IJavaThread t = null; | ||
| boolean originalStepFilter = false; | ||
| try { | ||
| IJavaThread thread = launchToLineBreakpoint(typeName, bp, true); | ||
| t = thread; | ||
| IJavaStackFrame stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| javaDebugTarget = (IJavaDebugTarget) stackFrame.getDebugTarget(); | ||
| originalStepFilter = javaDebugTarget.isStepFiltersEnabled(); | ||
|
|
||
| javaDebugTarget.setStepFiltersEnabled(true); | ||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 30, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 34, stackFrame.getLineNumber()); | ||
|
|
||
| } finally { | ||
| terminateAndRemove(t); | ||
| removeAllBreakpoints(); | ||
| javaDebugTarget.setStepFiltersEnabled(originalStepFilter); | ||
| } | ||
| } | ||
|
|
||
| public void testStepOverWithNestedMultiLineArgs() throws Exception { | ||
|
|
||
| String typeName = "StatementStepNested"; | ||
| ILineBreakpoint bp = createLineBreakpoint(20, typeName); | ||
| IJavaDebugTarget javaDebugTarget = null; | ||
| IJavaThread t = null; | ||
| boolean originalStepFilter = false; | ||
| try { | ||
| IJavaThread thread = launchToLineBreakpoint(typeName, bp, true); | ||
| t = thread; | ||
| IJavaStackFrame stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| javaDebugTarget = (IJavaDebugTarget) stackFrame.getDebugTarget(); | ||
| originalStepFilter = javaDebugTarget.isStepFiltersEnabled(); | ||
|
|
||
| javaDebugTarget.setStepFiltersEnabled(true); | ||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 27, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepInto()); | ||
| stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| assertEquals("Suspended at wrong line", 38, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepReturn()); | ||
| stackFrame = (IJavaStackFrame) thread.getTopStackFrame(); | ||
| assertEquals("Suspended at wrong line", 26, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 24, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 22, stackFrame.getLineNumber()); | ||
|
|
||
| runAndWaitForSuspendEvent(() -> thread.stepOver()); | ||
| assertEquals("Suspended at wrong line", 34, stackFrame.getLineNumber()); | ||
|
|
||
| } finally { | ||
| terminateAndRemove(t); | ||
| removeAllBreakpoints(); | ||
| javaDebugTarget.setStepFiltersEnabled(originalStepFilter); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns the <code>JDIDebugUIPlugin</code> preference store | ||
| */ | ||
| protected IPreferenceStore getPrefStore() { | ||
| return JDIDebugUIPlugin.getDefault().getPreferenceStore(); | ||
| } | ||
|
|
||
| private void runAndWaitForSuspendEvent(ISafeRunnable runnable) throws Exception { | ||
| DebugEventWaiter waiter = new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class); | ||
| runnable.run(); | ||
| waiter.waitForEvent(); | ||
iloveeclipse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| TestUtil.waitForJobs(getName(), 100, DEFAULT_TIMEOUT); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean enableUIEventLoopProcessingInWaiter() { | ||
| return true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.