Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
XYHyouKa opened this issue Apr 8, 2024 · 0 comments

Comments

@XYHyouKa
Copy link

XYHyouKa commented Apr 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant