Solved methods 860, solved fields 856, unsolved methods 253, unsolved fields 1439 - I guess because i changed how graph building works

This commit is contained in:
Adam
2015-12-13 17:57:25 -05:00
parent 5e8681adfd
commit a495c5c905
5 changed files with 77 additions and 14 deletions

View File

@@ -28,6 +28,7 @@ import net.runelite.deob.deobfuscators.rename.graph.Edge;
import net.runelite.deob.deobfuscators.rename.graph.EdgeType;
import net.runelite.deob.deobfuscators.rename.graph.FieldEdge;
import net.runelite.deob.deobfuscators.rename.graph.Graph;
import net.runelite.deob.deobfuscators.rename.graph.GraphBuilder;
import net.runelite.deob.deobfuscators.rename.graph.Vertex;
import net.runelite.deob.deobfuscators.rename.graph.VertexType;
import net.runelite.deob.execution.Execution;
@@ -309,20 +310,20 @@ public class Rename2
public NameMappings run(ClassGroup one, ClassGroup two)
{
Execution eone = new Execution(one);
eone.setBuildGraph(true);
//eone.setBuildGraph(true);
eone.populateInitialMethods();
eone.run();
Execution etwo = new Execution(two);
etwo.setBuildGraph(true);
//etwo.setBuildGraph(true);
etwo.populateInitialMethods();
etwo.run();
g1 = eone.getGraph();
g2 = etwo.getGraph();
g1 = GraphBuilder.build(one);
g2 = GraphBuilder.build(two);
System.out.println(eone.getGraph());
System.out.println(etwo.getGraph());
// System.out.println(eone.getGraph());
// System.out.println(etwo.getGraph());
for (int i = 0; i < 250; ++i)
{

View File

@@ -121,10 +121,10 @@ public class Edge
if (this.type == EdgeType.SETFIELD)// || this.type == EdgeType.SETFIELD_FROM)
{
if (!compareSetField(getGraph(), other.getGraph(),
(Field) this.getTo().getObject(), (Field) other.getTo().getObject(),
other.getIns()))
return false;
// if (!compareSetField(getGraph(), other.getGraph(),
// (Field) this.getTo().getObject(), (Field) other.getTo().getObject(),
// other.getIns()))
// return false;
}
// if (this.weight != other.weight)
// return false;

View File

@@ -37,6 +37,8 @@ public class Execution
public Set<Instruction> executed = new HashSet<>(); // executed instructions
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
public boolean paused;
public boolean step = true;
public Execution(ClassGroup group)
{
@@ -105,6 +107,7 @@ public class Execution
public Frame invoke(InstructionContext from, Method to)
{
if(!step) return null;//THIS BREAKS THIS
if (hasInvoked(from, to))
return null;
@@ -123,6 +126,7 @@ public class Execution
public void run()
{
assert !paused;
int fcount = 0;
while (!frames.isEmpty())
@@ -144,10 +148,17 @@ public class Execution
System.out.println("Processed " + fcount + " frames");
}
{
}
// public InstructionContext getPaused()
// {
// if (frames.isEmpty())
// return null;
//
// Frame f = frames.get(0);
// return f.getInstructions().get(f.getInstructions().size() - 1);
// }
public Collection<InstructionContext> getInstructonContexts(Instruction i)
{
return contexts.getCollection(i);
}
}

View File

@@ -228,7 +228,7 @@ public class Frame
/* jump */
}
if (oldCur instanceof MappableInstruction)
if (!execution.step && oldCur instanceof MappableInstruction)
{
execution.paused = true;
return;

View File

@@ -6,6 +6,9 @@ import java.util.List;
import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.Instruction;
import java.util.Objects;
import net.runelite.deob.attributes.code.instruction.types.DupInstruction;
import net.runelite.deob.attributes.code.instruction.types.LVTInstruction;
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
public class InstructionContext
{
@@ -158,4 +161,52 @@ public class InstructionContext
{
return "InstructionContext{" + "ins=" + ins + '}';
}
public InstructionContext resolve(
StackContext from // pushed from this
)
{
InstructionContext ctx = this;
if (ctx.getInstruction() instanceof SetFieldInstruction)
{
StackContext s = ctx.getPops().get(0);
return s.getPushed().resolve(s);
}
if (ctx.getInstruction() instanceof DupInstruction)
{
DupInstruction d = (DupInstruction) ctx.getInstruction();
StackContext s = d.getOriginal(from);
return s.getPushed().resolve(s);
}
if (ctx.getInstruction() instanceof LVTInstruction)
{
LVTInstruction lvt = (LVTInstruction) ctx.getInstruction();
Variables variables = ctx.getVariables();
if (lvt.store())
{
StackContext s = ctx.getPops().get(0); // is this right?
return s.getPushed().resolve(s);
}
else
{
VariableContext vctx = variables.get(lvt.getVariableIndex()); // variable being loaded
assert vctx != null;
InstructionContext storedCtx = vctx.getInstructionWhichStored();
if (storedCtx == null)
return ctx; // initial parameter
if (vctx.isIsParameter())
return ctx; // parameter (storedCtx is invoking instruction in another frame). this lvt index is fixed.
return storedCtx.resolve(null);
}
}
return ctx;
}
}