Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions org.eclipse.jdt.debug.tests/testprograms/StatementStep.java
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";
}

}
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 org.eclipse.jdt.debug.tests/testprograms/StatementStepNested.java
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) {
}
}
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();
TestUtil.waitForJobs(getName(), 100, DEFAULT_TIMEOUT);
}

@Override
protected boolean enableUIEventLoopProcessingInWaiter() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243",
"OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982",
"SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2", "compare.CompareObjectsStringTest", "compare.CompareListObjects",
"compare.CompareMapObjects", "compare.CompareSetObjects", "compare.CompareNormalObjects", "compare.CompareArrayObjects" };
"compare.CompareMapObjects", "compare.CompareSetObjects", "compare.CompareNormalObjects", "compare.CompareArrayObjects",
"StatementStep", "StatementStepArgument", "StatementStepNested" };

/**
* the default timeout
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2025 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -17,6 +17,7 @@

import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.debug.test.stepping.ForceReturnTests;
import org.eclipse.jdt.debug.test.stepping.StatementSteppingTests;
import org.eclipse.jdt.debug.test.stepping.StepFilterTests;
import org.eclipse.jdt.debug.test.stepping.StepIntoSelectionTests;
import org.eclipse.jdt.debug.test.stepping.StepIntoSelectionWithGenerics;
Expand Down Expand Up @@ -251,6 +252,7 @@ public AutomatedSuite() {
if (JavaProjectHelper.isJava6Compatible()) {
addTest(new TestSuite(ForceReturnTests.class));
}
addTest(new TestSuite(StatementSteppingTests.class));

//Classpath tests
addTest(new TestSuite(JavaLibraryPathTests.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2024 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -77,6 +77,8 @@ public class DebugUIMessages extends NLS {
public static String JavaDebugPreferencePage_ShowStepResult_local;
public static String JavaDebugPreferencePage_ShowStepResult_remote;
public static String JavaDebugPreferencePage_ShowStepTimeout_ms_1;

public static String JavaDebugPreferencePage_StatementLevelStepping;
public static String JavaDebugPreferencePage_Communication_1;
public static String JavaDebugPreferencePage_Debugger__timeout__2;
public static String JavaDebugPreferencePage__Launch_timeout__ms___1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ JavaDebugPreferencePage_ShowStepResult_1=Show method result after a step operati
JavaDebugPreferencePage_ShowStepResult_local=Enable for local launc&h types
JavaDebugPreferencePage_ShowStepResult_remote=Enable for remote connections (may be e&ven slower)
JavaDebugPreferencePage_ShowStepTimeout_ms_1=Don't show &if step operation takes longer than (ms):
JavaDebugPreferencePage_StatementLevelStepping=Filter intermediate instructions while stepping
JavaDebugPreferencePage_Communication_1=Communication
JavaDebugPreferencePage_Debugger__timeout__2=Debugger &timeout (ms):
JavaDebugPreferencePage__Launch_timeout__ms___1=&Launch timeout (ms):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2011 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -269,4 +269,9 @@ public interface IJDIPreferencesConstants {
*/
public static final String PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT= IJavaDebugUIConstants.PLUGIN_ID + ".prompt_delete_conditional_breakpoint"; //$NON-NLS-1$

/**
* Boolean preference controlling whether debugger should suspend only for statement-level instructions.
*/
public static final String PREF_STATEMENT_LEVEL_STEPPING = IJavaDebugUIConstants.PLUGIN_ID + ".statement_only_stepping"; //$NON-NLS-1$

}
Loading
Loading