From cac8614b48fdc6500b9bd1d407515de785961290 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 17 Sep 2009 17:39:45 +0400 Subject: [PATCH] Remember a forced step into at its call stack (IDEADEV-39365) --- .../actions/SmartStepIntoActionHandler.java | 6 ++--- .../intellij/debugger/engine/DebugProcessImpl.java | 17 ++++++++++---- .../intellij/debugger/impl/DebuggerSession.java | 27 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepIntoActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepIntoActionHandler.java index 406be5710a..49ab74437a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepIntoActionHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepIntoActionHandler.java @@ -48,12 +48,12 @@ public class SmartStepIntoActionHandler extends DebuggerActionHandler { final List methods = findReferencedMethods(position); if (methods.size() > 0) { if (methods.size() == 1) { - session.stepInto(false, createSmartStepFilter(methods.get(0))); + session.stepInto(true, createSmartStepFilter(methods.get(0))); } else { final PsiMethodListPopupStep popupStep = new PsiMethodListPopupStep(methods, new PsiMethodListPopupStep.OnChooseRunnable() { public void execute(PsiMethod chosenMethod) { - session.stepInto(false, createSmartStepFilter(chosenMethod)); + session.stepInto(true, createSmartStepFilter(chosenMethod)); } }); final ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep); @@ -63,7 +63,7 @@ public class SmartStepIntoActionHandler extends DebuggerActionHandler { return; } } - session.stepInto(false, null); + session.stepInto(true, null); } @Nullable diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index c04aebb0fd..427cbd919e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -1354,6 +1354,7 @@ public abstract class DebugProcessImpl implements DebugProcess { final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl thread = suspendContext.getThread(); RequestHint hint = new RequestHint(thread, suspendContext, StepRequest.STEP_OUT); + hint.setIgnoreFilters(mySession.shouldIgnoreSteppingFilters()); if (myReturnValueWatcher != null) { myReturnValueWatcher.setTrackingEnabled(true); } @@ -1363,12 +1364,12 @@ public abstract class DebugProcessImpl implements DebugProcess { } private class StepIntoCommand extends ResumeCommand { - private final boolean myIgnoreFilters; + private final boolean myForcedIgnoreFilters; private final RequestHint.SmartStepFilter mySmartStepFilter; public StepIntoCommand(SuspendContextImpl suspendContext, boolean ignoreFilters, final @Nullable RequestHint.SmartStepFilter smartStepFilter) { super(suspendContext); - myIgnoreFilters = ignoreFilters || smartStepFilter != null; + myForcedIgnoreFilters = ignoreFilters || smartStepFilter != null; mySmartStepFilter = smartStepFilter; } @@ -1379,7 +1380,15 @@ public abstract class DebugProcessImpl implements DebugProcess { final RequestHint hint = mySmartStepFilter != null? new RequestHint(stepThread, suspendContext, mySmartStepFilter) : new RequestHint(stepThread, suspendContext, StepRequest.STEP_INTO); - hint.setIgnoreFilters(myIgnoreFilters); + if (myForcedIgnoreFilters) { + try { + mySession.setIgnoreStepFiltersFlag(stepThread.frameCount()); + } + catch (EvaluateException e) { + LOG.info(e); + } + } + hint.setIgnoreFilters(myForcedIgnoreFilters || mySession.shouldIgnoreSteppingFilters()); doStep(suspendContext, stepThread, StepRequest.STEP_INTO, hint); super.contextAction(); } @@ -1402,7 +1411,7 @@ public abstract class DebugProcessImpl implements DebugProcess { // from which the java code was generated RequestHint hint = new RequestHint(steppingThread, suspendContext, StepRequest.STEP_OVER); hint.setRestoreBreakpoints(myIsIgnoreBreakpoints); - hint.setIgnoreFilters(myIsIgnoreBreakpoints); + hint.setIgnoreFilters(myIsIgnoreBreakpoints || mySession.shouldIgnoreSteppingFilters()); if (myReturnValueWatcher != null) { myReturnValueWatcher.setTrackingEnabled(true); diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index 140bc5ba2e..c3b38580e3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -74,6 +74,7 @@ public class DebuggerSession implements AbstractDebuggerSession { public static final int EVENT_REFRESH_VIEWS_ONLY = 11; private volatile boolean myIsEvaluating; + private volatile int myIgnoreFiltersFrameCountThreshold = 0; private DebuggerSessionState myState = null; @@ -252,10 +253,23 @@ public class DebuggerSession implements AbstractDebuggerSession { final SuspendContextImpl suspendContext = getSuspendContext(); if(suspendContext != null) { mySteppingThroughThreads.remove(suspendContext.getThread()); + resetIgnoreStepFiltersFlag(); resumeAction(myDebugProcess.createResumeCommand(suspendContext), EVENT_RESUME); } } + private void resetIgnoreStepFiltersFlag() { + myIgnoreFiltersFrameCountThreshold = 0; + } + + public void setIgnoreStepFiltersFlag(int currentStackFrameCount) { + myIgnoreFiltersFrameCountThreshold = currentStackFrameCount; + } + + public boolean shouldIgnoreSteppingFilters() { + return myIgnoreFiltersFrameCountThreshold > 0; + } + public void pause() { myDebugProcess.getManagerThread().schedule(myDebugProcess.createPauseCommand()); } @@ -415,6 +429,19 @@ public class DebuggerSession implements AbstractDebuggerSession { positionContext = suspendContext; } + if (currentThread != null) { + try { + final int frameCount = currentThread.frameCount(); + if (frameCount == 0 || (frameCount < myIgnoreFiltersFrameCountThreshold)) { + resetIgnoreStepFiltersFlag(); + } + } + catch (EvaluateException e) { + LOG.info(e); + resetIgnoreStepFiltersFlag(); + } + } + SourcePosition position = PsiDocumentManager.getInstance(getProject()).commitAndRunReadAction(new Computable() { public @Nullable SourcePosition compute() { return ContextUtil.getSourcePosition(positionContext); -- 2.11.4.GIT