diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java index 7d51b0f86642..15d2c8d22452 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java @@ -19,6 +19,7 @@ import com.intellij.debugger.engine.DebugProcessImpl; import com.intellij.debugger.engine.SuspendContextImpl; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.events.SuspendContextCommandImpl; +import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.memory.utils.StackFrameItem; import com.intellij.debugger.settings.DebuggerSettings; import com.intellij.openapi.util.Key; @@ -39,14 +40,16 @@ import java.util.Map; */ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { private final DebugProcessImpl myDebugProcess; + private final int myParamNo; public static final Key>> CAPTURED_STACKS = Key.create("CAPTURED_STACKS"); private static final int MAX_STORED_STACKS = 1000; private final JavaMethodBreakpointProperties myProperties = new JavaMethodBreakpointProperties(); - public StackCapturingLineBreakpoint(DebugProcessImpl debugProcess, String className, String methodName) { + public StackCapturingLineBreakpoint(DebugProcessImpl debugProcess, String className, String methodName, int paramNo) { super(debugProcess.getProject(), null); myDebugProcess = debugProcess; + myParamNo = paramNo; myProperties.EMULATED = true; myProperties.WATCH_EXIT = false; myProperties.myClassPattern = className; @@ -69,19 +72,22 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { try { SuspendContextImpl suspendContext = action.getSuspendContext(); if (suspendContext != null) { - Map> stacks = myDebugProcess.getUserData(CAPTURED_STACKS); - if (stacks == null) { - stacks = new LinkedHashMap>() { - @Override - protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_STORED_STACKS; - } - }; - myDebugProcess.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks)); - } - Value key = ContainerUtil.getFirstItem(suspendContext.getFrameProxy().getArgumentValues()); - if (key instanceof ObjectReference) { - stacks.put((ObjectReference)key, StackFrameItem.createFrames(suspendContext.getThread())); + StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy(); + if (frameProxy != null) { + Map> stacks = myDebugProcess.getUserData(CAPTURED_STACKS); + if (stacks == null) { + stacks = new LinkedHashMap>() { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > MAX_STORED_STACKS; + } + }; + myDebugProcess.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks)); + } + Value key = ContainerUtil.getOrElse(frameProxy.getArgumentValues(), myParamNo, null); + if (key instanceof ObjectReference) { + stacks.put((ObjectReference)key, StackFrameItem.createFrames(suspendContext.getThread())); + } } } } @@ -90,8 +96,8 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { return false; } - public static void track(DebugProcessImpl debugProcess, String classFqn, String methodName) { - StackCapturingLineBreakpoint breakpoint = new StackCapturingLineBreakpoint(debugProcess, classFqn, methodName); + public static void track(DebugProcessImpl debugProcess, String classFqn, String methodName, int paramNo) { + StackCapturingLineBreakpoint breakpoint = new StackCapturingLineBreakpoint(debugProcess, classFqn, methodName, paramNo); breakpoint.createRequest(debugProcess); } }