[Soot-list] data flow problem (Quentin Sabah)

yangbo at sei.buaa.edu.cn yangbo at sei.buaa.edu.cn
Mon Jul 15 06:12:52 EDT 2013


Hello 
This is a draft of the testing code I wrote to get the def and use var of a local
variable in a method.
  public void Test(int a[], int N){
		
int R0,R1,R2,R3;
		
R0 = 0;
		
R1 = 0;
		
R2 = 0;
		
R3 = 0;
		
while(R1 < N){
			
R0 = a[R1];
			
R2 = R1 + 2;
			
R3 = R1;
			
while(R2 < N){
				
if(a[R2] > R0){
					
R0 = a[R2];
					
R3 = R2;
				
}
				
R2 = R2 + 1;
			
}
			
R2 = a[R1];                  
			
a[R1]=R0;            (1)
			
a[R3]=R2;            (2)
			
R1=R1+1;
		
}
	
}
here are two statements (1) and (2)
(1) a[R1]=R0;  
(2) a[R3]=R2;
I will get the def var  “a” and “R1″ in statement (1) with “private HashSet defsOf( Local l )” method in SmartLocalDefs.
I will get the use var “a” and “R3″ in  statement  (2) with SmartLocalDefs
This is modified defsOf method in SmartLocalDefs. just add printlf statements.
public static HashSet<Unit> defsOf(Local l) {
		
HashSet<Unit> ret = localToDefs.get(l);
		
if (ret == null){
			
localToDefs.put(l, ret = new HashSet<Unit>());
		
}else{
			
Iterator defTemp = ret.iterator();
			
while(defTemp.hasNext()){
				
Unit temp = (Unit) defTemp.next();
				
System.out.println("Local:"+l.getName()+" defsOfLocal:"+temp.toString());
			
}
		
}
		
return ret;
	
}
Best Regard.
Bo Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130715/5c520acd/attachment.html 


More information about the Soot-list mailing list