org.jf.dexlib2.iface.debug.DebugItem Java Examples
The following examples show how to use
org.jf.dexlib2.iface.debug.DebugItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImmutableMethodImplementation.java From ZjDroid with Apache License 2.0 | 5 votes |
public ImmutableMethodImplementation(int registerCount, @Nullable Iterable<? extends Instruction> instructions, @Nullable List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks, @Nullable Iterable<? extends DebugItem> debugItems) { this.registerCount = registerCount; this.instructions = ImmutableInstruction.immutableListOf(instructions); this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks); this.debugItems = ImmutableDebugItem.immutableListOf(debugItems); }
Example #2
Source File: ImmutableMethodImplementation.java From zjdroid with Apache License 2.0 | 5 votes |
public ImmutableMethodImplementation(int registerCount, @Nullable Iterable<? extends Instruction> instructions, @Nullable List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks, @Nullable Iterable<? extends DebugItem> debugItems) { this.registerCount = registerCount; this.instructions = ImmutableInstruction.immutableListOf(instructions); this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks); this.debugItems = ImmutableDebugItem.immutableListOf(debugItems); }
Example #3
Source File: ImmutableMethodImplementation.java From ZjDroid with Apache License 2.0 | 5 votes |
public ImmutableMethodImplementation(int registerCount, @Nullable Iterable<? extends Instruction> instructions, @Nullable List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks, @Nullable Iterable<? extends DebugItem> debugItems) { this.registerCount = registerCount; this.instructions = ImmutableInstruction.immutableListOf(instructions); this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks); this.debugItems = ImmutableDebugItem.immutableListOf(debugItems); }
Example #4
Source File: MethodImplReIClassDef.java From atlas with Apache License 2.0 | 5 votes |
@Override protected MethodImplementation reMethodImpl(MethodImplementation methodImplementation) { if (methodImplementation == null){ return null; } Iterable<? extends Instruction> instructions = methodImplementation.getInstructions(); Iterable<? extends DebugItem> debugItems = methodImplementation.getDebugItems(); List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = methodImplementation.getTryBlocks(); return new ImmutableMethodImplementation(methodImplementation.getRegisterCount(), reInstructions(instructions), reTryCatchBlock(methodImplementation.getTryBlocks()), reDebugItem(methodImplementation.getDebugItems())); }
Example #5
Source File: ImmutableMethodImplementation.java From HeyGirl with Apache License 2.0 | 5 votes |
public ImmutableMethodImplementation(int registerCount, @Nullable Iterable<? extends Instruction> instructions, @Nullable List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks, @Nullable Iterable<? extends DebugItem> debugItems) { this.registerCount = registerCount; this.instructions = ImmutableInstruction.immutableListOf(instructions); this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks); this.debugItems = ImmutableDebugItem.immutableListOf(debugItems); }
Example #6
Source File: RewriterModule.java From HeyGirl with Apache License 2.0 | 4 votes |
@Nonnull public Rewriter<DebugItem> getDebugItemRewriter(@Nonnull Rewriters rewriters) { return new DebugItemRewriter(rewriters); }
Example #7
Source File: RewriterModule.java From zjdroid with Apache License 2.0 | 4 votes |
@Nonnull public Rewriter<DebugItem> getDebugItemRewriter(@Nonnull Rewriters rewriters) { return new DebugItemRewriter(rewriters); }
Example #8
Source File: MethodImplementationRewriter.java From zjdroid with Apache License 2.0 | 4 votes |
@Override @Nonnull public Iterable<? extends DebugItem> getDebugItems() { return RewriterUtils.rewriteIterable(rewriters.getDebugItemRewriter(), methodImplementation.getDebugItems()); }
Example #9
Source File: MethodDefinition.java From zjdroid with Apache License 2.0 | 4 votes |
private void addDebugInfo(final List<MethodItem> methodItems) { for (DebugItem debugItem: methodImpl.getDebugItems()) { methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); } }
Example #10
Source File: DexBody.java From JAADAS with GNU General Public License v3.0 | 4 votes |
/** * @param code the codeitem that is contained in this body * @param method the method that is associated with this body */ public DexBody(DexFile dexFile, Method method, RefType declaringClassType) { MethodImplementation code = method.getImplementation(); if (code == null) throw new RuntimeException("error: no code for method "+ method.getName()); this.declaringClassType = declaringClassType; tries = code.getTryBlocks(); methodSignature = method.getDefiningClass() +": "+ method.getReturnType() +" "+ method.getName() +"("; for (MethodParameter mp: method.getParameters()) methodSignature += mp.getType() +","; List<? extends CharSequence> paramTypes = method.getParameterTypes(); if (paramTypes != null) { parameterTypes = new ArrayList<Type>(); for (CharSequence type : paramTypes) parameterTypes.add(DexType.toSoot(type.toString())); } else { parameterTypes = Collections.emptyList(); } isStatic = Modifier.isStatic(method.getAccessFlags()); numRegisters = code.getRegisterCount(); numParameterRegisters = MethodUtil.getParameterRegisterCount(method); if (!isStatic) numParameterRegisters--; instructions = new ArrayList<DexlibAbstractInstruction>(); instructionAtAddress = new HashMap<Integer, DexlibAbstractInstruction>(); registerLocals = new Local[numRegisters]; int address = 0; for (Instruction instruction : code.getInstructions()) { DexlibAbstractInstruction dexInstruction = fromInstruction(instruction, address); instructions.add(dexInstruction); instructionAtAddress.put(address, dexInstruction); Debug.printDbg(" put instruction '", dexInstruction ,"' at 0x", Integer.toHexString(address)); address += instruction.getCodeUnits(); } // Check taken from Android's dalvik/libdex/DexSwapVerify.cpp if (numParameterRegisters > numRegisters) throw new RuntimeException("Malformed dex file: insSize (" + numParameterRegisters + ") > registersSize (" + numRegisters + ")"); for (DebugItem di: code.getDebugItems()) { if (di instanceof ImmutableLineNumber) { ImmutableLineNumber ln = (ImmutableLineNumber)di; DexlibAbstractInstruction ins = instructionAtAddress(ln.getCodeAddress()); if (ins == null) { Debug.printDbg("Line number tag pointing to invalid offset: " + ln.getCodeAddress()); continue; } ins.setLineNumber(ln.getLineNumber()); Debug.printDbg("Add line number tag " + ln.getLineNumber() + " for instruction: " + instructionAtAddress(ln.getCodeAddress())); } } this.dexFile = dexFile; }
Example #11
Source File: DexWriter.java From HeyGirl with Apache License 2.0 | 4 votes |
private void writeDebugAndCodeItems(@Nonnull DexDataWriter offsetWriter, @Nonnull DeferredOutputStream temp) throws IOException { ByteArrayOutputStream ehBuf = new ByteArrayOutputStream(); debugSectionOffset = offsetWriter.getPosition(); DebugWriter<StringKey, TypeKey> debugWriter = new DebugWriter<StringKey, TypeKey>(stringSection, typeSection, offsetWriter); DexDataWriter codeWriter = new DexDataWriter(temp, 0); List<CodeItemOffset<MethodKey>> codeOffsets = Lists.newArrayList(); for (ClassKey classKey: classSection.getSortedClasses()) { Collection<? extends MethodKey> directMethods = classSection.getSortedDirectMethods(classKey); Collection<? extends MethodKey> virtualMethods = classSection.getSortedVirtualMethods(classKey); Iterable<MethodKey> methods = Iterables.concat(directMethods, virtualMethods); for (MethodKey methodKey: methods) { List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = classSection.getTryBlocks(methodKey); Iterable<? extends Instruction> instructions = classSection.getInstructions(methodKey); Iterable<? extends DebugItem> debugItems = classSection.getDebugItems(methodKey); if (instructions != null && stringSection.hasJumboIndexes()) { boolean needsFix = false; for (Instruction instruction: instructions) { if (instruction.getOpcode() == Opcode.CONST_STRING) { if (stringSection.getItemIndex( (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) { needsFix = true; break; } } } if (needsFix) { MutableMethodImplementation mutableMethodImplementation = classSection.makeMutableMethodImplementation(methodKey); fixInstructions(mutableMethodImplementation); instructions = mutableMethodImplementation.getInstructions(); tryBlocks = mutableMethodImplementation.getTryBlocks(); debugItems = mutableMethodImplementation.getDebugItems(); } } int debugItemOffset = writeDebugItem(offsetWriter, debugWriter, classSection.getParameterNames(methodKey), debugItems); int codeItemOffset = writeCodeItem(codeWriter, ehBuf, methodKey, tryBlocks, instructions, debugItemOffset); if (codeItemOffset != -1) { codeOffsets.add(new CodeItemOffset<MethodKey>(methodKey, codeItemOffset)); } } } offsetWriter.align(); codeSectionOffset = offsetWriter.getPosition(); codeWriter.close(); temp.writeTo(offsetWriter); temp.close(); for (CodeItemOffset<MethodKey> codeOffset: codeOffsets) { classSection.setCodeItemOffset(codeOffset.method, codeSectionOffset + codeOffset.codeOffset); } }
Example #12
Source File: DexBackedMethodImplementation.java From zjdroid with Apache License 2.0 | 4 votes |
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() { return getDebugInfo(); }
Example #13
Source File: MethodImplementationRewriter.java From HeyGirl with Apache License 2.0 | 4 votes |
@Override @Nonnull public Iterable<? extends DebugItem> getDebugItems() { return RewriterUtils.rewriteIterable(rewriters.getDebugItemRewriter(), methodImplementation.getDebugItems()); }
Example #14
Source File: DexBackedMethodImplementation.java From HeyGirl with Apache License 2.0 | 4 votes |
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() { return getDebugInfo(); }
Example #15
Source File: MethodDefinition.java From HeyGirl with Apache License 2.0 | 4 votes |
private void addDebugInfo(final List<MethodItem> methodItems) { for (DebugItem debugItem: methodImpl.getDebugItems()) { methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); } }
Example #16
Source File: DexWriter.java From ZjDroid with Apache License 2.0 | 4 votes |
private void writeDebugAndCodeItems(@Nonnull DexDataWriter offsetWriter, @Nonnull DeferredOutputStream temp) throws IOException { ByteArrayOutputStream ehBuf = new ByteArrayOutputStream(); debugSectionOffset = offsetWriter.getPosition(); DebugWriter<StringKey, TypeKey> debugWriter = new DebugWriter<StringKey, TypeKey>(stringSection, typeSection, offsetWriter); DexDataWriter codeWriter = new DexDataWriter(temp, 0); List<CodeItemOffset<MethodKey>> codeOffsets = Lists.newArrayList(); for (ClassKey classKey: classSection.getSortedClasses()) { Collection<? extends MethodKey> directMethods = classSection.getSortedDirectMethods(classKey); Collection<? extends MethodKey> virtualMethods = classSection.getSortedVirtualMethods(classKey); Iterable<MethodKey> methods = Iterables.concat(directMethods, virtualMethods); for (MethodKey methodKey: methods) { List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = classSection.getTryBlocks(methodKey); Iterable<? extends Instruction> instructions = classSection.getInstructions(methodKey); Iterable<? extends DebugItem> debugItems = classSection.getDebugItems(methodKey); if (instructions != null && stringSection.hasJumboIndexes()) { boolean needsFix = false; for (Instruction instruction: instructions) { if (instruction.getOpcode() == Opcode.CONST_STRING) { if (stringSection.getItemIndex( (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) { needsFix = true; break; } } } if (needsFix) { MutableMethodImplementation mutableMethodImplementation = classSection.makeMutableMethodImplementation(methodKey); fixInstructions(mutableMethodImplementation); instructions = mutableMethodImplementation.getInstructions(); tryBlocks = mutableMethodImplementation.getTryBlocks(); debugItems = mutableMethodImplementation.getDebugItems(); } } int debugItemOffset = writeDebugItem(offsetWriter, debugWriter, classSection.getParameterNames(methodKey), debugItems); int codeItemOffset = writeCodeItem(codeWriter, ehBuf, methodKey, tryBlocks, instructions, debugItemOffset); if (codeItemOffset != -1) { codeOffsets.add(new CodeItemOffset<MethodKey>(methodKey, codeItemOffset)); } } } offsetWriter.align(); codeSectionOffset = offsetWriter.getPosition(); codeWriter.close(); temp.writeTo(offsetWriter); temp.close(); for (CodeItemOffset<MethodKey> codeOffset: codeOffsets) { classSection.setCodeItemOffset(codeOffset.method, codeSectionOffset + codeOffset.codeOffset); } }
Example #17
Source File: RewriterModule.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull public Rewriter<DebugItem> getDebugItemRewriter(@Nonnull Rewriters rewriters) { return new DebugItemRewriter(rewriters); }
Example #18
Source File: MethodImplementationRewriter.java From ZjDroid with Apache License 2.0 | 4 votes |
@Override @Nonnull public Iterable<? extends DebugItem> getDebugItems() { return RewriterUtils.rewriteIterable(rewriters.getDebugItemRewriter(), methodImplementation.getDebugItems()); }
Example #19
Source File: DexBackedMethodImplementation.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() { return getDebugInfo(); }
Example #20
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 4 votes |
private void addDebugInfo(final List<MethodItem> methodItems) { for (DebugItem debugItem: methodImpl.getDebugItems()) { methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); } }
Example #21
Source File: MethodImplementationRewriter.java From ZjDroid with Apache License 2.0 | 4 votes |
@Override @Nonnull public Iterable<? extends DebugItem> getDebugItems() { return RewriterUtils.rewriteIterable(rewriters.getDebugItemRewriter(), methodImplementation.getDebugItems()); }
Example #22
Source File: DexWriter.java From ZjDroid with Apache License 2.0 | 4 votes |
private void writeDebugAndCodeItems(@Nonnull DexDataWriter offsetWriter, @Nonnull DeferredOutputStream temp) throws IOException { ByteArrayOutputStream ehBuf = new ByteArrayOutputStream(); debugSectionOffset = offsetWriter.getPosition(); DebugWriter<StringKey, TypeKey> debugWriter = new DebugWriter<StringKey, TypeKey>(stringSection, typeSection, offsetWriter); DexDataWriter codeWriter = new DexDataWriter(temp, 0); List<CodeItemOffset<MethodKey>> codeOffsets = Lists.newArrayList(); for (ClassKey classKey: classSection.getSortedClasses()) { Collection<? extends MethodKey> directMethods = classSection.getSortedDirectMethods(classKey); Collection<? extends MethodKey> virtualMethods = classSection.getSortedVirtualMethods(classKey); Iterable<MethodKey> methods = Iterables.concat(directMethods, virtualMethods); for (MethodKey methodKey: methods) { List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = classSection.getTryBlocks(methodKey); Iterable<? extends Instruction> instructions = classSection.getInstructions(methodKey); Iterable<? extends DebugItem> debugItems = classSection.getDebugItems(methodKey); if (instructions != null && stringSection.hasJumboIndexes()) { boolean needsFix = false; for (Instruction instruction: instructions) { if (instruction.getOpcode() == Opcode.CONST_STRING) { if (stringSection.getItemIndex( (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) { needsFix = true; break; } } } if (needsFix) { MutableMethodImplementation mutableMethodImplementation = classSection.makeMutableMethodImplementation(methodKey); fixInstructions(mutableMethodImplementation); instructions = mutableMethodImplementation.getInstructions(); tryBlocks = mutableMethodImplementation.getTryBlocks(); debugItems = mutableMethodImplementation.getDebugItems(); } } int debugItemOffset = writeDebugItem(offsetWriter, debugWriter, classSection.getParameterNames(methodKey), debugItems); int codeItemOffset = writeCodeItem(codeWriter, ehBuf, methodKey, tryBlocks, instructions, debugItemOffset); if (codeItemOffset != -1) { codeOffsets.add(new CodeItemOffset<MethodKey>(methodKey, codeItemOffset)); } } } offsetWriter.align(); codeSectionOffset = offsetWriter.getPosition(); codeWriter.close(); temp.writeTo(offsetWriter); temp.close(); for (CodeItemOffset<MethodKey> codeOffset: codeOffsets) { classSection.setCodeItemOffset(codeOffset.method, codeSectionOffset + codeOffset.codeOffset); } }
Example #23
Source File: DexWriter.java From zjdroid with Apache License 2.0 | 4 votes |
private void writeDebugAndCodeItems(@Nonnull DexDataWriter offsetWriter, @Nonnull DeferredOutputStream temp) throws IOException { ByteArrayOutputStream ehBuf = new ByteArrayOutputStream(); debugSectionOffset = offsetWriter.getPosition(); DebugWriter<StringKey, TypeKey> debugWriter = new DebugWriter<StringKey, TypeKey>(stringSection, typeSection, offsetWriter); DexDataWriter codeWriter = new DexDataWriter(temp, 0); List<CodeItemOffset<MethodKey>> codeOffsets = Lists.newArrayList(); for (ClassKey classKey: classSection.getSortedClasses()) { Collection<? extends MethodKey> directMethods = classSection.getSortedDirectMethods(classKey); Collection<? extends MethodKey> virtualMethods = classSection.getSortedVirtualMethods(classKey); Iterable<MethodKey> methods = Iterables.concat(directMethods, virtualMethods); for (MethodKey methodKey: methods) { List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = classSection.getTryBlocks(methodKey); Iterable<? extends Instruction> instructions = classSection.getInstructions(methodKey); Iterable<? extends DebugItem> debugItems = classSection.getDebugItems(methodKey); if (instructions != null && stringSection.hasJumboIndexes()) { boolean needsFix = false; for (Instruction instruction: instructions) { if (instruction.getOpcode() == Opcode.CONST_STRING) { if (stringSection.getItemIndex( (StringRef)((ReferenceInstruction)instruction).getReference()) >= 65536) { needsFix = true; break; } } } if (needsFix) { MutableMethodImplementation mutableMethodImplementation = classSection.makeMutableMethodImplementation(methodKey); fixInstructions(mutableMethodImplementation); instructions = mutableMethodImplementation.getInstructions(); tryBlocks = mutableMethodImplementation.getTryBlocks(); debugItems = mutableMethodImplementation.getDebugItems(); } } int debugItemOffset = writeDebugItem(offsetWriter, debugWriter, classSection.getParameterNames(methodKey), debugItems); int codeItemOffset = writeCodeItem(codeWriter, ehBuf, methodKey, tryBlocks, instructions, debugItemOffset); if (codeItemOffset != -1) { codeOffsets.add(new CodeItemOffset<MethodKey>(methodKey, codeItemOffset)); } } } offsetWriter.align(); codeSectionOffset = offsetWriter.getPosition(); codeWriter.close(); temp.writeTo(offsetWriter); temp.close(); for (CodeItemOffset<MethodKey> codeOffset: codeOffsets) { classSection.setCodeItemOffset(codeOffset.method, codeSectionOffset + codeOffset.codeOffset); } }
Example #24
Source File: RewriterModule.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull public Rewriter<DebugItem> getDebugItemRewriter(@Nonnull Rewriters rewriters) { return new DebugItemRewriter(rewriters); }
Example #25
Source File: DexBackedMethodImplementation.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() { return getDebugInfo(); }
Example #26
Source File: MethodDefinition.java From atlas with Apache License 2.0 | 4 votes |
private void addDebugInfo(final List<MethodItem> methodItems) { for (DebugItem debugItem : methodImpl.getDebugItems()) { methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); } }
Example #27
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 4 votes |
private void addDebugInfo(final List<MethodItem> methodItems) { for (DebugItem debugItem: methodImpl.getDebugItems()) { methodItems.add(DebugMethodItem.build(registerFormatter, debugItem)); } }
Example #28
Source File: BackSmaliMain.java From SimpleSmali with Apache License 2.0 | 4 votes |
private static LocalInfo buildLocalInfo(DexBackedMethod dexBackedMethod) { LocalInfo info = new LocalInfo(); int insSize = getInsSize(dexBackedMethod); List<? extends MethodParameter> parameters = dexBackedMethod.getParameters(); int argReg = getRegisterSize(dexBackedMethod) - insSize;//reg = resiter - ins // System.out.println("registerCount:" + methodImplementation.getRegisterCount()); boolean isStatic = AccessFlags.STATIC.isSet(dexBackedMethod.getAccessFlags()); if (!isStatic) { info.setName(argReg, "this"); argReg++; } for (MethodParameter p : parameters) { int reg = argReg; if ("D".equals(p.getType()) || "J".equals(p.getType())) { argReg += 2; } else { argReg += 1; } if (!Strings.isNullOrEmpty(p.getName())) { info.setName(reg, p.getName()); } // System.out.println("pararms:====" + p.getName() + ",paramRegister:" + reg); } DexBackedMethodImplementation implementation = dexBackedMethod.getImplementation(); if (implementation != null) { Iterable<? extends DebugItem> debugItems = implementation.getDebugItems(); for (DebugItem debugItem : debugItems) { if (debugItem.getDebugItemType() == DebugItemType.START_LOCAL) { // System.out.println( // "debugItemStartLocal:====" + ((ImmutableStartLocal) debugItem).getName() + ",register:" // + ((ImmutableStartLocal) debugItem).getRegister()); info.setName(((ImmutableStartLocal) debugItem).getRegister(), ((ImmutableStartLocal) debugItem).getName()); } if (debugItem.getDebugItemType() == DebugItemType.START_LOCAL_EXTENDED) { // System.out.println( // "debugItemStartLocalExt:====" + ((ImmutableStartLocal) debugItem).getName() + ",register:" // + ((ImmutableStartLocal) debugItem).getRegister()); info.setName(((ImmutableStartLocal) debugItem).getRegister(), ((ImmutableStartLocal) debugItem).getName()); } } } return info; }
Example #29
Source File: MethodImplementation.java From HeyGirl with Apache License 2.0 | 2 votes |
/** * Get a list of debug items for this method. * * This generally matches the semantics of the debug_info_item in the dex specification, although in an easier to * digest form. * * The addresses of the DebugItems in the returned list will be in non-descending order. * * @return A list of DebugInfo items */ @Nonnull Iterable<? extends DebugItem> getDebugItems();
Example #30
Source File: MethodImplementation.java From ZjDroid with Apache License 2.0 | 2 votes |
/** * Get a list of debug items for this method. * * This generally matches the semantics of the debug_info_item in the dex specification, although in an easier to * digest form. * * The addresses of the DebugItems in the returned list will be in non-descending order. * * @return A list of DebugInfo items */ @Nonnull Iterable<? extends DebugItem> getDebugItems();