mirror of
https://github.com/pxb1988/dex2jar.git
synced 2024-11-23 13:19:46 +00:00
1. merge LineNumStmt to LabelStmt,
2. enable V3Test to process debug info --HG-- branch : debug-support
This commit is contained in:
parent
5ab114da09
commit
5c36f289c7
@ -33,6 +33,7 @@ public class LabelStmt extends E0Stmt {
|
||||
|
||||
public String displayName;
|
||||
public Label label;
|
||||
public int lineNumber = -1;
|
||||
|
||||
public LabelStmt(Label label) {
|
||||
super(ST.LABEL);
|
||||
@ -50,7 +51,11 @@ public class LabelStmt extends E0Stmt {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDisplayName() + ":";
|
||||
if (lineNumber >= 0) {
|
||||
return getDisplayName() + ": // line " + lineNumber;
|
||||
} else {
|
||||
return getDisplayName() + ":";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package com.googlecode.dex2jar.ir.stmt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt.E0Stmt;
|
||||
|
||||
public class LineNumStmt extends E0Stmt {
|
||||
|
||||
public String displayName;
|
||||
public LabelStmt label;
|
||||
public int line;
|
||||
|
||||
public LineNumStmt(int line, LabelStmt label) {
|
||||
super(ST.LINENUMBER);
|
||||
this.label = label;
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LineNumStmt clone(Map<LabelStmt, LabelStmt> map) {
|
||||
return new LineNumStmt(line, label.clone(map));
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName == null ? label.toString() : displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label.getDisplayName() + " -> line " + line;
|
||||
}
|
||||
|
||||
}
|
@ -100,8 +100,7 @@ public abstract class Stmt {
|
||||
public static enum ST {
|
||||
|
||||
ASSIGN, GOTO, IDENTITY, IF, LABEL, LOCK, LOOKUP_SWITCH, //
|
||||
NOP, RETURN, RETURN_VOID, TABLE_SWITCH, THROW, UNLOCK,
|
||||
LINENUMBER, LOCALVARIABLE
|
||||
NOP, RETURN, RETURN_VOID, TABLE_SWITCH, THROW, UNLOCK, LOCALVARIABLE
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,10 +86,6 @@ public final class Stmts {
|
||||
return new UnopStmt(ST.UNLOCK, box(op));
|
||||
}
|
||||
|
||||
public static LineNumStmt nLineNum(int line, LabelStmt label) {
|
||||
return new LineNumStmt(line, label);
|
||||
}
|
||||
|
||||
public static LocVarStmt nLocVar(String name, String type, String signature,
|
||||
LabelStmt start, LabelStmt end, Value reg) {
|
||||
return new LocVarStmt(name, type, signature, start, end, box(reg));
|
||||
|
@ -100,7 +100,6 @@ public class Cfg {
|
||||
public static boolean notThrow(Stmt s) {
|
||||
switch (s.st) {
|
||||
case LABEL:
|
||||
case LINENUMBER:
|
||||
case LOCALVARIABLE:
|
||||
case RETURN:
|
||||
case RETURN_VOID:
|
||||
|
@ -34,7 +34,6 @@ public class EndRemover implements Transformer {
|
||||
}
|
||||
break;
|
||||
case LABEL:
|
||||
case LINENUMBER:
|
||||
case LOCALVARIABLE:
|
||||
case NOP:
|
||||
case UNLOCK:
|
||||
@ -67,7 +66,6 @@ public class EndRemover implements Transformer {
|
||||
for (Stmt p = js.target.getNext(); !end; p = p.getNext()) {
|
||||
switch (p.st) {
|
||||
case LABEL:
|
||||
case LINENUMBER:
|
||||
break;
|
||||
case GOTO:
|
||||
LabelStmt target = ((JumpStmt) p).target;
|
||||
|
@ -63,10 +63,10 @@ public class ExceptionHandlerCurrectTransformer implements Transformer {
|
||||
LabelStmt handler = t.handler;
|
||||
Stmt st = handler.getNext();
|
||||
Stmt pre = handler.getPre();
|
||||
while (st.st == ST.LABEL || st.st == ST.LINENUMBER) {
|
||||
while (st.st == ST.LABEL) {
|
||||
st = st.getNext();
|
||||
}
|
||||
while (pre.st == ST.LABEL || pre.st == ST.LINENUMBER) {
|
||||
while (pre.st == ST.LABEL) {
|
||||
pre = pre.getPre();
|
||||
}
|
||||
if (needInsertMoveExceptionRef(st) && needInsertGoto(pre)) {
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.googlecode.dex2jar.ir.IrMethod;
|
||||
import com.googlecode.dex2jar.ir.stmt.LineNumStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LocVarStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt.ST;
|
||||
@ -19,7 +18,7 @@ public class InfoMove2Code implements Transformer {
|
||||
//Try to found all LOCALVARIABLE block and move them to the code before it's end label.
|
||||
//And all LINENUMBER block and move them after it's label
|
||||
for(Stmt st:stmts){
|
||||
if(st.st == ST.LOCALVARIABLE || st.st == ST.LINENUMBER){
|
||||
if(st.st == ST.LOCALVARIABLE){
|
||||
lvs.add(st);
|
||||
}
|
||||
}
|
||||
@ -43,7 +42,6 @@ public class InfoMove2Code implements Transformer {
|
||||
dist = dist.getPre();
|
||||
break;
|
||||
case LABEL:
|
||||
case LINENUMBER:
|
||||
if(skip){//SKIP EMPTY LINE
|
||||
dist = dist.getPre();
|
||||
}else{
|
||||
@ -57,8 +55,6 @@ public class InfoMove2Code implements Transformer {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(st.st == ST.LINENUMBER){
|
||||
dist = ((LineNumStmt)st).label;
|
||||
}
|
||||
if(dist != null){
|
||||
stmts.move(st, st, dist);
|
||||
|
@ -253,7 +253,6 @@ public class LocalRemove implements Transformer {
|
||||
switch (st.st) {
|
||||
case RETURN_VOID:
|
||||
case LABEL:
|
||||
case LINENUMBER:
|
||||
case LOCALVARIABLE:
|
||||
case GOTO:
|
||||
case NOP:
|
||||
|
@ -33,14 +33,13 @@ import com.googlecode.dex2jar.ir.expr.TypeExpr;
|
||||
import com.googlecode.dex2jar.ir.stmt.AssignStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.JumpStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LabelStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LineNumStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LocVarStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LookupSwitchStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt.E2Stmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmt.ST;
|
||||
import com.googlecode.dex2jar.ir.stmt.TableSwitchStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.UnopStmt;
|
||||
import com.googlecode.dex2jar.ir.stmt.LocVarStmt;
|
||||
import com.googlecode.dex2jar.ir.ts.Cfg;
|
||||
import com.googlecode.dex2jar.ir.ts.Cfg.StmtVisitor;
|
||||
import com.googlecode.dex2jar.ir.ts.LiveAnalyze;
|
||||
@ -350,31 +349,33 @@ public class IrMethod2AsmMethod implements Opcodes {
|
||||
: trap.type.getInternalName());
|
||||
}
|
||||
}
|
||||
|
||||
private void reIndexStmts(IrMethod ir) {
|
||||
int count = 0;
|
||||
for (Stmt st : ir.stmts) {
|
||||
st.id = count;
|
||||
count ++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private void reBuildInstructions(IrMethod ir, MethodVisitor asm) {
|
||||
for (Stmt st : ir.stmts) {
|
||||
switch (st.st) {
|
||||
case LABEL:
|
||||
asm.visitLabel(((LabelStmt) st).label);
|
||||
break;
|
||||
case LINENUMBER:
|
||||
LineNumStmt ls = (LineNumStmt) st;
|
||||
asm.visitLineNumber(ls.line, ls.label.label);
|
||||
LabelStmt labelStmt = (LabelStmt) st;
|
||||
asm.visitLabel(labelStmt.label);
|
||||
if (labelStmt.lineNumber >= 0) {
|
||||
asm.visitLineNumber(labelStmt.lineNumber, labelStmt.label);
|
||||
}
|
||||
break;
|
||||
case LOCALVARIABLE:
|
||||
LocVarStmt vs = (LocVarStmt) st;
|
||||
if(vs.start.id <= vs.end.id){
|
||||
asm.visitLocalVariable(vs.name, vs.type,
|
||||
vs.signature, vs.start.label, vs.end.label, ((Local)vs.op.value)._ls_index);
|
||||
}else{
|
||||
asm.visitLocalVariable(vs.name, vs.type,
|
||||
vs.signature, vs.end.label, vs.start.label, ((Local)vs.op.value)._ls_index);
|
||||
if (vs.start.id <= vs.end.id) {
|
||||
asm.visitLocalVariable(vs.name, vs.type, vs.signature, vs.start.label, vs.end.label,
|
||||
((Local) vs.op.value)._ls_index);
|
||||
} else {
|
||||
asm.visitLocalVariable(vs.name, vs.type, vs.signature, vs.end.label, vs.start.label,
|
||||
((Local) vs.op.value)._ls_index);
|
||||
}
|
||||
break;
|
||||
case ASSIGN: {
|
||||
|
@ -64,6 +64,7 @@ import static com.googlecode.dex2jar.ir.stmt.Stmts.nAssign;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nGoto;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nIdentity;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nIf;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nLocVar;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nLock;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nLookupSwitch;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nReturn;
|
||||
@ -71,8 +72,6 @@ import static com.googlecode.dex2jar.ir.stmt.Stmts.nReturnVoid;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nTableSwitch;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nThrow;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nUnLock;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nLocVar;
|
||||
import static com.googlecode.dex2jar.ir.stmt.Stmts.nLineNum;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -645,7 +644,7 @@ public class V3CodeAdapter implements DexCodeVisitor, Opcodes, DexOpcodes {
|
||||
|
||||
@Override
|
||||
public void visitLineNumber(int line, DexLabel label) {
|
||||
list.add(nLineNum(line, toLabelStmt(label)));
|
||||
toLabelStmt(label).lineNumber = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class V3Test {
|
||||
}
|
||||
};
|
||||
}
|
||||
}), DexFileReader.SKIP_DEBUG);
|
||||
}), 0);
|
||||
System.out.flush();
|
||||
System.out.println();
|
||||
if (exes.size() > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user