Bug 499500 - "Step Into" should also show value of "last returned
method"
Change-Id: I0a07dbee2811ce2d0748a767342b0f87866bce03
Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
diff --git a/org.eclipse.jdt.debug.tests/testprograms/StepResult3.java b/org.eclipse.jdt.debug.tests/testprograms/StepResult3.java
index 917bb48..9b31bf5 100644
--- a/org.eclipse.jdt.debug.tests/testprograms/StepResult3.java
+++ b/org.eclipse.jdt.debug.tests/testprograms/StepResult3.java
@@ -28,7 +28,7 @@
});
p.get();
h();
- g(0);
+ g(0); // bp8
String x = g(1);
return x;
}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/test/stepping/StepResultTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/test/stepping/StepResultTests.java
index edaf907..da83866 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/test/stepping/StepResultTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/test/stepping/StepResultTests.java
@@ -400,4 +400,74 @@
}
}
+ public void testStepInto() throws Exception {
+ String typeName = "StepResult3";
+ ILineBreakpoint bp8 = createLineBreakpoint(31, "StepResult3");
+ bp8.setEnabled(true);
+
+ IJavaThread thread = null;
+ try {
+ thread = launchToLineBreakpoint(typeName, bp8, false);
+ IJavaStackFrame stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("f", stackFrame.getMethodName());
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("g", stackFrame.getMethodName());
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("g", stackFrame.getMethodName());
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("f", stackFrame.getMethodName());
+ assertEquals("g() returned", stackFrame.getVariables()[0].getName());
+ assertEquals("\"XXX\"", stackFrame.getVariables()[0].getValue().toString());
+
+ stepInto(stackFrame);
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("f", stackFrame.getMethodName());
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepInto(stackFrame);
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("g", stackFrame.getMethodName());
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("g", stackFrame.getMethodName());
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("<init>", stackFrame.getMethodName()); // constructor of Exception
+ assertFalse(stackFrame.getVariables()[0].getName().contains("returned"));
+
+ stepReturn(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("g", stackFrame.getMethodName());
+ assertEquals("<init>() returned", stackFrame.getVariables()[0].getName());
+
+ stepInto(stackFrame);
+
+ stackFrame = (IJavaStackFrame) thread.getTopStackFrame();
+ assertEquals("main", stackFrame.getMethodName());
+ assertEquals("g() threw", stackFrame.getVariables()[0].getName());
+ }
+ finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
}
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
index 7fecb4a..5179c5e 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java
@@ -2518,8 +2518,7 @@
attachFiltersToStepRequest(request);
request.enable();
- if ((kind == StepRequest.STEP_OUT || kind == StepRequest.STEP_OVER) && manager.virtualMachine().canGetMethodReturnValues()
- && showStepResultIsEnabled()) {
+ if (manager.virtualMachine().canGetMethodReturnValues() && showStepResultIsEnabled()) {
if (fCurrentMethodExitRequest != null) {
removeJDIEventListener(this, fCurrentMethodExitRequest);
manager.deleteEventRequest(fCurrentMethodExitRequest);
@@ -2787,7 +2786,7 @@
StepEvent stepEvent = (StepEvent) event;
Location currentLocation = stepEvent.location();
- if ((getStepKind() == StepRequest.STEP_OUT || getStepKind() == StepRequest.STEP_OVER) && fStepResultCandidate != null) {
+ if (fStepResultCandidate != null) {
fStepResult = fStepResultCandidate;
fStepResultMethod = null;
fStepReturnTargetFrameCount = -1;