mirror of
https://github.com/revanced/smali.git
synced 2025-04-30 06:34:25 +02:00
Merge remote-tracking branch 'zerny/debuginfo'
This commit is contained in:
commit
7419b19f9a
@ -75,7 +75,7 @@ public class CDexBackedMethodImplementation extends DexBackedMethodImplementatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInstructionsSize() {
|
public int getInstructionsSize() {
|
||||||
int instructionsSize = dexFile.getDataBuffer().readUshort(
|
int instructionsSize = dexFile.getDataBuffer().readUshort(
|
||||||
codeOffset + CDEX_INSTRUCTIONS_SIZE_AND_PREHEADER_FLAGS_OFFSET) >>
|
codeOffset + CDEX_INSTRUCTIONS_SIZE_AND_PREHEADER_FLAGS_OFFSET) >>
|
||||||
CDEX_INSTRUCTIONS_SIZE_SHIFT;
|
CDEX_INSTRUCTIONS_SIZE_SHIFT;
|
||||||
|
@ -66,7 +66,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
return dexFile.getDataBuffer().readUshort(codeOffset);
|
return dexFile.getDataBuffer().readUshort(codeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getInstructionsSize() {
|
public int getInstructionsSize() {
|
||||||
return dexFile.getDataBuffer().readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
|
return dexFile.getDataBuffer().readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,13 +172,11 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
/**
|
/**
|
||||||
* Calculate and return the private size of a method implementation.
|
* Calculate and return the private size of a method implementation.
|
||||||
*
|
*
|
||||||
* Calculated as: debug info size + instructions size + try-catch size
|
* Calculated as: instructions size + try-catch size
|
||||||
*
|
*
|
||||||
* @return size in bytes
|
* @return size in bytes
|
||||||
*/
|
*/
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
int debugSize = getDebugInfo().getSize();
|
|
||||||
|
|
||||||
//set last offset just before bytecode instructions (after insns_size)
|
//set last offset just before bytecode instructions (after insns_size)
|
||||||
int lastOffset = getInstructionsStartOffset();
|
int lastOffset = getInstructionsStartOffset();
|
||||||
|
|
||||||
@ -195,7 +193,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
lastOffset = ((VariableSizeListIterator)tryHandlerIter).getReaderOffset();
|
lastOffset = ((VariableSizeListIterator)tryHandlerIter).getReaderOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//method impl size = debug block size + code_item size
|
//method impl size = code_item size
|
||||||
return debugSize + (lastOffset - codeOffset);
|
return lastOffset - codeOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterators;
|
||||||
import org.jf.dexlib2.AccessFlags;
|
import org.jf.dexlib2.AccessFlags;
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
@ -117,6 +118,10 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
DexReader reader = dexFile.getDataBuffer().readerAt(debugInfoOffset);
|
DexReader reader = dexFile.getDataBuffer().readerAt(debugInfoOffset);
|
||||||
final int lineNumberStart = reader.readBigUleb128();
|
final int lineNumberStart = reader.readBigUleb128();
|
||||||
int registerCount = methodImpl.getRegisterCount();
|
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?
|
//TODO: does dalvik allow references to invalid registers?
|
||||||
final LocalInfo[] locals = new LocalInfo[registerCount];
|
final LocalInfo[] locals = new LocalInfo[registerCount];
|
||||||
@ -172,7 +177,7 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected DebugItem readNextItem(@Nonnull DexReader reader) {
|
protected DebugItem readNextItem(@Nonnull DexReader reader) {
|
||||||
while (true) {
|
while (codeAddress <= lastInstructionAddress) {
|
||||||
int next = reader.readUbyte();
|
int next = reader.readUbyte();
|
||||||
switch (next) {
|
switch (next) {
|
||||||
case DebugItemType.END_SEQUENCE: {
|
case DebugItemType.END_SEQUENCE: {
|
||||||
@ -270,10 +275,13 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
int adjusted = next - 0x0A;
|
int adjusted = next - 0x0A;
|
||||||
codeAddress += adjusted / 15;
|
codeAddress += adjusted / 15;
|
||||||
lineNumber += (adjusted % 15) - 4;
|
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