Search in sources :

Example 1 with CDexBackedDexFile

use of org.jf.dexlib2.dexbacked.CDexBackedDexFile in project smali by JesusFreke.

the class CdexDebugOffsetTable method annotate.

@Nonnull
public static void annotate(@Nonnull DexAnnotator annotator, DexBuffer buffer) {
    DexReader reader = buffer.readerAt(annotator.getCursor());
    SectionAnnotator debugInfoAnnotator = annotator.getAnnotator(ItemType.DEBUG_INFO_ITEM);
    int methodCount = annotator.dexFile.getMethodSection().size();
    for (int methodIndex = 0; methodIndex < methodCount; methodIndex += 16) {
        annotator.annotate(0, "Offset chuck for methods %d-%d", methodIndex, Math.min(methodIndex + 16, methodCount));
        annotator.indent();
        int bitmask = reader.readUbyte() << 8;
        bitmask |= reader.readUbyte();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 16; i++) {
            sb.append((bitmask >> i) & 1);
        }
        annotator.annotate(2, "bitmask: 0b%s", sb.reverse());
        int debugOffset = ((CDexBackedDexFile) annotator.dexFile).getDebugInfoBase();
        for (int i = 0; i < 16; i++) {
            if ((bitmask & 1) != 0) {
                int offsetDelta = reader.readBigUleb128();
                debugOffset += offsetDelta;
                annotator.annotateTo(reader.getOffset(), "[method_id: %d]: offset_delta: %d  (offset=0x%x)", methodIndex + i, offsetDelta, debugOffset);
                debugInfoAnnotator.setItemIdentity(debugOffset, annotator.dexFile.getMethodSection().get(methodIndex + i).toString());
            }
            bitmask >>= 1;
        }
        annotator.deindent();
    }
}
Also used : DexReader(org.jf.dexlib2.dexbacked.DexReader) CDexBackedDexFile(org.jf.dexlib2.dexbacked.CDexBackedDexFile) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)1 CDexBackedDexFile (org.jf.dexlib2.dexbacked.CDexBackedDexFile)1 DexReader (org.jf.dexlib2.dexbacked.DexReader)1