Skip to content

Commit 4d19fec

Browse files
committed
Reorder step filter logic
1 parent 718d782 commit 4d19fec

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

com.microsoft.java.debug.core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<name>${base.name} :: Debugger Core</name>
99
<description>The Java Debug Server is an implementation of Visual Studio Code (VSCode) Debug Protocol. It can be used in Visual Studio Code to debug Java programs.</description>
1010
<url>https://github.com/scalacenter/java-debug</url>
11-
<version>0.34.0+5</version>
11+
<version>0.34.0+6</version>
1212
<properties>
1313
<base.name>Java Debug Server for Visual Studio Code</base.name>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/IStepFilterProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
public interface IStepFilterProvider extends IProvider {
1919
boolean shouldStepInto(Method method, Requests.StepFilters filters);
2020

21-
boolean shouldStepOut(Location previousLocation, Method method);
21+
boolean shouldStepOut(Location upperLocation, Method method);
2222
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/StepRequestHandler.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,18 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
164164
try {
165165
Location originalLocation = threadState.stepLocation;
166166
Location currentLocation = getTopFrame(thread).location();
167-
Location previousLocation = null;
167+
Location upperLocation = null;
168168
if (thread.frameCount() > 1) {
169-
previousLocation = thread.frame(1).location();
169+
upperLocation = thread.frame(1).location();
170170
}
171171
if (originalLocation != null && currentLocation != null) {
172172
boolean steppingIn = threadState.pendingStepType == Command.STEPIN;
173173
Requests.StepFilters stepFilters = context.getStepFilters();
174+
// If we stepped into a method that should be stepped out
175+
if (shouldStepOut(stepFilter, threadState.stackDepth, thread.frameCount(), upperLocation, currentLocation)) {
176+
doExtraStepOut(debugEvent, thread, stepFilters, threadState);
177+
return;
178+
}
174179
// If the ending location is the same as the original location do another step into.
175180
if (steppingIn && shouldDoExtraStep(threadState.stackDepth, originalLocation, thread.frameCount(), currentLocation)) {
176181
doExtraStepInto(debugEvent, thread, stepFilters, threadState);
@@ -181,11 +186,6 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
181186
doExtraStepInto(debugEvent, thread, stepFilters, threadState);
182187
return;
183188
}
184-
// If we stepped into a method that should be stepped out
185-
if (steppingIn && stepFilter.shouldStepOut(previousLocation, currentLocation.method())) {
186-
doExtraStepOut(debugEvent, thread, stepFilters, threadState);
187-
return;
188-
}
189189
}
190190

191191
} catch (IncompatibleThreadStateException | IndexOutOfBoundsException ex) {
@@ -225,6 +225,12 @@ private boolean shouldStepInto(IStepFilterProvider stepFilter, Location original
225225
&& stepFilter.shouldStepInto(currentLocation.method(), stepFilters);
226226
}
227227

228+
private boolean shouldStepOut(IStepFilterProvider stepFilter, int originalStackDepth, int currentStackDepth, Location upperLocation,
229+
Location currentLocation)
230+
throws IncompatibleThreadStateException {
231+
return currentStackDepth > originalStackDepth && stepFilter.shouldStepOut(upperLocation, currentLocation.method());
232+
}
233+
228234
/**
229235
* Check if the current top stack is same as the original top stack.
230236
*

com.microsoft.java.debug.plugin/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Bundle-ClassPath: lib/commons-io-2.10.0.jar,
2525
.,
2626
lib/rxjava-2.1.1.jar,
2727
lib/reactive-streams-1.0.0.jar,
28-
lib/com-microsoft-java-debug-core-0.34.0+5.jar
28+
lib/com-microsoft-java-debug-core-0.34.0+6.jar

com.microsoft.java.debug.plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<artifactItem>
4646
<groupId>ch.epfl.scala</groupId>
4747
<artifactId>com-microsoft-java-debug-core</artifactId>
48-
<version>0.34.0+5</version>
48+
<version>0.34.0+6</version>
4949
</artifactItem>
5050
</artifactItems>
5151
</configuration>

0 commit comments

Comments
 (0)