Skip to content

Commit 7d92828

Browse files
committed
Fix step handler when upperFrame is null
1 parent a67da2e commit 7d92828

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,14 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
169169
upperLocation = thread.frame(1).location();
170170
}
171171
if (originalLocation != null && currentLocation != null) {
172-
boolean steppingIn = threadState.pendingStepType == Command.STEPIN;
173172
Requests.StepFilters stepFilters = context.getStepFilters();
174173
// If we stepped into a method that should be stepped out
175174
if (shouldStepOut(stepFilter, threadState.stackDepth, thread.frameCount(), upperLocation, currentLocation)) {
176175
doExtraStepOut(debugEvent, thread, stepFilters, threadState);
177176
return;
178177
}
179178
// If the ending location is the same as the original location do another step into.
180-
if (steppingIn && shouldDoExtraStep(threadState.stackDepth, originalLocation, thread.frameCount(), currentLocation)) {
179+
if (shouldDoExtraStep(threadState, originalLocation, thread.frameCount(), currentLocation)) {
181180
doExtraStepInto(debugEvent, thread, stepFilters, threadState);
182181
return;
183182
}
@@ -228,7 +227,13 @@ private boolean shouldStepInto(IStepFilterProvider stepFilter, Location original
228227
private boolean shouldStepOut(IStepFilterProvider stepFilter, int originalStackDepth, int currentStackDepth, Location upperLocation,
229228
Location currentLocation)
230229
throws IncompatibleThreadStateException {
231-
return currentStackDepth > originalStackDepth && stepFilter.shouldStepOut(upperLocation, currentLocation.method());
230+
if (upperLocation == null) {
231+
return false;
232+
}
233+
if (currentStackDepth <= originalStackDepth) {
234+
return false;
235+
}
236+
return stepFilter.shouldStepOut(upperLocation, currentLocation.method());
232237
}
233238

234239
/**
@@ -237,9 +242,12 @@ private boolean shouldStepOut(IStepFilterProvider stepFilter, int originalStackD
237242
* @throws IncompatibleThreadStateException
238243
* if the thread is not suspended in the target VM.
239244
*/
240-
private boolean shouldDoExtraStep(int originalStackDepth, Location originalLocation, int currentStackDepth, Location currentLocation)
245+
private boolean shouldDoExtraStep(ThreadState threadState, Location originalLocation, int currentStackDepth, Location currentLocation)
241246
throws IncompatibleThreadStateException {
242-
if (originalStackDepth != currentStackDepth) {
247+
if (threadState.pendingStepType != Command.STEPIN) {
248+
return false;
249+
}
250+
if (threadState.stackDepth != currentStackDepth) {
243251
return false;
244252
}
245253
if (originalLocation == null) {

0 commit comments

Comments
 (0)