[Soot-list] data flow analysis problem

yangbo at sei.buaa.edu.cn yangbo at sei.buaa.edu.cn
Mon Jul 15 21:14:22 EDT 2013


Hello ,
This is 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];         (1)            
			
a[R1]=R0;         
			
a[R3]=R2;            (2)
			
R1=R1+1;
		
}
	
}
There are two statements (1) and (2)
(1) R2 = a[R1]; 
This statement's jimple code are:
      temp$17 = a;
      temp$18 = R1;
      temp$19 = temp$17[temp$18];
      R2 = temp$19;
(2) a[R3]=R2;
    This statement's jimple code are:
    temp$23 = R3;
    temp$22 = a
    temp$22[temp$23] = R2;
I get the def var  “a” and “R1″ in statement (1) with “private HashSet defsOf( Local l )” method in SmartLocalDefs. I think def var is R2 and use var are
 “a” and “R1″ in (1), So I think maybe this is a problem.
I get the use var “a” and “R3″ in  statement  (2) with SmartLocalDefs. You said this is valid for replying other user, However how to find def var in 
statement (2)?
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;
	
}
I want to know how to get def and var of a array variable.  Could you give me a hand? May be a small example is good.
Bo Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130716/74732ff7/attachment-0001.html 


More information about the Soot-list mailing list