Mapping of static methods when stepping out in pme
This commit is contained in:
@@ -89,6 +89,11 @@ public class MappingExecutorUtil
|
||||
ParallellMappingExecutor parallel = new ParallellMappingExecutor(e, e2);
|
||||
ParallelExecutorMapping mappings = new ParallelExecutorMapping();
|
||||
|
||||
mappings.m1 = m1;
|
||||
mappings.m2 = m2;
|
||||
|
||||
parallel.mappings = mappings;
|
||||
|
||||
while (parallel.step())
|
||||
{
|
||||
// get what each frame is paused/exited on
|
||||
|
||||
@@ -4,11 +4,13 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.runelite.deob.Method;
|
||||
|
||||
public class ParallelExecutorMapping
|
||||
{
|
||||
private Map<Object, Object> map = new HashMap<>();
|
||||
private List<Object> order = new ArrayList<>();
|
||||
public Method m1, m2;
|
||||
|
||||
public void map(Object one, Object two)
|
||||
{
|
||||
|
||||
@@ -7,11 +7,13 @@ import net.runelite.deob.Method;
|
||||
import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction;
|
||||
import net.runelite.deob.attributes.code.instructions.InvokeStatic;
|
||||
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
|
||||
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
|
||||
|
||||
public class ParallellMappingExecutor
|
||||
{
|
||||
private Execution e, e2;
|
||||
private InstructionContext p1, p2;
|
||||
public ParallelExecutorMapping mappings;
|
||||
|
||||
public ParallellMappingExecutor(Execution one, Execution two)
|
||||
{
|
||||
@@ -173,6 +175,13 @@ public class ParallellMappingExecutor
|
||||
f1 = popStack(f1);
|
||||
f2 = popStack(f2);
|
||||
|
||||
if (oldf1 != f1 && oldf2 != f2)
|
||||
if (oldf1.otherStatic == oldf2 && oldf2.otherStatic == oldf1)
|
||||
{
|
||||
mappings.map(oldf1.getMethod(), oldf2.getMethod());
|
||||
System.out.println("hmmm");
|
||||
}
|
||||
|
||||
// if (e.frames.size() - s1 != e2.frames.size() - s2)
|
||||
// {
|
||||
// System.out.println("fr mismatch");
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.stream.Collectors;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Deob;
|
||||
import net.runelite.deob.Field;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import org.junit.Assert;
|
||||
@@ -117,7 +118,8 @@ public class MapStaticTest
|
||||
Method m2 = group2.findClass("class183").findMethod("method3560");
|
||||
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
map(all, new HashSet(), m1, m2);
|
||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||
map(all, pmes, m1, m2);
|
||||
}
|
||||
|
||||
//@Test
|
||||
@@ -126,6 +128,7 @@ public class MapStaticTest
|
||||
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
||||
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
||||
|
||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||
for (String[] s : methods)
|
||||
{
|
||||
String[] one = s[0].split("\\."), two = s[1].split("\\.");
|
||||
@@ -134,7 +137,7 @@ public class MapStaticTest
|
||||
Method m2 = group2.findClass(two[0]).findMethod(two[1]);
|
||||
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
map(all, new HashSet(), m1, m2);
|
||||
map(all, pmes, m1, m2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,21 +153,43 @@ public class MapStaticTest
|
||||
|
||||
assert m1s.size() == m2s.size();
|
||||
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||
for (int i = 0; i < m1s.size(); ++i)
|
||||
{
|
||||
Method m1 = m1s.get(i), m2 = m2s.get(i);
|
||||
|
||||
assert m1.getPoolMethod().equals(m2.getPoolMethod());
|
||||
|
||||
map(all, new HashSet(), m1, m2);
|
||||
|
||||
for (Entry<Object, Object> e : all.entrySet())
|
||||
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
map(all, pmes, m1, m2);
|
||||
}
|
||||
int fields = 0, staticMethod = 0, method = 0, total = 0;
|
||||
for (ParallelExecutorMapping pme : pmes)
|
||||
for (Entry<Object, Object> e : pme.getMap().entrySet())
|
||||
{
|
||||
System.out.println(e.getKey() + " <-> " + e.getValue());
|
||||
|
||||
Object o = e.getKey();
|
||||
if (o instanceof Field)
|
||||
++fields;
|
||||
else if (o instanceof Method)
|
||||
{
|
||||
Method m = (Method) o;
|
||||
|
||||
if (m.isStatic())
|
||||
++staticMethod;
|
||||
else
|
||||
++method;
|
||||
}
|
||||
|
||||
++total;
|
||||
}
|
||||
}
|
||||
System.out.println("Total " + all.size());
|
||||
System.out.println("Total " + total + ". " + fields + " fields, " + staticMethod + " static methods, " + method + " methods");
|
||||
// for (Method m : group1.findClass("client").getMethods().getMethods())
|
||||
// {
|
||||
// if (!all.containsKey(m) && !m.isStatic())
|
||||
// System.out.println("missing " + m);
|
||||
// }
|
||||
}
|
||||
|
||||
public List<Method> getInitialMethods(ClassGroup group)
|
||||
@@ -201,7 +226,7 @@ public class MapStaticTest
|
||||
return methods;
|
||||
}
|
||||
|
||||
private void map(Map<Object, Object> all, Set<Object> invalid, Method m1, Method m2)
|
||||
private void map(Map<Object, Object> all, List<ParallelExecutorMapping> result, Method m1, Method m2)
|
||||
{
|
||||
if (all.containsKey(m1))
|
||||
return;
|
||||
@@ -225,6 +250,8 @@ public class MapStaticTest
|
||||
return;
|
||||
}
|
||||
|
||||
result.add(mappings);
|
||||
|
||||
for (Entry<Object, Object> e : mappings.getMap().entrySet())
|
||||
{
|
||||
if (e.getKey() instanceof Method)
|
||||
@@ -232,7 +259,7 @@ public class MapStaticTest
|
||||
Method n1 = (Method) e.getKey(),
|
||||
n2 = (Method) e.getValue();
|
||||
|
||||
map(all, invalid, n1, n2);
|
||||
map(all, result, n1, n2);
|
||||
}
|
||||
else
|
||||
all.put(e.getKey(), e.getValue());
|
||||
@@ -240,4 +267,25 @@ public class MapStaticTest
|
||||
//all.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void print(ClassGroup cg)
|
||||
{
|
||||
int methods = 0, fields = 0, classes = 0;
|
||||
for (ClassFile cf : cg.getClasses())
|
||||
{
|
||||
++classes;
|
||||
methods += cf.getMethods().getMethods().size();
|
||||
fields += cf.getFields().getFields().size();
|
||||
}
|
||||
int total = methods + fields;
|
||||
System.out.println("Goal; total m/f: " + total + ", " + methods + " methods, " + fields + " fields");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void printTotalObjects() throws Exception
|
||||
{
|
||||
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
||||
//ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
||||
print(group1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user