Soot - 从 java 类映射到 jimple

发布于 2025-01-18 21:16:34 字数 616 浏览 3 评论 0原文

使用以下代码,我可以获得jimple Java .class文件的表示:

        soot.Main.main(args);
        SootClass mainClass = Scene.v().getMainClass();
        String methodSignature = "void main(java.lang.String[])";
        SootMethod mainMethod = mainClass.getMethod(methodSignature);
        Body jimpleBody = mainMethod.retrieveActiveBody();

但是,我需要从.classjimple。详细说明,对于.class文件中的某个代码行,我想知道其相应的jimple表示。由于一行代码可以转换为多个jimple代码,因此该地图可以是一对一的。是否存在可以解决此问题的API或方法?

With the following code I can get the jimple representation of a java .class file:

        soot.Main.main(args);
        SootClass mainClass = Scene.v().getMainClass();
        String methodSignature = "void main(java.lang.String[])";
        SootMethod mainMethod = mainClass.getMethod(methodSignature);
        Body jimpleBody = mainMethod.retrieveActiveBody();

However, I need to know the map from .class to jimple. In detail, For a certain line of code in the .class file, I want to know its corresponding jimple representation. Since one line of code can be converted into multiple jimple codes, this map can be one-to-many. Does there exist any API or method that can solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2025-01-25 21:16:34

我找到解决方案在这里。详细说明单元您可以使用

Unit unit = ...
int sourceID = unit.getJavaSourceStartLineNumber();
// do something smart here ...

I find the solution here. In detail, for a Unit you can use

Unit unit = ...
int sourceID = unit.getJavaSourceStartLineNumber();
// do something smart here ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文