[Soot-list] Building a call graph for a class that has no main

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Mon Jul 25 03:08:09 EDT 2011


Hi John.

The implicit() and all() calls are always taken from the EntryPoint
class, as those have a very special, Java-specific semantics. I think
whatever you set in the Scene will only affect the result of
application().

Eric

On 25 July 2011 00:43, John Dee <jdsoot at hotmail.com> wrote:
> Hi Eric, if I could just check one final thing. When I pass in the list of
> SootMethods to the setEntryPoints method, how will Soot be able to
> differentiate between the methods required for 'all' to the methods required
> for 'implicit' etc..? Thanks indeed JD
>
>> From: bodden at st.informatik.tu-darmstadt.de
>> Date: Sun, 24 Jul 2011 15:16:58 +0200
>> Subject: Re: [Soot-list] Building a call graph for a class that has no
>> main
>> To: jdsoot at hotmail.com
>> CC: soot-list at sable.mcgill.ca
>>
>> Hi John.
>>
>> My apologies - apparently this is harder than it should be. I have
>> made some changes to Soot, which should eliminate the problem. Please
>> set your custom entry points using Scene.v().setEntryPoints(...). Make
>> sure to provide an exhaustive list because this will cause Soot to
>> ignore all default entry points.
>>
>> We are currently experiencing a problem with our build server but
>> hopefully this will be fixed tomorrow and a new nightly build will
>> appear here:
>> http://vandyk.st.informatik.tu-darmstadt.de/abc/
>>
>> The version in SVN is fixed already.
>>
>> Eric
>>
>>
>> On 23 July 2011 20:33, John Dee <jdsoot at hotmail.com> wrote:
>> >
>> > Hi,
>> > I was just wondering if someone could give me some guidance on this?
>> > Perhaps
>> > by a small worked example.
>> > I'm still stuck and cannot set the entry point for a class that has no
>> > main
>> > method.
>> > Thanks & Regards
>> > JD
>> >
>> > ________________________________
>> > From: jdsoot at hotmail.com
>> > To: bodden at st.informatik.tu-darmstadt.de; soot-list at sable.mcgill.ca
>> > Date: Fri, 22 Jul 2011 17:05:00 +0100
>> > Subject: Re: [Soot-list] Building a call graph for a class that has no
>> > main
>> >
>> > Hi Eric,
>> > I have spent the past couple of hours looking over the information in
>> > the
>> > archives and I can
>> > find 2 possible solutions.
>> > The first solution is stated here
>> >
>> > - http://www.sable.mcgill.ca/pipermail/soot-list/2011-January/003434.html
>> > Which says that before calling Soot's main method - you can call
>> > Scene.v().setEntryPoints(new MyEntryPoints())
>> > Now, I see an issue with this. To subclass 'EntryPoints', you must
>> > provide a
>> > call to super with an
>> > argument of type Singletons.Global. I'm not sure what that is or how to
>> > pass
>> > it into the 'MyEntryPoints' constructor.
>> > The second approach I found was here -
>> > http://www.sable.mcgill.ca/pipermail/soot-list/2005-August/000326.html
>> > This says to call 'EntryPoints.v().application' to get your application
>> > entry points. You then alter this list and call
>> > 'Scene.v().setEntryPoints(...)' with your altered list. I tried this and
>> > it
>> > doesn't work either. I get an error stating:
>> > Exception in thread "main" java.lang.RuntimeException: There is no main
>> > class set!
>> > I have no main method in my class and after trying several approaches, I
>> > can't find a work around.
>> > The code I have is:
>> > public class CallGraphExample
>> > {
>> > public static void main(String[] args) {
>> > // create a list from args
>> >   List<String> argsList = new ArrayList<String>(Arrays.asList(args));
>> >
>> >   // add on the following arguments
>> >   argsList.addAll(Arrays.asList(new String[]{
>> >   "-w",
>> >   "testers.CallGraphs"
>> >   }));
>> >
>> >   // PackManager manages the packs containing the various phases and
>> > their
>> > options
>> >   PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new
>> > SceneTransformer() {
>> > @Override
>> > protected void internalTransform(String phaseName, Map options) {
>> >       CHATransformer.v().transform();
>> >
>> >       // return the soot class with the given name
>> >                SootClass a =
>> > Scene.v().getSootClass("testers.CallGraphs");
>> >
>> >                List<SootMethod> entryMethods = new
>> > ArrayList<SootMethod>();
>> >                SootMethod method = a.getMethodByName("doStuff");
>> >                entryMethods.add(method);
>> >                entryMethods.addAll(EntryPoints.v().application());
>> >                Scene.v().setEntryPoints(entryMethods);
>> >                for (SootMethod sMethod : Scene.v().getEntryPoints()) {
>> >               if (sMethod.getName().equals("main")) {
>> >               Scene.v().getEntryPoints().remove(sMethod);
>> >               break;
>> >               }
>> >                }
>> >       SootMethod src =
>> > Scene.v().getMainClass().getMethodByName("doStuff");
>> >       CallGraph cg = Scene.v().getCallGraph();
>> >       Iterator<MethodOrMethodContext> targets = new
>> > Targets(cg.edgesOutOf(src));
>> >       while (targets.hasNext()) {
>> >           SootMethod tgt = (SootMethod)targets.next();
>> >           System.out.println(src + " may call " + tgt);
>> >       }
>> > }
>> >   }));
>> >            args = argsList.toArray(new String[0]);
>> >            soot.Main.main(args); // **** EXCEPTION THROWN HERE
>> > }
>> > }
>> > My test class looks like:
>> > package testers;
>> > public class CallGraphs
>> > {
>> > public static void doStuff() {
>> > StringBuilder b = new StringBuilder("Blah");
>> > b.append(" Blah");
>> > new A().foo();
>> > }
>> > }
>> > class A
>> > {
>> > public void foo() {
>> > bar();
>> > }
>> > public void bar() {
>> > }
>> > }
>> > I have also tried updating the EntryPoints list before the call
>> > to soot.Main.main(args) and this doesn't work either.
>> > When I do this, I get an error stating -
>> > Exception in thread "main" java.lang.RuntimeException: Aborting: can't
>> > find
>> > classfile testers.CallGraphs at soot.Scene.getSootClass(Scene.java:484)
>> > at
>> > dk.brics.soot.callgraphs.CallGraphExample.main(CallGraphExample.java:56)
>> > I'm using Eclipse 3.6 with the latest version of Soot. I'm really stuck
>> > and
>> > don't know what else to try. if anyone could
>> > help me out I would really appreciate it. As I mentioned, I have
>> > examined
>> > the archives but can't find a definitive answer.
>> > Thanks & regards
>> > JD
>> >> From: bodden at st.informatik.tu-darmstadt.de
>> >> Date: Fri, 22 Jul 2011 13:28:16 +0200
>> >> Subject: Re: [Soot-list] Building a call graph for a class that has no
>> >> main
>> >> To: jdsoot at hotmail.com
>> >> CC: soot-list at sable.mcgill.ca
>> >>
>> >> Hi John.
>> >>
>> >> This has been answered many times on the list. Please search the
>> >> archives for EntryPoints.
>> >>
>> >> Eric
>> >>
>> >> On 21 July 2011 23:03, John Dee <jdsoot at hotmail.com> wrote:
>> >> > Hi there.
>> >> > I refer to the example of building a class graph from the 'soot
>> >> > survivors
>> >> > guide':
>> >> > public static void main(String[] args) {
>> >> >   List<String> argsList = new ArrayList<String>(Arrays.asList(args));
>> >> >   argsList.addAll(Arrays.asList(new String[]{
>> >> >   "-w",
>> >> >   "-main-class",
>> >> >   "testers.CallGraphs",//main-class
>> >> >   "testers.CallGraphs",//argument classes
>> >> >   "testers.A" //
>> >> >   }));
>> >> >   PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans",
>> >> > new
>> >> > SceneTransformer() {
>> >> > @Override
>> >> > protected void internalTransform(String phaseName, Map options) {
>> >> >       CHATransformer.v().transform();
>> >> >                        SootClass a =
>> >> > Scene.v().getSootClass("testers.A");
>> >> >       SootMethod src =
>> >> > Scene.v().getMainClass().getMethodByName("doStuff");
>> >> >       CallGraph cg = Scene.v().getCallGraph();
>> >> >       Iterator<MethodOrMethodContext> targets = new
>> >> > Targets(cg.edgesOutOf(src));
>> >> >       while (targets.hasNext()) {
>> >> >           SootMethod tgt = (SootMethod)targets.next();
>> >> >           System.out.println(src + " may call " + tgt);
>> >> >       }
>> >> > }
>> >> >   }));
>> >> >            args = argsList.toArray(new String[0]);
>> >> >            soot.Main.main(args);
>> >> > }
>> >> > The above example works fine, except that class 'CallGraphs' contains
>> >> > a
>> >> > main
>> >> > method. However, the class that I want to analyse does
>> >> > not contain a main method. So, I'm wondering how I can set the method
>> >> > entry
>> >> > point?
>> >> > Thanks & Regards,
>> >> > JD
>> >> >
>> >> > _______________________________________________
>> >> > Soot-list mailing list
>> >> > Soot-list at sable.mcgill.ca
>> >> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Dr. Eric Bodden, http://bodden.de/
>> >> Principal Investigator in Secure Services at CASED
>> >> Coordinator of the CASED Advisory Board of Study Affairs
>> >> PostDoc at Software Technology Group, Technische Universität Darmstadt
>> >> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> >> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>> >
>> > _______________________________________________ Soot-list mailing list
>> > Soot-list at sable.mcgill.ca
>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> > _______________________________________________
>> > Soot-list mailing list
>> > Soot-list at sable.mcgill.ca
>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >
>> >
>>
>>
>>
>> --
>> Dr. Eric Bodden, http://bodden.de/
>> Principal Investigator in Secure Services at CASED
>> Coordinator of the CASED Advisory Board of Study Affairs
>> PostDoc at Software Technology Group, Technische Universität Darmstadt
>> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>



-- 
Dr. Eric Bodden, http://bodden.de/
Principal Investigator in Secure Services at CASED
Coordinator of the CASED Advisory Board of Study Affairs
PostDoc at Software Technology Group, Technische Universität Darmstadt
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt


More information about the Soot-list mailing list