[Soot-list] one bug in the MHGPostDominatorsFinder?

jiangfan shi jiangfan.shi at gmail.com
Tue Oct 27 18:01:00 EDT 2009


Dear All,

I want to use the MHGPostDominatorsFinder to compute the post dominator and
immediate post dominator. But when I apply it to the following code, I found
there maybe some errors in the result. Correct me, if I am wrong here.

The analyzed Java source code:

package testPDG;

public class forSootDiscussion {

public static void main(String[] args ){
 int i=1;
 int sum=0;
 if(i<10){
sum=i+10;
sum=sum*100;
 }else{
i=i-10;
sum=sum*101;
 }
 i=0;
 }
}

The transformed Jimple source code:

  public static void main(java.lang.String[])
    {
        java.lang.String[] r0;
        byte b0, b1;
        int i2, i3, i4, i5;
        boolean z0;

        r0 := @parameter0: java.lang.String[];
        b0 = 1;
        b1 = 0;
        if b0 >= 10 goto label0;

        i2 = b0 + 10;
        i3 = i2 * 100;
        goto label1;

     label0:
        i4 = b0 + -10;
        i5 = b1 * 101;

     label1:
        z0 = 0;
        return;
    }

The main code snippet of using MHGPostDominatorsFinder is the following:


if (method.getSignature().contains("main")) {
Body b = method.retrieveActiveBody();
 UnitGraph g = new ExceptionalUnitGraph(b);
MHGPostDominatorsFinder dom = new MHGPostDominatorsFinder(g);

/**
 * print out if statement's post dominators
  */
Iterator unitIt = g.iterator();
while (unitIt.hasNext()) {
 Unit s = (Unit) unitIt.next();
Stmt tmp = (Stmt) s;
if (tmp instanceof IfStmt) {
 IfStmt ifstmt = (IfStmt) tmp;
List<Stmt> tmplist = dom.getDominators(ifstmt);

System.out.println(ifstmt.toString()
+ "'s post domainators are shown below");
 for (int i = 0; i < tmplist.size(); i++) {
System.out.println(tmplist.get(i));
 }

System.out
.println(ifstmt.toString()
 + "'s immediate post domainator is shown below");

Stmt tmpdom = (Stmt) dom
 .getImmediateDominator(ifstmt);
System.out.println(tmpdom.toString());

}

}
}

I attached the CFG of the Jimple in this email.

The analyzed results for the if statement "if b0 >= 10 goto i4 = b0 + -10"
are shown below:

The immediate post dominator: return
The post dominator set: return, if b0 >= 10 goto i4 = b0 + -10.

Based on my understanding, the immediate post dominator should be "z0=0",
which is also missing in the post dominator set.

Do I miss any options for the MHGPostDominatorsFinder?

Any suggestions and comments are appreciated.

jiangfan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20091027/6200d68f/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg.jpg
Type: image/jpeg
Size: 27561 bytes
Desc: not available
Url : http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20091027/6200d68f/attachment-0001.jpg 


More information about the Soot-list mailing list