[Soot-list] Fw: Extracting information from Spark

Antonina Khairova antonina.khairova at vxu.se
Thu Feb 5 10:02:14 EST 2009


Thanks Eric! I tried this method, but I need something else for extraction.
E.g. I have simple code as an input:
public class BB {

BB myA;//line2

int booka; //line 3

public static void main(String ... args) {

BB a = new BB(); // line 5

BB a2 = new BB(); // line 6

a.myA = new BB(); //line 8

a2.myA = a; //line 9

a2.myA = a.myA; // line 10

a=a2; //line 11

}

}



I need next output:

For the line 8 (assign statement):

=====[type BB(line 6), field: myA]====[ type BB from line 5] - this is done
in the way I put here befor, BUT!

I nee next:

For the line 10:

=====[type BB(line 6), field: myA]====[ type BB from line 8]

I can do it, but I just have to write my own analysis through the code.

Is there any method to do it easier?



Best, Antonina


 > ----- Original Message ----- 
> From: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
> To: "Antonina Khairova" <antonina.khairova at vxu.se>
> Cc: <soot-list at sable.mcgill.ca>
> Sent: Thursday, February 05, 2009 3:27 PM
> Subject: Re: [Soot-list] Extracting information from Spark
>
>
> 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