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

Fail to get variable names after setting use-original-names:true #1262

Open
coder-chenzhi opened this issue Dec 27, 2019 · 3 comments
Open

Comments

@coder-chenzhi
Copy link

coder-chenzhi commented Dec 27, 2019

I use soot-3.3.0 to run a faint variable analysis. However, I can't get variable names after setting use-original-names:true.
Test Code

public class Main {
    public static void dummyTest() {
        Person me = new Person("Victor", 25, false);
        me.age = 26;
        System.out.println(me.name);
    }
}

class Person {
    String name;
    int age;
    boolean gender;

    public Person(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }
}

Generated Jimple for the dummyTest() method:

    public static void dummyTest()
    {
        edu.zju.Person $stack1;
        java.lang.String $stack2;
        java.io.PrintStream $stack3;

        $stack1 = new edu.zju.Person;

        specialinvoke $stack1.<edu.zju.Person: void <init>(java.lang.String,int,boolean)>("Victor", 25, 0);

        $stack1.<edu.zju.Person: int age> = 26;

        $stack3 = <java.lang.System: java.io.PrintStream out>;

        $stack2 = $stack1.<edu.zju.Person: java.lang.String name>;

        virtualinvoke $stack3.<java.io.PrintStream: void println(java.lang.String)>($stack2);

        return;
    }

The name $stack1 should be me.

@ericbodden
Copy link
Member

We just received another such report over the Soot mailing list. @linghuiluo are you aware of any open limitations in that regard w.r.t. the current source-code frontend?

@s1530129650
Copy link

I report it in Soot mailing list.
when i run "java -cp sootclasses-trunk-jar-with-dependencies.jar soot.tools.CFGViewer --soot-classpath .;"%JAVA_HOME%"\jre\lib\rt.jar --graph=BriefBlockGraph Triangle " twice .
OS: window10
Java 7
Soot 3.0.1

The first loaded Triangle.java, the 2nd loaded Triangle.class. The different results (Triangle_java.dot and Triangle_calss.dot ) are generated.

Triangle_calss.dot is visualized as Triangle_class.png, which is reasonable.
And Triangle_java.dot is visualized as Triangle_java.png, which looks wrong:
1. it remains the original name .
2. There are some nodes named "goto label**" which is not necessary and wrong.

Unfortunately, when i add "-p jb use-original-names:true" and run
"java -cp sootclasses-trunk-jar-with-dependencies.jar soot.tools.CFGViewer --soot-classpath .;"%JAVA_HOME%"\jre\lib\rt.jar -p jb use-original-names:true --graph=BriefUnitGraph Triangle"
, which loaded Triangle.class, the original names aren't keep.

You can find all in res.zip
res.zip

@amadionix
Copy link

I also have the same problem.

I compiled the class to instrument this way: javac -g ClassToInstrument

Then I iterate over Local variables l (body.getParameterLocals()), and if I do l.getName() I get the Soot name instead of the actual variable name.

I am running the class like this: java -cp .:soot-with-dep.jar MyAnalysisClass -p jb use-original-names:true ClassToInstrument (<args[0] in MyAnalysisClass.Main>) MethodToInstrument (<args[1] in MyAnalysisClass.Main>)
I haven't actually typed what you see in parenthesis, it's just to explain to you what those things are.

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

4 participants