Commit 4c241242 authored by pcregut's avatar pcregut

Corrects bug #316332

visitLabel missing if no debug info (tryCatch
structure visit was also wrong).
parent 5dd94f39
...@@ -330,49 +330,49 @@ public class MethodCodeReader { ...@@ -330,49 +330,49 @@ public class MethodCodeReader {
// Parses all the instructions. // Parses all the instructions.
dexFile.seek(instructionsStartOffset); dexFile.seek(instructionsStartOffset);
while (dexFile.getPos() < instructionsEndOffset) { while (dexFile.getPos() < instructionsEndOffset) {
int relativeOffset = dexFile.getPos() - instructionsStartOffset;
if (!skipDebug && (debugCurrentOpcodeOffset >= 0)) { if (!skipDebug && (debugCurrentOpcodeOffset >= 0)) {
// Parses the Debug Information Item. This will work only if it has information // Parses the Debug Information Item. This will work only if it has information
// to display for the current offset. Note that we don't need to parse // to display for the current offset. Note that we don't need to parse
// this structure on the first pass (findLabelOnly). // this structure on the first pass (findLabelOnly).
int relativeOffset = dexFile.getPos() - instructionsStartOffset;
parseDebugInformationItem(methodVisitor, relativeOffset, findLabelsOnly); parseDebugInformationItem(methodVisitor, relativeOffset, findLabelsOnly);
// If a Label is present here, visit it. The label table must of course have }
// been built before (on the first pass). // If a Label is present here, visit it. The label table must of course have
if (labels.containsKey(relativeOffset)) { // been built before (on the first pass).
Label label = labels.get(relativeOffset); if (labels.containsKey(relativeOffset)) {
// The line number is valid only if set in the last occurrence Label label = labels.get(relativeOffset);
// of the Debug Informations parsing. // The line number is valid only if set in the last occurrence
if (newDebugLineEmitted) { // of the Debug Informations parsing (it implies !skipDebug).
label.setLine(debugEmittedLine); if (newDebugLineEmitted) {
} label.setLine(debugEmittedLine);
}
if (!findLabelsOnly) {
methodVisitor.visitLabel(label); if (!findLabelsOnly) {
} methodVisitor.visitLabel(label);
} }
}
// Visits the line number (previously parsed) AFTER we visited
// the Label. // Visits the line number (previously parsed) AFTER we visited
if (newDebugLineEmitted) { // the Label.
if (!findLabelsOnly) { if (newDebugLineEmitted) {
methodVisitor.visitLineNumber(debugEmittedLine, if (!findLabelsOnly) {
getLabel(relativeOffset)); methodVisitor.visitLineNumber(debugEmittedLine,
} getLabel(relativeOffset));
newDebugLineEmitted = false; }
} newDebugLineEmitted = false;
}
// If a Try/Catch block is here, visit it. The TryCatch table has been
// built before on first pass. // If a Try/Catch block is here, visit it. The TryCatch table has been
if (listTryCatchStructures.containsKey(relativeOffset)) { // built before on first pass.
ArrayList<TryCatch> listTryCatch = listTryCatchStructures.get(relativeOffset); if (listTryCatchStructures.containsKey(relativeOffset)) {
for (TryCatch tcs : listTryCatch) { ArrayList<TryCatch> listTryCatch = listTryCatchStructures.get(relativeOffset);
if (!findLabelsOnly) { for (TryCatch tcs : listTryCatch) {
methodVisitor.visitTryCatchBlock(tcs.getStart(), if (!findLabelsOnly) {
tcs.getEnd(), tcs.getHandler(), tcs.getType()); methodVisitor.visitTryCatchBlock(tcs.getStart(),
} tcs.getEnd(), tcs.getHandler(), tcs.getType());
} }
} }
} }
// Now reads the bytecode itself. // Now reads the bytecode itself.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment