00001 package edu.ksu.cis.bandera.prog;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 import ca.mcgill.sable.util.*;
00037 import ca.mcgill.sable.soot.*;
00038 import ca.mcgill.sable.soot.jimple.*;
00039
00040 import edu.ksu.cis.bandera.prog.DomAnalysis;
00041 import edu.ksu.cis.bandera.prog.PostdomAnalysis;
00042 import edu.ksu.cis.bandera.prog.BackEdgeAnalysis;
00043
00044 public class TestDom
00045 {
00046 public static void main(String[] args)
00047 {
00048 SootClassManager cm = new SootClassManager();
00049 SootClass sClass = cm.getClass(args[0]);
00050 sClass.resolveIfNecessary();
00051
00052 BuildAndStoreBody bd =
00053 new BuildAndStoreBody(Jimple.v(),
00054 new StoredBody(ClassFile.v()),
00055 BuildJimpleBodyOption.NO_PACKING);
00056
00057 Iterator methodIt = sClass.getMethods().iterator();
00058
00059 while(methodIt.hasNext())
00060 {
00061 SootMethod m = (SootMethod) methodIt.next();
00062 bd.resolveFor(m);
00063 JimpleBody body = (JimpleBody) new StoredBody(Jimple.v()).resolveFor(m);
00064 StmtList stmtList = body.getStmtList();
00065 CompleteStmtGraph stmtGraph = new CompleteStmtGraph(stmtList);
00066
00067
00068 DomAnalysis da = new DomAnalysis(stmtList, stmtGraph);
00069 Map domMap = da.stmtToDominatorsMap();
00070 System.out.println("\n dominators map for method : " + m.getName());
00071 System.out.println(domMap);
00072
00073
00074 Map immdomMap = da.stmtToImmediateDom();
00075 System.out.println("\n immediate dominators map for method : " + m.getName());
00076 System.out.println(immdomMap);
00077
00078
00079 PostdomAnalysis pda = new PostdomAnalysis(stmtList, stmtGraph);
00080 Map postdomMap = pda.stmtToPostdominatorsMap();
00081 System.out.println("\n post-dominators map for method : " + m.getName());
00082 System.out.println(postdomMap);
00083
00084
00085 Map immpostdomMap = pda.stmtToImmediatePostdom();
00086 System.out.println("\n immediate post-dominators map for method : " + m.getName());
00087 System.out.println(immpostdomMap);
00088
00089
00090
00091 BackEdgeAnalysis bea = new BackEdgeAnalysis(stmtList, stmtGraph);
00092 List edgeList = bea.backEdgeList();
00093 System.out.println("\n back edge list for method: " + m.getName());
00094 System.out.println(edgeList);
00095 }
00096 }
00097 }