[Soot-list] Extracting information from Spark

Eric Bodden eric.bodden at mail.mcgill.ca
Thu Feb 5 09:27:46 EST 2009


Hi Antonina.

What are you trying to do with Spark? Just ordinary points-to
analysis? If this is the case, that's pretty simple:

PointsToAnalysis pta = Scene.v().getPointsToAnalysis();
PointsToSet p1 = pta.reachingObjects(l1);
PointsToSet p2 = pta.reachingObjects(l2);
if(p1.hasNonEmptyIntersection(p2)) {
  //l1,l2 may point to the sae objects
} else {
  //they may not
}

Hope that helps.

Eric

2009/2/5 Antonina Khairova <antonina.khairova at vxu.se>:
> Hi all. I gave just started work with Spark in my Eclipse project.
> I would like to know how I can extract the information after the code was
> analyzed by Spark. I do it like this:
> I go through all the classes and through all the methods in the class, look
> for statements there and then If the statement includes local variables I
> put the line of va and var in the hash map. Then I process the statements
> again and look for assign statements, so the part of my code look like this:
>
>
>
> if
>
> (s instanceof AssignStmt)
>
> {
>
> System.
>
> out.println("AssignStatement: " + ((AssignStmt)s).toString() + " :line:"+
> line);
>
> Value leftOp = ((AssignStmt) s).getLeftOp();
>
> Value rightOp = ((AssignStmt) s).getRightOp();
>
> String left = "";
>
> String right =
>
> "";
>
> if (leftOp instanceof JimpleLocal)
>
> {
>
> JimpleLocal jl = (JimpleLocal)leftOp;
>
> if (jl.getName().charAt(0)== '$')
>
> {
>
> refer.put(leftOp, rightOp);
>
> }
>
> if (jl.getName().charAt(0) != '$')
>
> {
>
> left = "[JL: type " + jl.getType() + " from line " + map.get(leftOp) + "]";
>
> }
>
> }
>
> else if (leftOp instanceof JInstanceFieldRef)
>
> {
>
> JInstanceFieldRef ifr = (JInstanceFieldRef)leftOp;
>
> SootFieldRef fr = ifr.getFieldRef();
>
> left = "[FR: Class " + fr.declaringClass().toString() + "(line " +
> map.get(ifr.getBaseBox().getValue()).toString() + ")" + ", field: " +
> fr.name() + "]";
>
> }
>
> if (rightOp instanceof JimpleLocal)
>
> {
>
> JimpleLocal jl = (JimpleLocal)rightOp;
>
> if (jl.getName().charAt(0) == '$')
>
> {
>
> right=getOpString((Value)refer.get(rightOp),map);
>
> Type type =jl.getType();
>
> int numb =jl.getNumber();
>
> String name =jl.getName();
>
> System.
>
> out.println("");
>
> }
>
> if (jl.getName().charAt(0) != '$')
>
> {
>
> right = "[JL: type " + jl.getType() + " from line " + map.get(rightOp) +
> "]";
>
>
>
> }
>
> }
>
> else if (rightOp instanceof JInstanceFieldRef)
>
> {
>
> JInstanceFieldRef ifr = (JInstanceFieldRef)rightOp;
>
> SootFieldRef fr = ifr.getFieldRef();
>
>
>
> right =
>
> "[FR: Class " + fr.declaringClass().toString() + "(line " +
> map.get(ifr.getBaseBox().getValue()).toString() + ")" + ", field: " +
> fr.name() + "]";
>
>
>
> }
>
> if (left.length() > 0 && right.length() > 0)
>
> System.
>
> out.println("====="+left + "====" + right);
>
> lastStmt = (AssignStmt)s;
>
>
>
> }
>
>
>
>
>
>
>
> Im not really sure that is the right desision, I think should be more clever
> than this one. But I haven't found any examples how to extract the
> information from Spark.
>
>
>
> Looking forward hearing your answers.
>
>
>
> Thanks for help. Antonina
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>



-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada


More information about the Soot-list mailing list