[Soot-list] Extracting information from Spark
Antonina Khairova
antonina.khairova at vxu.se
Thu Feb 5 09:15:48 EST 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090205/d00c7ac8/attachment.html
More information about the Soot-list
mailing list