allow to specify param no

This commit is contained in:
Egor.Ushakov
2016-12-28 13:58:22 +03:00
parent ddfe5a3589
commit efb3f4f90b
@@ -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<Map<ObjectReference, List<StackFrameItem>>> 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<ObjectReference, List<StackFrameItem>> stacks = myDebugProcess.getUserData(CAPTURED_STACKS);
if (stacks == null) {
stacks = new LinkedHashMap<ObjectReference, List<StackFrameItem>>() {
@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<ObjectReference, List<StackFrameItem>> stacks = myDebugProcess.getUserData(CAPTURED_STACKS);
if (stacks == null) {
stacks = new LinkedHashMap<ObjectReference, List<StackFrameItem>>() {
@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);
}
}