mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 16:50:39 +00:00
DebugAdapter
This commit is contained in:
@@ -114,4 +114,8 @@ public class Core {
|
|||||||
Core.verbose("Updates available...");
|
Core.verbose("Updates available...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void debug(int i) {
|
||||||
|
System.out.println("DEBUG: " + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.IntInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
public class AddDebugAdapter {
|
||||||
|
private MethodNode mn;
|
||||||
|
|
||||||
|
public AddDebugAdapter(MethodNode mn) {
|
||||||
|
this.mn = mn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inject() {
|
||||||
|
|
||||||
|
int i = 20;
|
||||||
|
for(AbstractInsnNode node : mn.instructions.toArray().clone()) {
|
||||||
|
if(node.getType() == AbstractInsnNode.METHOD_INSN || node.getOpcode() == Opcodes.PUTFIELD || node.getOpcode() == Opcodes.ASTORE || node.getOpcode() == Opcodes.ISTORE) {
|
||||||
|
i++;
|
||||||
|
InsnList inject = new InsnList();
|
||||||
|
inject.add(new IntInsnNode(Opcodes.BIPUSH, i));
|
||||||
|
inject.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
|
||||||
|
"org/parabot/core/Core", "debug",
|
||||||
|
"(I)V"));
|
||||||
|
mn.instructions.insertBefore(node.getNext(), inject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user