mirror of
https://github.com/revanced/smali.git
synced 2025-04-29 22:24:26 +02:00
Only include debug info within the instruction range of a method.
This commit is contained in:
parent
cbd41d36cc
commit
6187d13f14
@ -75,7 +75,7 @@ public class CDexBackedMethodImplementation extends DexBackedMethodImplementatio
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInstructionsSize() {
|
||||
public int getInstructionsSize() {
|
||||
int instructionsSize = dexFile.getDataBuffer().readUshort(
|
||||
codeOffset + CDEX_INSTRUCTIONS_SIZE_AND_PREHEADER_FLAGS_OFFSET) >>
|
||||
CDEX_INSTRUCTIONS_SIZE_SHIFT;
|
||||
|
@ -66,7 +66,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
||||
return dexFile.getDataBuffer().readUshort(codeOffset);
|
||||
}
|
||||
|
||||
protected int getInstructionsSize() {
|
||||
public int getInstructionsSize() {
|
||||
return dexFile.getDataBuffer().readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
package org.jf.dexlib2.dexbacked.util;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.jf.dexlib2.AccessFlags;
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
@ -117,6 +118,10 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
||||
DexReader reader = dexFile.getDataBuffer().readerAt(debugInfoOffset);
|
||||
final int lineNumberStart = reader.readBigUleb128();
|
||||
int registerCount = methodImpl.getRegisterCount();
|
||||
// Debug information can have events for addresses past the instructions.
|
||||
// They have no relevance for the method in question and are excluded from the iterator.
|
||||
final int lastInstructionAddress = methodImpl.getInstructionsSize()
|
||||
- Iterators.getLast(methodImpl.getInstructions().iterator()).getCodeUnits();
|
||||
|
||||
//TODO: does dalvik allow references to invalid registers?
|
||||
final LocalInfo[] locals = new LocalInfo[registerCount];
|
||||
@ -172,7 +177,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
||||
|
||||
@Nullable
|
||||
protected DebugItem readNextItem(@Nonnull DexReader reader) {
|
||||
while (true) {
|
||||
while (codeAddress <= lastInstructionAddress) {
|
||||
int next = reader.readUbyte();
|
||||
switch (next) {
|
||||
case DebugItemType.END_SEQUENCE: {
|
||||
@ -270,10 +275,13 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
||||
int adjusted = next - 0x0A;
|
||||
codeAddress += adjusted / 15;
|
||||
lineNumber += (adjusted % 15) - 4;
|
||||
return new ImmutableLineNumber(codeAddress, lineNumber);
|
||||
return codeAddress <= lastInstructionAddress
|
||||
? new ImmutableLineNumber(codeAddress, lineNumber)
|
||||
: endOfData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return endOfData();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user