[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question on Strins in PointsToSet



Let us consider the analysis of the following program with a modified
version of soot using a custom transform added to the wjtp phase.

class B {
	String s1 = "aaa";
	static String s2 = "bbb";
	
	void m() {
		f(s1);
		f(s2);
	}
}

I am trying to analyze the arguments of f. I use a 'LocalDefs' analysis
to get the definition of locals in methods and the Spark PointsToAnalysis
to get the propagation of allocation to variables 
(option -p cg.spark enabled:true).

I have seen in the documentation that Strings receive a special treatment 
and that constant strings are propagated in PointsToSets but I do not manage
to get it working.

For f(s2), I only get that the definition is an assignment following a 
field dereference where the object is r0 (self) but the PointsToSet is empty.
Here is the code (without any coercion test but this is not the problem).
stmt is the statement containing the definition of the local used as
argument of f :

  Value r = ((JAssignStmt) stmt).getRightOp ();
  InstanceFieldRef fr = (InstanceFieldRef) r;
  Local b = (Local) fr.getBase();
  PointsToSet fdefs = pag.reachingObjects((Local) b,fr.getField());
  Set result = fdefs.possibleStringConstants();

and for s1, it contains an AllocNode but not a ConstantStringNode. The
corresponding code for a static field is :

  Value r = ((JAssignStmt) stmt).getRightOp ();
  StaticFieldRef fr = (StaticFieldRef) r;
  PointsToSet fdefs = pag.reachingObjects(fr.getField());
  Set result = possibleStringConstants((PointsToSetInternal) fdefs);

What am I doing wrong ? Is there something to trigger the special treatment
of strings ? As a new user, am I just expecting too much from the Spark 
propagation algorithm ?
Thank you in advance for your help,

Pierre Cregut

-- 
Pierre Cregut - pierre.cregut@rd.francetelecom.com - +33 2 96 05 16 28
FTR&D - DTL/TAL - 2 avenue Pierre Marzin - 22307 Lannion Cedex - France