[Soot-list] soot
Raghav Karol
raghav.karol at gmail.com
Thu Oct 5 03:33:03 EDT 2006
Before each run you should use a
G.v().reset();
On 10/5/06, Peng Li <lipeng360 at gmail.com> wrote:
> HI
> I am using soot to analyze multiple class files. The method what I am using
> is to run soot.Main.main(args) multiple times and each time give different
> "args" to soot.Main.main(); . However, the first soot run is ok, the second
> soot run gives me the following mistakes.
>
> java.lang.RuntimeException: This operation requires resolving level
> SIGNATURES but
> com.oreilly.struts.storefront.order.ShoppingCartActions is
> at resolving level HIERARCHY
> ("com.oreilly.struts.storefront.order.ShoppingCartActions "
> is the 2nd class name which is passed to soot.Main.main() )
>
> The method what I am using looks very silly because it restarts soot many
> time (depending on how many classes you have.). I am wondering if there are
> any good ways to run soot analysis for multiple classes. Could anyone help
> me to figure out my problem?
>
> Thank you very much for your help.
>
> Cheers
>
> Peng
>
>
> import soot.*;
> import soot.jimple.*;
> import soot.toolkits.graph.BriefUnitGraph;
> import soot.util.*;
> import java.util.*;
>
> public class ReturnInstrumenter extends BodyTransformer{
> private static ReturnInstrumenter instance = new ReturnInstrumenter();
> private ReturnInstrumenter() {}
>
> public static ReturnInstrumenter v() { return instance; }
>
> public static void main(String[] args)
> {
> String[]
> a={"com.oreilly.struts.storefront.order.CheckoutAction"};
> String[]
> b={"com.oreilly.struts.storefront.order.ShoppingCartActions
> "};
>
> Scene.v().setSootClassPath("C:/workspace/ReturnValue/sootOutput;C:/j2sdk1.4.2_12/jre/lib/rt.jar");
> PhaseOptions.v().setPhaseOption("jop", "on");
> PackManager.v ().getPack("jtp").add(new Transform("jtp.instrumenter",
> ReturnInstrumenter.v()));
>
> Scene.v().addBasicClass("java.io.PrintStream",SootClass.SIGNATURES);
> soot.Main.main(a);
> soot.Main.main(b);
> }
>
> protected void internalTransform(Body body, String phase, Map options) {
> BriefUnitGraph cfg=new BriefUnitGraph(body);
> SootMethod method = body.getMethod();
> System.out.println("instrumenting method : " + method.getSignature());
> Chain units = body.getUnits();
> Iterator stmtIt = units.snapshotIterator();
> while(stmtIt.hasNext())
> {
> Stmt stmt = (Stmt) stmtIt.next();
> if(stmt instanceof ReturnStmt)
> {
>
> List predlist=cfg.getPredsOf(stmt);
> Stmt invokstmt = (Stmt) predlist.get(0);
> InvokeExpr invokexpr = invokstmt.getInvokeExpr();
> System.out.println(invokexpr.getArg(0));
>
> } }}
>
>
>
> Output
>
> Soot started on Thu Oct 05 07:43:03 CST 2006
> Transforming
> com.oreilly.struts.storefront.order.CheckoutAction...
> instrumenting method :
> <com.oreilly.struts.storefront.order.CheckoutAction: void
> <init>()>
> instrumenting method :
> <com.oreilly.struts.storefront.order.CheckoutAction:
> org.apache.struts.action.ActionForward
> execute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest
> ,javax.servlet.http.HttpServletResponse)>
> "Login"
> "Success"
> Writing to
> sootOutput\com\oreilly\struts\storefront\order\CheckoutAction.class
> Soot finished on Thu Oct 05 07:43:04 CST 2006
> Soot has run for 0 min. 1 sec.
> Soot started on Thu Oct 05 07:43:04 CST 2006
> java.lang.RuntimeException: This operation requires resolving level
> SIGNATURES but
> com.oreilly.struts.storefront.order.ShoppingCartActions is
> at resolving level HIERARCHY
> at soot.SootClass.checkLevel(SootClass.java:126)
> at soot.SootClass.addMethod(SootClass.java:581)
> at soot.coffi.Util.resolveFromClassFile(Util.java:252)
> at soot.CoffiClassSource.resolve(CoffiClassSource.java :37)
> at
> soot.SootResolver.bringToHierarchy(SootResolver.java:148)
> at
> soot.SootResolver.bringToSignatures(SootResolver.java:172)
> at
> soot.SootResolver.processResolveWorklist(SootResolver.java:104)
> at soot.SootResolver.resolveClass (SootResolver.java:89)
> at soot.Scene.loadClass(Scene.java:329)
> at soot.Scene.loadClassAndSupport(Scene.java:314)
> at soot.Scene.loadNecessaryClass(Scene.java:861)
> at soot.Scene.loadNecessaryClasses(Scene.java :880)
> at soot.Main.run(Main.java:177)
> at soot.Main.main(Main.java:153)
> at ReturnInstrumenter.main(ReturnInstrumenter.java:29)
> Exception in thread "main"
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>
>
--
Raghav
MSc., Student
Informatics and Mathematical Modeling
Technical University of Denmark
+45 606 31 639
More information about the Soot-list
mailing list