From b66000da0cf46727b6702ce077b6ef841f436ba2 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 20 Mar 2015 20:26:10 +0300 Subject: [PATCH] debugger: instruction parser should stop on code offset, not instruction index --- .../intellij/debugger/jdi/InstructionParser.java | 15 +++++---------- .../debugger/ui/impl/FrameVariablesTree.java | 3 +-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/InstructionParser.java b/java/debugger/impl/src/com/intellij/debugger/jdi/InstructionParser.java index 78bf10fe7e40..2cfa649b10dc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/InstructionParser.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/InstructionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,21 +22,16 @@ import org.jetbrains.annotations.Nullable; */ public class InstructionParser { private final byte[] myCode; - private final long myCurrentInstructionIndex; + private final long myStopOffset; - public InstructionParser(byte[] code, long instructionIndex) { + public InstructionParser(byte[] code, long stopOffset) { myCode = code; - myCurrentInstructionIndex = instructionIndex; + myStopOffset = stopOffset; } public void parse() { - final int codeEnd = myCode.length; int v = 0; - int instructionIndex = 0; - while (v < codeEnd) { - if (instructionIndex++ >= myCurrentInstructionIndex) { - break; - } + while (v < myStopOffset) { int opcode = myCode[v] & 0xFF; final byte opcodeType = opcode == Bytecodes.IMPDEP1 || opcode == Bytecodes.IMPDEP2? Bytecodes.NOARG_INSN : Bytecodes.TYPE[opcode]; switch (opcodeType) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java index c4c6201f0ee6..5bf55df20844 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java @@ -242,9 +242,8 @@ public class FrameVariablesTree extends DebuggerTree { final byte[] bytecodes = method.bytecodes(); if (bytecodes != null && bytecodes.length > 0) { final int firstLocalVariableSlot = ArgumentValueDescriptorImpl.getFirstLocalsSlot(method); - final long instructionIndex = location.codeIndex(); final TIntObjectHashMap usedVars = new TIntObjectHashMap(); - new InstructionParser(bytecodes, instructionIndex) { + new InstructionParser(bytecodes, location.codeIndex()) { @Override protected void localVariableInstructionFound(int opcode, int slot, String typeSignature) { if (slot >= firstLocalVariableSlot) {