From 5bb2719ce562771f59e01f3be9d2939f921069d2 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 29 Jun 2016 11:11:03 +0300 Subject: [PATCH] IDEA-157946 Incorrect set value for arguments without debug info - better fix --- .../debugger/jdi/LocalVariablesUtil.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 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 a510307b67a7..0b3998dff70f 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java @@ -150,13 +150,12 @@ 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, firstArgsSlot); + MultiMap namesMap = calcNames(new SimpleStackFrameContext(frameProxy, process), firstLocalVariableSlot); // first add arguments - int slot = firstArgsSlot; + int slot = getFirstArgsSlot(method); List typeNames = method.argumentTypeNames(); List argValues = frameProxy.getArgumentValues(); for (int i = 0; i < argValues.size(); i++) { @@ -317,9 +316,7 @@ public class LocalVariablesUtil { } @NotNull - private static MultiMap calcNames(@NotNull final StackFrameContext context, - final int firstLocalsSlot, - final int firstArgsSlot) { + private static MultiMap calcNames(@NotNull final StackFrameContext context, final int firstLocalsSlot) { return ApplicationManager.getApplication().runReadAction(new Computable>() { @Override public MultiMap compute() { @@ -329,7 +326,7 @@ public class LocalVariablesUtil { PsiElement method = DebuggerUtilsEx.getContainingMethod(element); if (method != null) { MultiMap res = new MultiMap<>(); - int slot = Math.max(0, firstArgsSlot + firstLocalsSlot - getFirstLocalsSlot(method)); + int slot = Math.max(0, firstLocalsSlot - getParametersStackSize(method)); for (PsiParameter parameter : DebuggerUtilsEx.getParameters(method)) { res.putValue(slot, parameter.getName()); slot += getTypeSlotSize(parameter.getType()); @@ -481,11 +478,8 @@ public class LocalVariablesUtil { } } - private static int getFirstLocalsSlot(PsiElement method) { + private static int getParametersStackSize(PsiElement method) { int startSlot = 0; - if (method instanceof PsiModifierListOwner) { - startSlot = ((PsiModifierListOwner)method).hasModifierProperty(PsiModifier.STATIC) ? 0 : 1; - } for (PsiParameter parameter : DebuggerUtilsEx.getParameters(method)) { startSlot += getTypeSlotSize(parameter.getType()); }