/** * 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 */ public void debugPrint(PrintWriter out, String prefix) { encode(null, prefix, out, null, false); }
/** * 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 */ private byte[] encode(DexFile file, String prefix, PrintWriter debugPrint, AnnotatedOutput out, boolean consume) { 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; }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { 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); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // 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()); } }
boolean needPadding = (insnsSz & 1) != 0; int triesSz = (catches == null) ? 0 : catches.triesSize(); int debugOff = (debugInfo == null) ? 0 : debugInfo.getAbsoluteOffset(); debugInfo.annotateTo(file, out, " ");
/** {@inheritDoc} */ public void addContents(DexFile file) { MixedItemSection byteData = file.getByteData(); TypeIdsSection typeIds = file.getTypeIds(); if (code.hasPositions() || code.hasLocals()) { debugInfo = new DebugInfoItem(code, isStatic, ref); byteData.add(debugInfo); } if (code.hasAnyCatches()) { for (Type type : code.getCatchTypes()) { typeIds.intern(type); } catches = new CatchStructs(code); } for (Constant c : code.getInsnConstants()) { file.internIfAppropriate(c); } }
/** * Does a human-friendly dump of this instance. * * @param out {@code non-null;} where to dump * @param prefix {@code non-null;} per-line prefix to use * @param verbose whether to be verbose with the output */ public void debugPrint(PrintWriter out, String prefix, boolean verbose) { out.println(ref.toHuman() + ":"); DalvInsnList insns = code.getInsns(); out.println("regs: " + Hex.u2(getRegistersSize()) + "; ins: " + Hex.u2(getInsSize()) + "; outs: " + Hex.u2(getOutsSize())); insns.debugPrint(out, prefix, verbose); String prefix2 = prefix + " "; if (catches != null) { out.print(prefix); out.println("catches"); catches.debugPrint(out, prefix2); } if (debugInfo != null) { out.print(prefix); out.println("debug info"); debugInfo.debugPrint(out, prefix2); } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { 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); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // 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()); } }
boolean needPadding = (insnsSz & 1) != 0; int triesSz = (catches == null) ? 0 : catches.triesSize(); int debugOff = (debugInfo == null) ? 0 : debugInfo.getAbsoluteOffset(); debugInfo.annotateTo(file, out, " ");
/** {@inheritDoc} */ public void addContents(DexFile file) { MixedItemSection byteData = file.getByteData(); TypeIdsSection typeIds = file.getTypeIds(); if (code.hasPositions() || code.hasLocals()) { debugInfo = new DebugInfoItem(code, isStatic, ref); byteData.add(debugInfo); } if (code.hasAnyCatches()) { for (Type type : code.getCatchTypes()) { typeIds.intern(type); } catches = new CatchStructs(code); } for (Constant c : code.getInsnConstants()) { file.internIfAppropriate(c); } }
/** * Does a human-friendly dump of this instance. * * @param out {@code non-null;} where to dump * @param prefix {@code non-null;} per-line prefix to use * @param verbose whether to be verbose with the output */ public void debugPrint(PrintWriter out, String prefix, boolean verbose) { out.println(ref.toHuman() + ":"); DalvInsnList insns = code.getInsns(); out.println("regs: " + Hex.u2(getRegistersSize()) + "; ins: " + Hex.u2(getInsSize()) + "; outs: " + Hex.u2(getOutsSize())); insns.debugPrint(out, prefix, verbose); String prefix2 = prefix + " "; if (catches != null) { out.print(prefix); out.println("catches"); catches.debugPrint(out, prefix2); } if (debugInfo != null) { out.print(prefix); out.println("debug info"); debugInfo.debugPrint(out, prefix2); } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { 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); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { // 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()); } }
boolean needPadding = (insnsSz & 1) != 0; int triesSz = (catches == null) ? 0 : catches.triesSize(); int debugOff = (debugInfo == null) ? 0 : debugInfo.getAbsoluteOffset(); debugInfo.annotateTo(file, out, " ");
/** * 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 */ public void debugPrint(PrintWriter out, String prefix) { encode(null, prefix, out, null, false); }
/** {@inheritDoc} */ @Override public void addContents(DexFile file) { MixedItemSection byteData = file.getByteData(); TypeIdsSection typeIds = file.getTypeIds(); if (code.hasPositions() || code.hasLocals()) { debugInfo = new DebugInfoItem(code, isStatic, ref); byteData.add(debugInfo); } if (code.hasAnyCatches()) { for (Type type : code.getCatchTypes()) { typeIds.intern(type); } catches = new CatchStructs(code); } for (Constant c : code.getInsnConstants()) { file.internIfAppropriate(c); } }
/** * 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 */ private byte[] encode(DexFile file, String prefix, PrintWriter debugPrint, AnnotatedOutput out, boolean consume) { 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; }
/** * Does a human-friendly dump of this instance. * * @param out {@code non-null;} where to dump * @param prefix {@code non-null;} per-line prefix to use * @param verbose whether to be verbose with the output */ public void debugPrint(PrintWriter out, String prefix, boolean verbose) { out.println(ref.toHuman() + ":"); DalvInsnList insns = code.getInsns(); out.println("regs: " + Hex.u2(getRegistersSize()) + "; ins: " + Hex.u2(getInsSize()) + "; outs: " + Hex.u2(getOutsSize())); insns.debugPrint(out, prefix, verbose); String prefix2 = prefix + " "; if (catches != null) { out.print(prefix); out.println("catches"); catches.debugPrint(out, prefix2); } if (debugInfo != null) { out.print(prefix); out.println("debug info"); debugInfo.debugPrint(out, prefix2); } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { 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); }