Skip to content

How to retain "LocalVariableTable" and "MethodParameters" attributes in .class after instrumentation? #2065

@XYHyouKa

Description

@XYHyouKa

I found LocalVariableTable and MethodParameters attributes in .class are lost after instrumentation? I am not sure whether it's bug because I use soot my own way, so commit a feature request. Here's the detailed descriptions below:

I am using Soot to develop a Javaagent, thus requiring a workflow from byte[] to Jimple to byte[], rather than class files. So it would be better If soot can run continuely (that's what I do now) instead of executing only once (reads all class files and then outputs all class files), and supports byte[] workflow.

To do this, I added a byte stream ClassProvider so that I can use Scene.v().loadClassAndSupport(String) directly to read project classes. The output implemented a subclass of soot.baf.BafASMBackend to obtain byte array data of classes. Core implementation:

public class SubClass extends BafASMBackend {
    /* ... */
    public byte[] generateClassBytes() {
        ClassWriter cw = new SootASMClassWriter(ClassWriter.COMPUTE_FRAMES);
        cv = cw;
        generateByteCode();
        return cw.toByteArray();
    }
}

However, the classes obtained this way lost useful attributes for the program, such as LocalVariableTable and MethodParameters. Is there any wrong in my usage? How to handle this process more properly? Thank you for your reply!

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