chore: resolve minor code issues in debug info parser

This commit is contained in:
Skylot
2019-08-02 22:46:39 +03:00
parent cf5bfc297b
commit 19ca8a096b
2 changed files with 12 additions and 15 deletions
@@ -17,7 +17,7 @@ import jadx.core.dex.visitors.JadxVisitor;
import jadx.core.dex.visitors.blocksmaker.BlockSplitter;
import jadx.core.dex.visitors.ssa.SSATransform;
import jadx.core.utils.ErrorsCounter;
import jadx.core.utils.exceptions.DecodeException;
import jadx.core.utils.Utils;
import jadx.core.utils.exceptions.JadxException;
@JadxVisitor(
@@ -40,11 +40,13 @@ public class DebugInfoParseVisitor extends AbstractVisitor {
processDebugInfo(mth, debugOffset);
}
} catch (Exception e) {
LOG.error("Error to parse debug info: {}", ErrorsCounter.formatMsg(mth, e.getMessage()), e);
mth.addComment("JADX WARNING: Error to parse debug info: "
+ ErrorsCounter.formatMsg(mth, e.getMessage())
+ '\n' + Utils.getStackTrace(e));
}
}
private void processDebugInfo(MethodNode mth, int debugOffset) throws DecodeException {
private void processDebugInfo(MethodNode mth, int debugOffset) {
InsnNode[] insnArr = mth.getInstructions();
DebugInfoParser debugInfoParser = new DebugInfoParser(mth, debugOffset, insnArr);
List<LocalVar> localVars = debugInfoParser.process();
@@ -107,8 +109,8 @@ public class DebugInfoParseVisitor extends AbstractVisitor {
int line = insn.getSourceLine();
if (line != 0) {
mth.setSourceLine(line - 1);
return;
}
return;
}
}
}
@@ -10,7 +10,6 @@ import jadx.core.dex.instructions.args.RegisterArg;
import jadx.core.dex.nodes.DexNode;
import jadx.core.dex.nodes.InsnNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.utils.exceptions.DecodeException;
public class DebugInfoParser {
private static final int DBG_END_SEQUENCE = 0x00;
@@ -50,7 +49,7 @@ public class DebugInfoParser {
this.insnByOffset = insnByOffset;
}
public List<LocalVar> process() throws DecodeException {
public List<LocalVar> process() {
boolean varsInfoFound = false;
resultList = new ArrayList<>();
@@ -142,15 +141,11 @@ public class DebugInfoParser {
}
default: {
if (c >= DBG_FIRST_SPECIAL) {
int adjustedOpCode = c - DBG_FIRST_SPECIAL;
int addrInc = adjustedOpCode / DBG_LINE_RANGE;
addr = addrChange(addr, addrInc, line);
line += DBG_LINE_BASE + adjustedOpCode % DBG_LINE_RANGE;
setLine(addr, line);
} else {
throw new DecodeException("Unknown debug insn code: " + c);
}
int adjustedOpCode = c - DBG_FIRST_SPECIAL;
int addrInc = adjustedOpCode / DBG_LINE_RANGE;
addr = addrChange(addr, addrInc, line);
line += DBG_LINE_BASE + adjustedOpCode % DBG_LINE_RANGE;
setLine(addr, line);
break;
}
}