mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 00:24:34 +02:00
Add support in dexlib2 for debug info
This commit is contained in:
parent
c307c1887d
commit
9c60ef2a10
49
dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java
Normal file
49
dexlib2/src/main/java/org/jf/dexlib2/DebugItemType.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2;
|
||||
|
||||
public abstract class DebugItemType {
|
||||
// The debug items that directly correspond with one of the dexlib2.iface.debug interfaces
|
||||
public static final int START_LOCAL = 0x03;
|
||||
public static final int END_LOCAL = 0x05;
|
||||
public static final int RESTART_LOCAL = 0x06;
|
||||
public static final int PROLOGUE_END = 0x07;
|
||||
public static final int EPILOGUE_BEGIN = 0x08;
|
||||
public static final int SET_SOURCE_FILE = 0x09;
|
||||
public static final int LINE_NUMBER = 0x0a;
|
||||
|
||||
// Other items, which are typically handled internally
|
||||
public static final int END_SEQUENCE = 0x00;
|
||||
public static final int ADVANCE_PC = 0x01;
|
||||
public static final int ADVANCE_LINE = 0x02;
|
||||
public static final int START_LOCAL_EXTENDED = 0x04;
|
||||
}
|
@ -142,7 +142,7 @@ public class DexBackedMethod implements Method {
|
||||
@Override
|
||||
public MethodImplementation getImplementation() {
|
||||
if (codeOffset > 0) {
|
||||
return new DexBackedMethodImplementation(dexBuf, codeOffset);
|
||||
return new DexBackedMethodImplementation(dexBuf, this, codeOffset);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -33,9 +33,11 @@ package org.jf.dexlib2.dexbacked;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.dexbacked.instruction.DexBackedInstruction;
|
||||
import org.jf.dexlib2.dexbacked.util.DebugItemList;
|
||||
import org.jf.dexlib2.dexbacked.util.FixedSizeList;
|
||||
import org.jf.dexlib2.iface.MethodImplementation;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
import org.jf.util.AlignmentUtils;
|
||||
|
||||
@ -43,8 +45,10 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//TODO: consider making this extends DexBackedMethod, rather than passing in the associated DexBackedMethod
|
||||
public class DexBackedMethodImplementation implements MethodImplementation {
|
||||
@Nonnull public final DexBuffer dexBuf;
|
||||
@Nonnull public final DexBackedMethod method;
|
||||
private final int codeOffset;
|
||||
|
||||
public final int registerCount;
|
||||
@ -52,14 +56,17 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
||||
|
||||
// code_item offsets
|
||||
private static final int TRIES_SIZE_OFFSET = 6;
|
||||
private static final int DEBUG_OFFSET_OFFSET = 8;
|
||||
private static final int INSTRUCTIONS_SIZE_OFFSET = 12;
|
||||
private static final int INSTRUCTIONS_START_OFFSET = 16;
|
||||
|
||||
private static final int TRY_ITEM_SIZE = 8;
|
||||
|
||||
public DexBackedMethodImplementation(@Nonnull DexBuffer dexBuf,
|
||||
@Nonnull DexBackedMethod method,
|
||||
int codeOffset) {
|
||||
this.dexBuf = dexBuf;
|
||||
this.method = method;
|
||||
this.codeOffset = codeOffset;
|
||||
this.registerCount = dexBuf.readUshort(codeOffset);
|
||||
|
||||
@ -97,6 +104,16 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<? extends DebugItem> getDebugItems() {
|
||||
final int debugInfoOffset = dexBuf.readSmallUint(codeOffset + DEBUG_OFFSET_OFFSET);
|
||||
if (debugInfoOffset > 0) {
|
||||
return new DebugItemList(dexBuf, debugInfoOffset, method);
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ImmutableList<? extends Instruction> buildInstructionList() {
|
||||
// instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
|
||||
|
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.dexbacked.util;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.dexbacked.DexBuffer;
|
||||
import org.jf.dexlib2.dexbacked.DexReader;
|
||||
import org.jf.dexlib2.iface.Method;
|
||||
import org.jf.dexlib2.iface.MethodImplementation;
|
||||
import org.jf.dexlib2.iface.MethodParameter;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.debug.EndLocal;
|
||||
import org.jf.dexlib2.iface.debug.LocalInfo;
|
||||
import org.jf.dexlib2.immutable.debug.*;
|
||||
import org.jf.util.ExceptionWithContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class DebugItemList extends VariableSizeListWithContext<DebugItem> {
|
||||
@Nonnull public final DexBuffer dexBuf;
|
||||
private final int debugInfoOffset;
|
||||
@Nonnull private final Method method;
|
||||
@Nonnull private final MethodImplementation methodImpl;
|
||||
|
||||
public DebugItemList(@Nonnull DexBuffer dexBuf,
|
||||
int debugInfoOffset,
|
||||
@Nonnull Method method) {
|
||||
this.dexBuf = dexBuf;
|
||||
this.debugInfoOffset = debugInfoOffset;
|
||||
this.method = method;
|
||||
MethodImplementation methodImpl = method.getImplementation();
|
||||
if (methodImpl == null) {
|
||||
throw new ExceptionWithContext("Creating a DebugItemList for a method with no implementation. WTF?");
|
||||
}
|
||||
this.methodImpl = methodImpl;
|
||||
}
|
||||
|
||||
private static final LocalInfo EMPTY_LOCAL_INFO = new LocalInfo() {
|
||||
@Nullable @Override public String getName() { return null; }
|
||||
@Nullable @Override public String getType() { return null; }
|
||||
@Nullable @Override public String getSignature() { return null; }
|
||||
};
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator listIterator() {
|
||||
DexReader initialReader = dexBuf.readerAt(debugInfoOffset);
|
||||
// TODO: this unsigned value could legitimally be > MAX_INT
|
||||
final int lineNumberStart = initialReader.readSmallUleb128();
|
||||
int registerCount = methodImpl.getRegisterCount();
|
||||
|
||||
//TODO: does dalvik allow references to invalid registers?
|
||||
final LocalInfo[] locals = new LocalInfo[registerCount];
|
||||
Arrays.fill(locals, EMPTY_LOCAL_INFO);
|
||||
|
||||
List<? extends MethodParameter> parameters = method.getParameters();
|
||||
|
||||
//TODO: need to add parameter info to MethodParameter. Is there some way we could use the same reader for that?
|
||||
int debugParametersSize = initialReader.readSmallUleb128();
|
||||
if (debugParametersSize > parameters.size()) {
|
||||
//TODO: make sure that dalvik doesn't allow this
|
||||
throw new ExceptionWithContext("DebugInfoItem has more parameters than the method itself does. WTF?");
|
||||
}
|
||||
for (int i=0; i<parameters.size(); i++) {
|
||||
// TODO: look for a signature annotation on the... method? parameter?, and get the parameter signature
|
||||
final MethodParameter methodParameter = parameters.get(i);
|
||||
final String parameterName = dexBuf.getOptionalString(initialReader.readSmallUleb128() - 1);
|
||||
|
||||
locals[i] = new LocalInfo() {
|
||||
@Nullable @Override public String getName() { return parameterName; }
|
||||
@Nullable @Override public String getType() { return methodParameter.getType(); }
|
||||
@Nullable @Override public String getSignature() { return null; }
|
||||
};
|
||||
}
|
||||
|
||||
if (parameters.size() < registerCount) {
|
||||
// we need to push the parameter locals back to their appropriate register
|
||||
int localIndex = registerCount-1;
|
||||
for (int i=parameters.size()-1; i>-1; i--) {
|
||||
LocalInfo currentLocal = locals[i];
|
||||
locals[localIndex] = currentLocal;
|
||||
locals[i] = EMPTY_LOCAL_INFO;
|
||||
String type = currentLocal.getType();
|
||||
localIndex--;
|
||||
if (type != null && (type.equals("J") || type.equals("D"))) {
|
||||
localIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Iterator(dexBuf, initialReader.getOffset()) {
|
||||
private boolean finished = false;
|
||||
private int codeAddress = 0;
|
||||
private int lineNumber = lineNumberStart;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected DebugItem readItem(@Nonnull DexReader reader, int index) {
|
||||
if (finished) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
while (true) {
|
||||
int next = reader.readUbyte();
|
||||
switch (next) {
|
||||
case DebugItemType.END_SEQUENCE: {
|
||||
finished = true;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
case DebugItemType.ADVANCE_PC: {
|
||||
int addressDiff = reader.readSmallUleb128();
|
||||
codeAddress += addressDiff;
|
||||
continue;
|
||||
}
|
||||
case DebugItemType.ADVANCE_LINE: {
|
||||
int lineDiff = reader.readSleb128();
|
||||
lineNumber += lineDiff;
|
||||
continue;
|
||||
}
|
||||
case DebugItemType.START_LOCAL: {
|
||||
int register = reader.readSmallUleb128();
|
||||
String name = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
||||
String type = dexBuf.getOptionalType(reader.readSmallUleb128() - 1);
|
||||
ImmutableStartLocal startLocal =
|
||||
new ImmutableStartLocal(codeAddress, register, name, type, null);
|
||||
locals[register] = startLocal;
|
||||
return startLocal;
|
||||
}
|
||||
case DebugItemType.START_LOCAL_EXTENDED: {
|
||||
int register = reader.readSmallUleb128();
|
||||
String name = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
||||
String type = dexBuf.getOptionalType(reader.readSmallUleb128() - 1);
|
||||
String signature = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
||||
ImmutableStartLocal startLocal =
|
||||
new ImmutableStartLocal(codeAddress, register, name, type, signature);
|
||||
locals[register] = startLocal;
|
||||
return startLocal;
|
||||
}
|
||||
case DebugItemType.END_LOCAL: {
|
||||
int register = reader.readSmallUleb128();
|
||||
LocalInfo localInfo = locals[register];
|
||||
boolean replaceLocalInTable = true;
|
||||
if (localInfo instanceof EndLocal) {
|
||||
localInfo = EMPTY_LOCAL_INFO;
|
||||
// don't replace the local info in locals. The new EndLocal won't have any info at all,
|
||||
// and we dont want to wipe out what's there, so that it is available for a subsequent
|
||||
// RestartLocal
|
||||
replaceLocalInTable = false;
|
||||
}
|
||||
ImmutableEndLocal endLocal =
|
||||
new ImmutableEndLocal(codeAddress, register, localInfo.getName(),
|
||||
localInfo.getType(), localInfo.getSignature());
|
||||
if (replaceLocalInTable) {
|
||||
locals[register] = endLocal;
|
||||
}
|
||||
return endLocal;
|
||||
}
|
||||
case DebugItemType.RESTART_LOCAL: {
|
||||
int register = reader.readSmallUleb128();
|
||||
LocalInfo localInfo = locals[register];
|
||||
ImmutableRestartLocal restartLocal =
|
||||
new ImmutableRestartLocal(codeAddress, register, localInfo.getName(),
|
||||
localInfo.getType(), localInfo.getSignature());
|
||||
locals[register] = restartLocal;
|
||||
return restartLocal;
|
||||
}
|
||||
case DebugItemType.PROLOGUE_END: {
|
||||
return new ImmutablePrologueEnd(codeAddress);
|
||||
}
|
||||
case DebugItemType.EPILOGUE_BEGIN: {
|
||||
return new ImmutableEpilogueBegin(codeAddress);
|
||||
}
|
||||
case DebugItemType.SET_SOURCE_FILE: {
|
||||
String sourceFile = dexBuf.getOptionalString(reader.readSmallUleb128() - 1);
|
||||
return new ImmutableSetSourceFile(codeAddress, sourceFile);
|
||||
}
|
||||
default: {
|
||||
int base = ((next & 0xFF) - 0x0A);
|
||||
codeAddress += base / 15;
|
||||
lineNumber += (base % 15) - 4;
|
||||
return new ImmutableLineNumber(codeAddress, lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void skipItem(@Nonnull DexReader reader, int index) {
|
||||
super.skipItem(reader, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkBounds(int index) {
|
||||
// skip the bounds check here. We'll throw NoSuchElementException directly from readItem
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -85,19 +85,21 @@ public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||
@Override public boolean hasNext() { return index < size(); }
|
||||
@Override public int nextIndex() { return index; }
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T next() {
|
||||
protected void checkBounds(int index) {
|
||||
if (index >= size()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T next() {
|
||||
checkBounds(index);
|
||||
return readItem(reader, index++);
|
||||
}
|
||||
|
||||
public void skip() {
|
||||
if (index >= size()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
checkBounds(index);
|
||||
skipItem(reader, index++);
|
||||
}
|
||||
}
|
||||
|
@ -95,19 +95,21 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
|
||||
@Override public boolean hasNext() { return index < size(); }
|
||||
@Override public int nextIndex() { return index; }
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T next() {
|
||||
protected void checkBounds(int index) {
|
||||
if (index >= size()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T next() {
|
||||
checkBounds(index);
|
||||
return readItem(reader, index++);
|
||||
}
|
||||
|
||||
public void skip() {
|
||||
if (index >= size()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
checkBounds(index);
|
||||
skipItem(reader, index++);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
package org.jf.dexlib2.iface;
|
||||
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -40,4 +41,5 @@ public interface MethodImplementation {
|
||||
int getRegisterCount();
|
||||
@Nonnull List<? extends Instruction> getInstructions();
|
||||
@Nonnull List<? extends TryBlock> getTryBlocks();
|
||||
@Nonnull List<? extends DebugItem> getDebugItems();
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface DebugItem {
|
||||
int getDebugItemType();
|
||||
int getCodeAddress();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface EndLocal extends DebugItem, LocalInfo {
|
||||
int getRegister();
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface EpilogueBegin extends DebugItem {
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface LineNumber extends DebugItem {
|
||||
int getLineNumber();
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface LocalInfo {
|
||||
@Nullable String getName();
|
||||
@Nullable String getType();
|
||||
@Nullable String getSignature();
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface PrologueEnd extends DebugItem {
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface RestartLocal extends DebugItem, LocalInfo {
|
||||
int getRegister();
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface SetSourceFile extends DebugItem {
|
||||
@Nullable String getSourceFile();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.iface.debug;
|
||||
|
||||
public interface StartLocal extends DebugItem, LocalInfo {
|
||||
int getRegister();
|
||||
}
|
@ -35,7 +35,9 @@ import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.iface.MethodImplementation;
|
||||
import org.jf.dexlib2.iface.TryBlock;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
import org.jf.dexlib2.immutable.debug.ImmutableDebugItem;
|
||||
import org.jf.dexlib2.immutable.instruction.ImmutableInstruction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -46,21 +48,26 @@ public class ImmutableMethodImplementation implements MethodImplementation {
|
||||
public final int registerCount;
|
||||
@Nonnull public final ImmutableList<? extends ImmutableInstruction> instructions;
|
||||
@Nonnull public final ImmutableList<? extends ImmutableTryBlock> tryBlocks;
|
||||
@Nonnull public final ImmutableList<? extends ImmutableDebugItem> debugItems;
|
||||
|
||||
public ImmutableMethodImplementation(int registerCount,
|
||||
@Nullable List<? extends Instruction> instructions,
|
||||
@Nullable List<? extends TryBlock> tryBlocks) {
|
||||
@Nullable List<? extends TryBlock> tryBlocks,
|
||||
@Nullable List<? extends DebugItem> debugItems) {
|
||||
this.registerCount = registerCount;
|
||||
this.instructions = ImmutableInstruction.immutableListOf(instructions);
|
||||
this.tryBlocks = ImmutableTryBlock.immutableListOf(tryBlocks);
|
||||
this.debugItems = ImmutableDebugItem.immutableListOf(debugItems);
|
||||
}
|
||||
|
||||
public ImmutableMethodImplementation(int registerCount,
|
||||
@Nullable ImmutableList<? extends ImmutableInstruction> instructions,
|
||||
@Nullable ImmutableList<? extends ImmutableTryBlock> tryBlocks) {
|
||||
@Nullable ImmutableList<? extends ImmutableTryBlock> tryBlocks,
|
||||
@Nullable ImmutableList<? extends ImmutableDebugItem> debugItems) {
|
||||
this.registerCount = registerCount;
|
||||
this.instructions = Objects.firstNonNull(instructions, ImmutableList.<ImmutableInstruction>of());
|
||||
this.tryBlocks = Objects.firstNonNull(tryBlocks, ImmutableList.<ImmutableTryBlock>of());
|
||||
this.debugItems = Objects.firstNonNull(debugItems, ImmutableList.<ImmutableDebugItem>of());
|
||||
}
|
||||
|
||||
public static ImmutableMethodImplementation of(MethodImplementation methodImplementation) {
|
||||
@ -70,10 +77,12 @@ public class ImmutableMethodImplementation implements MethodImplementation {
|
||||
return new ImmutableMethodImplementation(
|
||||
methodImplementation.getRegisterCount(),
|
||||
methodImplementation.getInstructions(),
|
||||
methodImplementation.getTryBlocks());
|
||||
methodImplementation.getTryBlocks(),
|
||||
methodImplementation.getDebugItems());
|
||||
}
|
||||
|
||||
@Override public int getRegisterCount() { return 0; }
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableInstruction> getInstructions() { return instructions; }
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableTryBlock> getTryBlocks() { return tryBlocks; }
|
||||
@Nonnull @Override public ImmutableList<? extends ImmutableDebugItem> getDebugItems() { return debugItems; }
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.*;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
import org.jf.util.ExceptionWithContext;
|
||||
import org.jf.util.ImmutableListConverter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ImmutableDebugItem implements DebugItem {
|
||||
public final int codeAddress;
|
||||
|
||||
public ImmutableDebugItem(int codeAddress) {
|
||||
this.codeAddress = codeAddress;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableDebugItem of(DebugItem debugItem) {
|
||||
if (debugItem instanceof ImmutableDebugItem) {
|
||||
return (ImmutableDebugItem)debugItem;
|
||||
}
|
||||
switch (debugItem.getDebugItemType()) {
|
||||
case DebugItemType.START_LOCAL:
|
||||
return ImmutableStartLocal.of((StartLocal)debugItem);
|
||||
case DebugItemType.END_LOCAL:
|
||||
return ImmutableEndLocal.of((EndLocal)debugItem);
|
||||
case DebugItemType.RESTART_LOCAL:
|
||||
return ImmutableRestartLocal.of((RestartLocal)debugItem);
|
||||
case DebugItemType.PROLOGUE_END:
|
||||
return ImmutablePrologueEnd.of((PrologueEnd)debugItem);
|
||||
case DebugItemType.EPILOGUE_BEGIN:
|
||||
return ImmutableEpilogueBegin.of((EpilogueBegin)debugItem);
|
||||
case DebugItemType.SET_SOURCE_FILE:
|
||||
return ImmutableSetSourceFile.of((SetSourceFile)debugItem);
|
||||
case DebugItemType.LINE_NUMBER:
|
||||
return ImmutableLineNumber.of((LineNumber)debugItem);
|
||||
default:
|
||||
throw new ExceptionWithContext("Invalid debug item type: %d", debugItem.getDebugItemType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override public int getCodeAddress() { return codeAddress; }
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableList<ImmutableDebugItem> immutableListOf(@Nullable List<? extends DebugItem> list) {
|
||||
return CONVERTER.convert(list);
|
||||
}
|
||||
|
||||
private static final ImmutableListConverter<ImmutableDebugItem, DebugItem> CONVERTER =
|
||||
new ImmutableListConverter<ImmutableDebugItem, DebugItem>() {
|
||||
@Override
|
||||
protected boolean isImmutable(DebugItem item) {
|
||||
return item instanceof ImmutableDebugItem;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ImmutableDebugItem makeImmutable(DebugItem item) {
|
||||
return ImmutableDebugItem.of(item);
|
||||
}
|
||||
};
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.EndLocal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImmutableEndLocal extends ImmutableDebugItem implements EndLocal {
|
||||
public final int register;
|
||||
@Nullable public final String name;
|
||||
@Nullable public final String type;
|
||||
@Nullable public final String signature;
|
||||
|
||||
public ImmutableEndLocal(int codeAddress,
|
||||
int register) {
|
||||
super(codeAddress);
|
||||
this.register = register;
|
||||
this.name = null;
|
||||
this.type = null;
|
||||
this.signature = null;
|
||||
}
|
||||
|
||||
public ImmutableEndLocal(int codeAddress,
|
||||
int register,
|
||||
@Nullable String name,
|
||||
@Nullable String type,
|
||||
@Nullable String signature) {
|
||||
super(codeAddress);
|
||||
this.register = register;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableEndLocal of(@Nonnull EndLocal endLocal) {
|
||||
if (endLocal instanceof ImmutableEndLocal) {
|
||||
return (ImmutableEndLocal)endLocal;
|
||||
}
|
||||
return new ImmutableEndLocal(
|
||||
endLocal.getCodeAddress(),
|
||||
endLocal.getRegister(),
|
||||
endLocal.getType(),
|
||||
endLocal.getName(),
|
||||
endLocal.getSignature());
|
||||
}
|
||||
|
||||
@Override public int getRegister() { return register; }
|
||||
@Nullable @Override public String getName() { return name; }
|
||||
@Nullable @Override public String getType() { return type; }
|
||||
@Nullable @Override public String getSignature() { return signature; }
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.END_LOCAL; }
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.EpilogueBegin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ImmutableEpilogueBegin extends ImmutableDebugItem implements EpilogueBegin {
|
||||
public ImmutableEpilogueBegin(int codeAddress) {
|
||||
super(codeAddress);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableEpilogueBegin of(@Nonnull EpilogueBegin epilogueBegin) {
|
||||
if (epilogueBegin instanceof ImmutableEpilogueBegin) {
|
||||
return (ImmutableEpilogueBegin)epilogueBegin;
|
||||
}
|
||||
return new ImmutableEpilogueBegin(epilogueBegin.getCodeAddress());
|
||||
}
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.EPILOGUE_BEGIN; }
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.LineNumber;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ImmutableLineNumber extends ImmutableDebugItem implements LineNumber {
|
||||
public final int lineNumber;
|
||||
|
||||
public ImmutableLineNumber(int codeAddress,
|
||||
int lineNumber) {
|
||||
super(codeAddress);
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableLineNumber of(@Nonnull LineNumber lineNumber) {
|
||||
if (lineNumber instanceof ImmutableLineNumber) {
|
||||
return (ImmutableLineNumber)lineNumber;
|
||||
}
|
||||
return new ImmutableLineNumber(
|
||||
lineNumber.getCodeAddress(),
|
||||
lineNumber.getLineNumber());
|
||||
}
|
||||
|
||||
@Override public int getLineNumber() { return lineNumber; }
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.LINE_NUMBER; }
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.PrologueEnd;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ImmutablePrologueEnd extends ImmutableDebugItem implements PrologueEnd {
|
||||
public ImmutablePrologueEnd(int codeAddress) {
|
||||
super(codeAddress);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutablePrologueEnd of(@Nonnull PrologueEnd prologueEnd) {
|
||||
if (prologueEnd instanceof ImmutablePrologueEnd) {
|
||||
return (ImmutablePrologueEnd)prologueEnd;
|
||||
}
|
||||
return new ImmutablePrologueEnd(prologueEnd.getCodeAddress());
|
||||
}
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.PROLOGUE_END; }
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.RestartLocal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImmutableRestartLocal extends ImmutableDebugItem implements RestartLocal {
|
||||
public final int register;
|
||||
@Nullable public final String name;
|
||||
@Nullable public final String type;
|
||||
@Nullable public final String signature;
|
||||
|
||||
public ImmutableRestartLocal(int codeAddress,
|
||||
int register) {
|
||||
super(codeAddress);
|
||||
this.register = register;
|
||||
this.name = null;
|
||||
this.type = null;
|
||||
this.signature = null;
|
||||
}
|
||||
|
||||
public ImmutableRestartLocal(int codeAddress,
|
||||
int register,
|
||||
@Nullable String name,
|
||||
@Nullable String type,
|
||||
@Nullable String signature) {
|
||||
super(codeAddress);
|
||||
this.register = register;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableRestartLocal of(@Nonnull RestartLocal restartLocal) {
|
||||
if (restartLocal instanceof ImmutableRestartLocal) {
|
||||
return (ImmutableRestartLocal)restartLocal;
|
||||
}
|
||||
return new ImmutableRestartLocal(
|
||||
restartLocal.getCodeAddress(),
|
||||
restartLocal.getRegister(),
|
||||
restartLocal.getType(),
|
||||
restartLocal.getName(),
|
||||
restartLocal.getSignature());
|
||||
}
|
||||
|
||||
@Override public int getRegister() { return register; }
|
||||
@Nullable @Override public String getName() { return name; }
|
||||
@Nullable @Override public String getType() { return type; }
|
||||
@Nullable @Override public String getSignature() { return signature; }
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.RESTART_LOCAL; }
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.SetSourceFile;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImmutableSetSourceFile extends ImmutableDebugItem implements SetSourceFile {
|
||||
@Nullable public final String sourceFile;
|
||||
|
||||
public ImmutableSetSourceFile(int codeAddress,
|
||||
@Nullable String sourceFile) {
|
||||
super(codeAddress);
|
||||
this.sourceFile = sourceFile;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableSetSourceFile of (@Nonnull SetSourceFile setSourceFile) {
|
||||
if (setSourceFile instanceof ImmutableSetSourceFile) {
|
||||
return (ImmutableSetSourceFile)setSourceFile;
|
||||
}
|
||||
return new ImmutableSetSourceFile(
|
||||
setSourceFile.getCodeAddress(),
|
||||
setSourceFile.getSourceFile());
|
||||
}
|
||||
|
||||
@Nullable @Override public String getSourceFile() { return sourceFile; }
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.SET_SOURCE_FILE; }
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2012, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib2.immutable.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.iface.debug.StartLocal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImmutableStartLocal extends ImmutableDebugItem implements StartLocal {
|
||||
public final int register;
|
||||
@Nullable public final String name;
|
||||
@Nullable public final String type;
|
||||
@Nullable public final String signature;
|
||||
|
||||
public ImmutableStartLocal(int codeAddress,
|
||||
int register,
|
||||
@Nullable String name,
|
||||
@Nullable String type,
|
||||
@Nullable String signature) {
|
||||
super(codeAddress);
|
||||
this.register = register;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ImmutableStartLocal of(@Nonnull StartLocal startLocal) {
|
||||
if (startLocal instanceof ImmutableStartLocal) {
|
||||
return (ImmutableStartLocal)startLocal;
|
||||
}
|
||||
return new ImmutableStartLocal(
|
||||
startLocal.getCodeAddress(),
|
||||
startLocal.getRegister(),
|
||||
startLocal.getType(),
|
||||
startLocal.getName(),
|
||||
startLocal.getSignature());
|
||||
}
|
||||
|
||||
@Override public int getRegister() { return register; }
|
||||
@Nullable @Override public String getName() { return name; }
|
||||
@Nullable @Override public String getType() { return type; }
|
||||
@Nullable @Override public String getSignature() { return signature; }
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.START_LOCAL; }
|
||||
}
|
@ -70,7 +70,7 @@ public class InstructionOffsetMapTest {
|
||||
/*24: 0x32*/ new ImmutableInstruction51l(Opcode.CONST_WIDE, 32, 33),
|
||||
/*25: 0x37*/ new ImmutableInstruction10t(Opcode.GOTO, 1)
|
||||
);
|
||||
ImmutableMethodImplementation impl = new ImmutableMethodImplementation(33, instructions, null);
|
||||
ImmutableMethodImplementation impl = new ImmutableMethodImplementation(33, instructions, null, null);
|
||||
InstructionOffsetMap instructionOffsetMap = new InstructionOffsetMap(impl);
|
||||
|
||||
int[] expectedOffsets = new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11,
|
||||
|
Loading…
x
Reference in New Issue
Block a user