debugger: instruction parser should stop on code offset, not instruction index

This commit is contained in:
Egor.Ushakov
2015-03-20 20:27:36 +03:00
parent 2d63e30ec1
commit b66000da0c
2 changed files with 6 additions and 12 deletions
@@ -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) {
@@ -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<DecompiledLocalVariable> usedVars = new TIntObjectHashMap<DecompiledLocalVariable>();
new InstructionParser(bytecodes, instructionIndex) {
new InstructionParser(bytecodes, location.codeIndex()) {
@Override
protected void localVariableInstructionFound(int opcode, int slot, String typeSignature) {
if (slot >= firstLocalVariableSlot) {