mirror of
https://github.com/revanced/smali.git
synced 2025-05-20 16:07:05 +02:00
Fix DebugItems in the new builder stuff
This commit is contained in:
parent
edd961477e
commit
84be16bf51
@ -33,14 +33,12 @@ package org.jf.dexlib2.builder;
|
|||||||
|
|
||||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class BuilderDebugItem implements DebugItem {
|
public abstract class BuilderDebugItem implements DebugItem {
|
||||||
@Nullable MethodLocation location;
|
@Nullable MethodLocation location;
|
||||||
|
|
||||||
public BuilderDebugItem(@Nonnull MethodLocation location) {
|
public BuilderDebugItem() {
|
||||||
this.location = location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getCodeAddress() {
|
@Override public int getCodeAddress() {
|
||||||
|
@ -183,31 +183,31 @@ public class MethodLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addLineNumber(int lineNumber) {
|
public void addLineNumber(int lineNumber) {
|
||||||
debugItems.add(new BuilderLineNumber(this, lineNumber));
|
getDebugItems().add(new BuilderLineNumber(lineNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStartLocal(int registerNumber, @Nullable StringReference name, @Nullable TypeReference type,
|
public void addStartLocal(int registerNumber, @Nullable StringReference name, @Nullable TypeReference type,
|
||||||
@Nullable StringReference signature) {
|
@Nullable StringReference signature) {
|
||||||
debugItems.add(new BuilderStartLocal(this, registerNumber, name, type, signature));
|
getDebugItems().add(new BuilderStartLocal(registerNumber, name, type, signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEndLocal(int registerNumber) {
|
public void addEndLocal(int registerNumber) {
|
||||||
debugItems.add(new BuilderEndLocal(this, registerNumber));
|
getDebugItems().add(new BuilderEndLocal(registerNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRestartLocal(int registerNumber) {
|
public void addRestartLocal(int registerNumber) {
|
||||||
debugItems.add(new BuilderRestartLocal(this, registerNumber));
|
getDebugItems().add(new BuilderRestartLocal(registerNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPrologue() {
|
public void addPrologue() {
|
||||||
debugItems.add(new BuilderPrologueEnd(this));
|
getDebugItems().add(new BuilderPrologueEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEpilogue() {
|
public void addEpilogue() {
|
||||||
debugItems.add(new BuilderEpilogueBegin(this));
|
getDebugItems().add(new BuilderEpilogueBegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSetSourceFile(@Nullable BuilderStringReference sourceFile) {
|
public void addSetSourceFile(@Nullable BuilderStringReference sourceFile) {
|
||||||
debugItems.add(new BuilderSetSourceFile(this, sourceFile));
|
getDebugItems().add(new BuilderSetSourceFile(sourceFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
int debugCodeAddress = debugItem.getCodeAddress();
|
int debugCodeAddress = debugItem.getCodeAddress();
|
||||||
int locationIndex = mapCodeAddressToIndex(codeAddressToIndex, debugCodeAddress);
|
int locationIndex = mapCodeAddressToIndex(codeAddressToIndex, debugCodeAddress);
|
||||||
MethodLocation debugLocation = instructionList.get(locationIndex);
|
MethodLocation debugLocation = instructionList.get(locationIndex);
|
||||||
BuilderDebugItem builderDebugItem = convertDebugItem(debugLocation, debugItem);
|
BuilderDebugItem builderDebugItem = convertDebugItem(debugItem);
|
||||||
debugLocation.getDebugItems().add(builderDebugItem);
|
debugLocation.getDebugItems().add(builderDebugItem);
|
||||||
builderDebugItem.location = debugLocation;
|
builderDebugItem.location = debugLocation;
|
||||||
}
|
}
|
||||||
@ -909,32 +909,32 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private BuilderDebugItem convertDebugItem(@Nonnull MethodLocation location, @Nonnull DebugItem debugItem) {
|
private BuilderDebugItem convertDebugItem(@Nonnull DebugItem debugItem) {
|
||||||
switch (debugItem.getDebugItemType()) {
|
switch (debugItem.getDebugItemType()) {
|
||||||
case DebugItemType.START_LOCAL: {
|
case DebugItemType.START_LOCAL: {
|
||||||
StartLocal startLocal = (StartLocal)debugItem;
|
StartLocal startLocal = (StartLocal)debugItem;
|
||||||
return new BuilderStartLocal(location, startLocal.getRegister(), startLocal.getNameReference(),
|
return new BuilderStartLocal(startLocal.getRegister(), startLocal.getNameReference(),
|
||||||
startLocal.getTypeReference(), startLocal.getSignatureReference());
|
startLocal.getTypeReference(), startLocal.getSignatureReference());
|
||||||
}
|
}
|
||||||
case DebugItemType.END_LOCAL: {
|
case DebugItemType.END_LOCAL: {
|
||||||
EndLocal endLocal = (EndLocal)debugItem;
|
EndLocal endLocal = (EndLocal)debugItem;
|
||||||
return new BuilderEndLocal(location, endLocal.getRegister());
|
return new BuilderEndLocal(endLocal.getRegister());
|
||||||
}
|
}
|
||||||
case DebugItemType.RESTART_LOCAL: {
|
case DebugItemType.RESTART_LOCAL: {
|
||||||
RestartLocal restartLocal = (RestartLocal)debugItem;
|
RestartLocal restartLocal = (RestartLocal)debugItem;
|
||||||
return new BuilderRestartLocal(location, restartLocal.getRegister());
|
return new BuilderRestartLocal(restartLocal.getRegister());
|
||||||
}
|
}
|
||||||
case DebugItemType.PROLOGUE_END:
|
case DebugItemType.PROLOGUE_END:
|
||||||
return new BuilderPrologueEnd(location);
|
return new BuilderPrologueEnd();
|
||||||
case DebugItemType.EPILOGUE_BEGIN:
|
case DebugItemType.EPILOGUE_BEGIN:
|
||||||
return new BuilderEpilogueBegin(location);
|
return new BuilderEpilogueBegin();
|
||||||
case DebugItemType.LINE_NUMBER: {
|
case DebugItemType.LINE_NUMBER: {
|
||||||
LineNumber lineNumber = (LineNumber)debugItem;
|
LineNumber lineNumber = (LineNumber)debugItem;
|
||||||
return new BuilderLineNumber(location, lineNumber.getLineNumber());
|
return new BuilderLineNumber(lineNumber.getLineNumber());
|
||||||
}
|
}
|
||||||
case DebugItemType.SET_SOURCE_FILE: {
|
case DebugItemType.SET_SOURCE_FILE: {
|
||||||
SetSourceFile setSourceFile = (SetSourceFile)debugItem;
|
SetSourceFile setSourceFile = (SetSourceFile)debugItem;
|
||||||
return new BuilderSetSourceFile(location, setSourceFile.getSourceFileReference());
|
return new BuilderSetSourceFile(setSourceFile.getSourceFileReference());
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new ExceptionWithContext("Invalid debug item type: " + debugItem.getDebugItemType());
|
throw new ExceptionWithContext("Invalid debug item type: " + debugItem.getDebugItemType());
|
||||||
|
@ -33,18 +33,14 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.EndLocal;
|
import org.jf.dexlib2.iface.debug.EndLocal;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BuilderEndLocal extends BuilderDebugItem implements EndLocal {
|
public class BuilderEndLocal extends BuilderDebugItem implements EndLocal {
|
||||||
private final int register;
|
private final int register;
|
||||||
|
|
||||||
public BuilderEndLocal(@Nonnull MethodLocation location,
|
public BuilderEndLocal(int register) {
|
||||||
int register) {
|
|
||||||
super(location);
|
|
||||||
this.register = register;
|
this.register = register;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,14 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.EpilogueBegin;
|
import org.jf.dexlib2.iface.debug.EpilogueBegin;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class BuilderEpilogueBegin extends BuilderDebugItem implements EpilogueBegin {
|
public class BuilderEpilogueBegin extends BuilderDebugItem implements EpilogueBegin {
|
||||||
public BuilderEpilogueBegin(@Nonnull MethodLocation location) {
|
public BuilderEpilogueBegin() {
|
||||||
super(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getDebugItemType() { return DebugItemType.EPILOGUE_BEGIN; }
|
@Override public int getDebugItemType() { return DebugItemType.EPILOGUE_BEGIN; }
|
||||||
|
@ -33,17 +33,12 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.LineNumber;
|
import org.jf.dexlib2.iface.debug.LineNumber;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class BuilderLineNumber extends BuilderDebugItem implements LineNumber {
|
public class BuilderLineNumber extends BuilderDebugItem implements LineNumber {
|
||||||
private final int lineNumber;
|
private final int lineNumber;
|
||||||
|
|
||||||
public BuilderLineNumber(@Nonnull MethodLocation location,
|
public BuilderLineNumber(int lineNumber) {
|
||||||
int lineNumber) {
|
|
||||||
super(location);
|
|
||||||
this.lineNumber = lineNumber;
|
this.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,14 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.PrologueEnd;
|
import org.jf.dexlib2.iface.debug.PrologueEnd;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class BuilderPrologueEnd extends BuilderDebugItem implements PrologueEnd {
|
public class BuilderPrologueEnd extends BuilderDebugItem implements PrologueEnd {
|
||||||
public BuilderPrologueEnd(@Nonnull MethodLocation location) {
|
public BuilderPrologueEnd() {
|
||||||
super(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getDebugItemType() { return DebugItemType.PROLOGUE_END; }
|
@Override public int getDebugItemType() { return DebugItemType.PROLOGUE_END; }
|
||||||
|
@ -33,18 +33,14 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.RestartLocal;
|
import org.jf.dexlib2.iface.debug.RestartLocal;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BuilderRestartLocal extends BuilderDebugItem implements RestartLocal {
|
public class BuilderRestartLocal extends BuilderDebugItem implements RestartLocal {
|
||||||
private final int register;
|
private final int register;
|
||||||
|
|
||||||
public BuilderRestartLocal(@Nonnull MethodLocation location,
|
public BuilderRestartLocal(int register) {
|
||||||
int register) {
|
|
||||||
super(location);
|
|
||||||
this.register = register;
|
this.register = register;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,20 +33,16 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.SetSourceFile;
|
import org.jf.dexlib2.iface.debug.SetSourceFile;
|
||||||
import org.jf.dexlib2.iface.reference.StringReference;
|
import org.jf.dexlib2.iface.reference.StringReference;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BuilderSetSourceFile extends BuilderDebugItem implements SetSourceFile {
|
public class BuilderSetSourceFile extends BuilderDebugItem implements SetSourceFile {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final StringReference sourceFile;
|
private final StringReference sourceFile;
|
||||||
|
|
||||||
public BuilderSetSourceFile(@Nonnull MethodLocation location,
|
public BuilderSetSourceFile(@Nullable StringReference sourceFile) {
|
||||||
@Nullable StringReference sourceFile) {
|
|
||||||
super(location);
|
|
||||||
this.sourceFile = sourceFile;
|
this.sourceFile = sourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
|||||||
|
|
||||||
import org.jf.dexlib2.DebugItemType;
|
import org.jf.dexlib2.DebugItemType;
|
||||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||||
import org.jf.dexlib2.builder.MethodLocation;
|
|
||||||
import org.jf.dexlib2.iface.debug.StartLocal;
|
import org.jf.dexlib2.iface.debug.StartLocal;
|
||||||
import org.jf.dexlib2.iface.reference.StringReference;
|
import org.jf.dexlib2.iface.reference.StringReference;
|
||||||
import org.jf.dexlib2.iface.reference.TypeReference;
|
import org.jf.dexlib2.iface.reference.TypeReference;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BuilderStartLocal extends BuilderDebugItem implements StartLocal {
|
public class BuilderStartLocal extends BuilderDebugItem implements StartLocal {
|
||||||
@ -47,12 +45,10 @@ public class BuilderStartLocal extends BuilderDebugItem implements StartLocal {
|
|||||||
@Nullable private final TypeReference type;
|
@Nullable private final TypeReference type;
|
||||||
@Nullable private final StringReference signature;
|
@Nullable private final StringReference signature;
|
||||||
|
|
||||||
public BuilderStartLocal(@Nonnull MethodLocation location,
|
public BuilderStartLocal(int register,
|
||||||
int register,
|
|
||||||
@Nullable StringReference name,
|
@Nullable StringReference name,
|
||||||
@Nullable TypeReference type,
|
@Nullable TypeReference type,
|
||||||
@Nullable StringReference signature) {
|
@Nullable StringReference signature) {
|
||||||
super(location);
|
|
||||||
this.register = register;
|
this.register = register;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user