FileDocCategorySizeDatePackage
DebugInfoItem.javaAPI DocAndroid 5.1 API6507Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.file

DebugInfoItem

public class DebugInfoItem extends OffsettedItem

Fields Summary
private static final int
ALIGNMENT
the required alignment for instances of this class
private static final boolean
ENABLE_ENCODER_SELF_CHECK
private final com.android.dx.dex.code.DalvCode
code
{@code non-null;} the code this item represents
private byte[]
encoded
private final boolean
isStatic
private final com.android.dx.rop.cst.CstMethodRef
ref
Constructors Summary
public DebugInfoItem(com.android.dx.dex.code.DalvCode code, boolean isStatic, com.android.dx.rop.cst.CstMethodRef ref)


           
        // We don't know the write size yet.
        super (ALIGNMENT, -1);

        if (code == null) {
            throw new NullPointerException("code == null");
        }

        this.code = code;
        this.isStatic = isStatic;
        this.ref = ref;
    
Methods Summary
public voidaddContents(DexFile file)
{@inheritDoc}

        // No contents to add.
    
public voidannotateTo(DexFile file, com.android.dx.util.AnnotatedOutput out, java.lang.String prefix)
Writes annotations for the elements of this list, as zero-length. This is meant to be used for dumping this instance directly after a code dump (with the real local list actually existing elsewhere in the output).

param
file {@code non-null;} the file to use for referencing other sections
param
out {@code non-null;} where to annotate to
param
prefix {@code null-ok;} prefix to attach to each line of output

        encode(file, prefix, null, out, false);
    
public voiddebugPrint(java.io.PrintWriter out, java.lang.String prefix)
Does a human-friendly dump of this instance.

param
out {@code non-null;} where to dump
param
prefix {@code non-null;} prefix to attach to each line of output

        encode(null, prefix, out, null, false);
    
private byte[]encode(DexFile file, java.lang.String prefix, java.io.PrintWriter debugPrint, com.android.dx.util.AnnotatedOutput out, boolean consume)
Performs debug info encoding.

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

        byte[] result = encode0(file, prefix, debugPrint, out, consume);

        if (ENABLE_ENCODER_SELF_CHECK && (file != null)) {
            try {
                DebugInfoDecoder.validateEncode(result, file, ref, code,
                        isStatic);
            } catch (RuntimeException ex) {
                // Reconvert, annotating to System.err.
                encode0(file, "", new PrintWriter(System.err, true), null,
                        false);
                throw ex;
            }
        }

        return result;
    
private byte[]encode0(DexFile file, java.lang.String prefix, java.io.PrintWriter debugPrint, com.android.dx.util.AnnotatedOutput out, boolean consume)
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

        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;
    
public ItemTypeitemType()
{@inheritDoc}

        return ItemType.TYPE_DEBUG_INFO_ITEM;
    
protected voidplace0(Section addedTo, int offset)
{@inheritDoc}

        // Encode the data and note the size.

        try {
            encoded = encode(addedTo.getFile(), null, null, null, false);
            setWriteSize(encoded.length);
        } catch (RuntimeException ex) {
            throw ExceptionWithContext.withContext(ex,
                    "...while placing debug info for " + ref.toHuman());
        }
    
public java.lang.StringtoHuman()
{@inheritDoc}

        throw new RuntimeException("unsupported");
    
protected voidwriteTo0(DexFile file, com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        if (out.annotates()) {
            /*
             * Re-run the encoder to generate the annotations,
             * but write the bits from the original encode
             */

            out.annotate(offsetString() + " debug info");
            encode(file, null, null, out, true);
        }

        out.write(encoded);