ah, found it. duh.

This commit is contained in:
Adam
2016-04-06 21:36:39 -04:00
parent b889d4da98
commit b5a9dd8ee7
8 changed files with 16 additions and 31 deletions

View File

@@ -174,11 +174,6 @@ public abstract class Instruction implements Cloneable
{
return length;
}
public String getDesc(Frame frame)
{
return type.getName() + " at pc " + frame.getPc() + " in " + frame.getMethod().getName() + " " + frame.getMethod().getDescriptor() + " class " + frame.getMethod().getCode().getAttributes().getClassFile().getName();
}
public abstract InstructionContext execute(Frame e);

View File

@@ -42,7 +42,7 @@ public class GetField extends Instruction implements GetFieldInstruction
public String toString()
{
Method m = this.getInstructions().getCode().getAttributes().getMethod();
return "getfield " + myField + " in " + m;
return "getfield " + myField + " in " + m + " at pc 0x" + Integer.toHexString(this.getPc());
}
@Override

View File

@@ -117,12 +117,6 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
{
return "invokespecial " + method + " in " + this.getInstructions().getCode().getAttributes().getMethod();
}
@Override
public String getDesc(Frame frame)
{
return "invokespecial " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName();
}
@Override
public void removeParameter(int idx)

View File

@@ -112,12 +112,6 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
return ins;
}
@Override
public String getDesc(Frame frame)
{
return "invokestatic " + method.getNameAndType().getDescriptor() + " on " + method.getClassEntry().getName() + " return value " + method.getNameAndType().getDescriptor().getReturnValue();
}
@Override
public void removeParameter(int idx)

View File

@@ -115,7 +115,7 @@ public class LDC_W extends Instruction implements PushConstantInstruction
@Override
public String getDesc(Frame frame)
public String toString()
{
return "ldc_w " + value;
}

View File

@@ -220,7 +220,7 @@ public class Frame
}
catch (Throwable ex)
{
System.err.println("Error executing instruction " + cur.getDesc(this));
System.err.println("Error executing instruction " + cur);
System.err.println("Frame stack (grows downward):");
while (stack.getSize() > 0)
{
@@ -228,7 +228,7 @@ public class Frame
InstructionContext pushed = stacki.getPushed();
Frame frame = pushed.getFrame();
System.err.println(pushed.getInstruction().getDesc(frame));
System.err.println(pushed.getInstruction());
}
System.err.println("end of stack");
ex.printStackTrace();

View File

@@ -48,7 +48,6 @@ public class StackContext
public void addPopped(InstructionContext popped)
{
// assert ParallellMappingExecutor.returnStacks.contains(this) == false;
if (!this.poppeds.contains(popped))
this.poppeds.add(popped);
}

View File

@@ -61,9 +61,11 @@ public class UnusedParameters implements Deobfuscator
unused.put(ms, u);
}
}
private int processUnused(Execution execution, ClassGroup group)
{
// XXX maybe only remove parameters at the very end, in the event i want to export a func?
int count = 0;
for (List<Method> m : unused.keySet())
@@ -163,19 +165,20 @@ public class UnusedParameters implements Deobfuscator
ii.removeParameter(paramIndex); // remove parameter from instruction
Collection<InstructionContext> ics = invokes.get(i);//execution.getInstructonContexts(i);
Collection<InstructionContext> ics = invokes.get(i);
assert ics != null;
if (ics != null)
{
InstructionContext ins = ics.toArray(new InstructionContext[0])[0];
for (InstructionContext ins : ics)
{
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
StackContext sctx = ins.getPops().get(pops);
if (sctx.getPushed().getInstruction().getInstructions() == null)
continue;
StackContext sctx = ins.getPops().get(pops);
if (sctx.getPushed().getInstruction().getInstructions() == null)
continue;
ins.removeStack(pops); // remove parameter from stack
ins.removeStack(pops); // remove parameter from stack
}
}
}
}