[Soot-list] Soot-list Digest, Vol 81, Issue 5

Aaloan Miftah aaloanmiftah at yahoo.com
Fri Jan 6 16:43:58 EST 2012


Hi,

I've done something similar, though it was through editing Soot's source code,

(sorry can't provide diff, hacking at linux kernel has downsides, using livecd to retrieve the source)
Go into soot.Scene and replace "public void setMainClass(SootClass m)" with,

    public void setMainClass(SootClass m)
    {
        mainClass = m;
        //if(!m.declaresMethod(getSubSigNumberer().findOrAdd( "void main(java.lang.String[])" ))) {
        //throw new RuntimeException("Main-class has no main method!");
        //}
    }

Next, in soot.EntryPoints add,

    private final ArrayList<SootMethod> customEntryPoints = new ArrayList<SootMethod>();


    public void addEntryPoint(SootMethod m) {
        customEntryPoints.add(m);
    }

and replace "public List<SootMethod> application()" with,

    public List<SootMethod> application() {
        List<SootMethod> ret = new ArrayList<SootMethod>();
        if(customEntryPoints.size() > 0)
            ret.addAll(customEntryPoints);
        else if(Scene.v().hasMainClass() || !Scene.v().hasCustomEntryPoints())
        addMethod( ret, Scene.v().getMainClass(), sigMain );
        for (SootMethod clinit : clinitsOf(Scene.v().getMainClass() )) {
            ret.add(clinit);
        }
        return ret;
    }

usage (off top of my head):
Scene.load***Classes();
EntryPoints.v().addEntryPoint(Scene.getMethod("<ClassName: void methodName()>"));

this _is_ a hack (and I haven't verified it), not sure if it'll produce expected results, so verify the callgraph. Could a Soot developer verify?


________________________________
 From: Tezcan Dilshener <tezcan at dilshener.de>
To: Eric Bodden <eric.bodden at ec-spride.de> 
Cc: soot-list at sable.mcgill.ca 
Sent: Friday, January 6, 2012 2:07 PM
Subject: Re: [Soot-list] Soot-list Digest, Vol 81, Issue 5
 

Hi Eric,


Can you just delete the .java files?
I do not have .java files. Soot is demanding for source files when I run it with -process-dir option.
It is reading all the classes from the directory I specify on the call option and then looks for their source files hence fails with exception.
Exception in thread "main" java.lang.RuntimeException: couldn't find class: HelperCorrelation (is your soot-class-path set properly?)
at soot.SootResolver.bringToHierarchy(SootResolver.java:184)

The exception is misleading because in debug mode, I can see that it is looking for the source file and not for the class file. 
It is coming form the SootResolver after the following line.
ClassSource is = SourceLocator.v().getClassSource(className);
 
When I specify the source directory on the class path as indicated by the exception message, then I get the following error;
Exception in thread "main" soot.CompilationDeathException: there were errors during parsing and/or type checking (JastAdd frontend)
at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:63)

I have already written these two issues to you and to the user-list.  So as you can see this is getting real frustrating.
I can always use the ASM library to get a call/invocation list form class files but I am still hoping to use a reputable framework like the Soot.

Has anyone out there actually used Soot to obtain a call graph from .class files for an application that does not have any main methods?
I would love to hear form you about how you achieved it?
Could you please provide me a working code example? 

Cheers
Tezcan
 

On 06.01.2012, at 12:06, Eric Bodden wrote:

Looks like no matter what I do Soot is trying to look for the sources of the
>>
>classes that it reads.
>>
>Can you just delete the .java files?
>
>
>All I am trying to do is record a list of ClassA.method() calls
>>
>ClassB.metod().
>>
>How can I run Soot so that it only analyzes class files to give me a such a
>>
>list?
>>
>Just create a BodyTransformer in the "jtp" pack that prints all invoke
>expressions in the respective body's unit chain.
>
>Best wishes,
>Eric
>

Tezcan Dilshener  

"Subset of all things that we know and believe makes our knowledge."




_______________________________________________
Soot-list mailing list
Soot-list at sable.mcgill.ca
http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120106/2e5dcb05/attachment-0001.html 


More information about the Soot-list mailing list