Search in sources :

Example 1 with LocalList

use of com.android.dx.dex.code.LocalList in project J2ME-Loader by nikita36078.

the class DebugInfoItem method encode0.

/**
 * Helper for {@link #encode} to do most of the work.
 *
 * @param file {@code null-ok;} file to refer to during encoding
 * @param prefix {@code null-ok;} prefix to attach to each line of output
 * @param debugPrint {@code null-ok;} if specified, an alternate output for
 * annotations
 * @param out {@code null-ok;} if specified, where annotations should go
 * @param consume whether to claim to have consumed output for
 * {@code out}
 * @return {@code non-null;} the encoded array
 */
private byte[] encode0(DexFile file, String prefix, PrintWriter debugPrint, AnnotatedOutput out, boolean consume) {
    PositionList positions = code.getPositions();
    LocalList locals = code.getLocals();
    DalvInsnList insns = code.getInsns();
    int codeSize = insns.codeSize();
    int regSize = insns.getRegistersSize();
    DebugInfoEncoder encoder = new DebugInfoEncoder(positions, locals, file, codeSize, regSize, isStatic, ref);
    byte[] result;
    if ((debugPrint == null) && (out == null)) {
        result = encoder.convert();
    } else {
        result = encoder.convertAndAnnotate(prefix, debugPrint, out, consume);
    }
    return result;
}
Also used : LocalList(com.android.dx.dex.code.LocalList) DalvInsnList(com.android.dx.dex.code.DalvInsnList) PositionList(com.android.dx.dex.code.PositionList)

Example 2 with LocalList

use of com.android.dx.dex.code.LocalList in project buck by facebook.

the class DebugInfoDecoder method validateEncode.

/**
     * Validates an encoded debug info stream against data used to encode it,
     * throwing an exception if they do not match. Used to validate the
     * encoder.
     *
     * @param info encoded debug info
     * @param file {@code non-null;} file to refer to during decoding
     * @param ref {@code non-null;} method whose info is being decoded
     * @param code {@code non-null;} original code object that was encoded
     * @param isStatic whether the method is static
     */
public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) {
    PositionList pl = code.getPositions();
    LocalList ll = code.getLocals();
    DalvInsnList insns = code.getInsns();
    int codeSize = insns.codeSize();
    int countRegisters = insns.getRegistersSize();
    try {
        validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll);
    } catch (RuntimeException ex) {
        System.err.println("instructions:");
        insns.debugPrint(System.err, "  ", true);
        System.err.println("local list:");
        ll.debugPrint(System.err, "  ");
        throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman());
    }
}
Also used : LocalList(com.android.dx.dex.code.LocalList) DalvInsnList(com.android.dx.dex.code.DalvInsnList) PositionList(com.android.dx.dex.code.PositionList)

Example 3 with LocalList

use of com.android.dx.dex.code.LocalList in project buck by facebook.

the class DebugInfoItem method encode0.

/**
     * Helper for {@link #encode} to do most of the work.
     *
     * @param file {@code null-ok;} file to refer to during encoding
     * @param prefix {@code null-ok;} prefix to attach to each line of output
     * @param debugPrint {@code null-ok;} if specified, an alternate output for
     * annotations
     * @param out {@code null-ok;} if specified, where annotations should go
     * @param consume whether to claim to have consumed output for
     * {@code out}
     * @return {@code non-null;} the encoded array
     */
private byte[] encode0(DexFile file, String prefix, PrintWriter debugPrint, AnnotatedOutput out, boolean consume) {
    PositionList positions = code.getPositions();
    LocalList locals = code.getLocals();
    DalvInsnList insns = code.getInsns();
    int codeSize = insns.codeSize();
    int regSize = insns.getRegistersSize();
    DebugInfoEncoder encoder = new DebugInfoEncoder(positions, locals, file, codeSize, regSize, isStatic, ref);
    byte[] result;
    if ((debugPrint == null) && (out == null)) {
        result = encoder.convert();
    } else {
        result = encoder.convertAndAnnotate(prefix, debugPrint, out, consume);
    }
    return result;
}
Also used : LocalList(com.android.dx.dex.code.LocalList) DalvInsnList(com.android.dx.dex.code.DalvInsnList) PositionList(com.android.dx.dex.code.PositionList)

Example 4 with LocalList

use of com.android.dx.dex.code.LocalList in project J2ME-Loader by nikita36078.

the class DebugInfoDecoder method validateEncode.

/**
 * Validates an encoded debug info stream against data used to encode it,
 * throwing an exception if they do not match. Used to validate the
 * encoder.
 *
 * @param info encoded debug info
 * @param file {@code non-null;} file to refer to during decoding
 * @param ref {@code non-null;} method whose info is being decoded
 * @param code {@code non-null;} original code object that was encoded
 * @param isStatic whether the method is static
 */
public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) {
    PositionList pl = code.getPositions();
    LocalList ll = code.getLocals();
    DalvInsnList insns = code.getInsns();
    int codeSize = insns.codeSize();
    int countRegisters = insns.getRegistersSize();
    try {
        validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll);
    } catch (RuntimeException ex) {
        System.err.println("instructions:");
        insns.debugPrint(System.err, "  ", true);
        System.err.println("local list:");
        ll.debugPrint(System.err, "  ");
        throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman());
    }
}
Also used : LocalList(com.android.dx.dex.code.LocalList) DalvInsnList(com.android.dx.dex.code.DalvInsnList) PositionList(com.android.dx.dex.code.PositionList)

Aggregations

DalvInsnList (com.android.dx.dex.code.DalvInsnList)4 LocalList (com.android.dx.dex.code.LocalList)4 PositionList (com.android.dx.dex.code.PositionList)4