From 50fcffc15b9c7e5b5f4cd912bff73b4599137bcd Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 28 Jun 2016 15:56:00 +0300 Subject: [PATCH] IDEA-157946 Incorrect set value for arguments without debug info --- .../debugger/jdi/LocalVariablesUtil.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java index e4309afb7672..a510307b67a7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java @@ -150,12 +150,13 @@ public class LocalVariablesUtil { com.sun.jdi.Method method = frameProxy.location().method(); final int firstLocalVariableSlot = getFirstLocalsSlot(method); + final int firstArgsSlot = getFirstArgsSlot(method); // gather code variables names - MultiMap namesMap = calcNames(new SimpleStackFrameContext(frameProxy, process), firstLocalVariableSlot); + MultiMap namesMap = calcNames(new SimpleStackFrameContext(frameProxy, process), firstLocalVariableSlot, firstArgsSlot); // first add arguments - int slot = 0; + int slot = firstArgsSlot; List typeNames = method.argumentTypeNames(); List argValues = frameProxy.getArgumentValues(); for (int i = 0; i < argValues.size(); i++) { @@ -316,7 +317,9 @@ public class LocalVariablesUtil { } @NotNull - private static MultiMap calcNames(@NotNull final StackFrameContext context, final int firstLocalsSlot) { + private static MultiMap calcNames(@NotNull final StackFrameContext context, + final int firstLocalsSlot, + final int firstArgsSlot) { return ApplicationManager.getApplication().runReadAction(new Computable>() { @Override public MultiMap compute() { @@ -326,7 +329,7 @@ public class LocalVariablesUtil { PsiElement method = DebuggerUtilsEx.getContainingMethod(element); if (method != null) { MultiMap res = new MultiMap<>(); - int slot = Math.max(0, firstLocalsSlot - getFirstLocalsSlot(method)); + int slot = Math.max(0, firstArgsSlot + firstLocalsSlot - getFirstLocalsSlot(method)); for (PsiParameter parameter : DebuggerUtilsEx.getParameters(method)) { res.putValue(slot, parameter.getName()); slot += getTypeSlotSize(parameter.getType()); @@ -496,8 +499,12 @@ public class LocalVariablesUtil { return 1; } + private static int getFirstArgsSlot(com.sun.jdi.Method method) { + return method.isStatic() ? 0 : 1; + } + private static int getFirstLocalsSlot(com.sun.jdi.Method method) { - int firstLocalVariableSlot = method.isStatic() ? 0 : 1; + int firstLocalVariableSlot = getFirstArgsSlot(method); for (String type : method.argumentTypeNames()) { firstLocalVariableSlot += getTypeSlotSize(type); }