mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-08 00:38:38 +00:00
different debug adapter
This commit is contained in:
@@ -1,33 +1,43 @@
|
|||||||
package org.parabot.core.asm.adapters;
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
import org.objectweb.asm.tree.InsnList;
|
||||||
import org.objectweb.asm.tree.IntInsnNode;
|
import org.objectweb.asm.tree.LabelNode;
|
||||||
|
import org.objectweb.asm.tree.LdcInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
public class AddDebugAdapter {
|
public class AddDebugAdapter {
|
||||||
|
private ClassNode owner;
|
||||||
private MethodNode mn;
|
private MethodNode mn;
|
||||||
|
|
||||||
|
public AddDebugAdapter(ClassNode owner, MethodNode mn) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.mn = mn;
|
||||||
|
}
|
||||||
|
|
||||||
public AddDebugAdapter(MethodNode mn) {
|
public AddDebugAdapter(MethodNode mn) {
|
||||||
this.mn = mn;
|
this.mn = mn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inject() {
|
public void inject() {
|
||||||
|
InsnList inject = new InsnList();
|
||||||
|
Label l0 = new Label();
|
||||||
|
inject.add(new LabelNode(l0));
|
||||||
|
|
||||||
|
String callString = owner.name + "." + mn.name + " " + mn.desc;
|
||||||
|
LdcInsnNode ldc = new LdcInsnNode(callString);
|
||||||
|
|
||||||
|
MethodInsnNode methodNode = new MethodInsnNode(Opcodes.INVOKESTATIC, "org/parabot/core/Core", "debug",
|
||||||
|
"(Ljava/lang/String;)V");
|
||||||
|
|
||||||
|
inject.add(ldc);
|
||||||
|
inject.add(methodNode);
|
||||||
|
|
||||||
|
mn.instructions.insert(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