Skip to content

Printing instruction list for debugging/troubleshooting #20

Closed
@chylex

Description

@chylex

Discussed this a bit on stream before, so I'm making an issue to figure out the approach.

I generate a log with all instructions of the transformed method when the transformer fails, which makes it really easy to diagnose issues with two mods transforming the same method. This is what I used in 1.12 and older:

TraceMethodVisitor visitor = new TraceMethodVisitor(new Textifier());

for(Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();){
    iter.next().accept(visitor);
}

// print visitor.p.getText()

with an example section of the output:

ALOAD 0
GETFIELD bud.S : Ljava/util/Random;
INVOKEVIRTUAL java/util/Random.nextFloat ()F
LDC 0.4

On stream you said Textifier is no longer available as asm-util is not included anymore, so I could either:

  • Re-add asm-util and add a utility method to ASMAPI with the code above, or
  • Implement custom printouts for each instruction type that'd look similar to Textifier output, this could perhaps also include remapped names

Let me know what you think, I could PR this sometime next week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions