我通过烟尘对类文件进行静态分析。我必须分别获取try和catch块中的语句。我使用以下代码来获取异常处理程序的成功:
private static void test(SootMethod method){
JimpleBody b = (JimpleBody) method.retrieveActiveBody();
Chain<Trap> trapChain = b.getTraps();
ExceptionalUnitGraph g = new ExceptionalUnitGraph(b);
Iterator<Unit> unitIter = g.iterator();
while (unitIter.hasNext()) {
Unit u = unitIter.next();
Iterator<Trap> trapIter = trapChain.iterator();
while(trapIter.hasNext()){
Trap trap = trapIter.next();
if(u.equals(trap.getHandlerUnit())){
System.out.println("excep: "+ u.toString());
List<Unit> list = g.getExceptionalSuccsOf(u);
for(int i = 0;i<list.size();i++){
System.out.println("Succs: "+list.get(i));
}
break;
}
}
}
}
但是,结果仅包含catch块的条目,例如:e = $r6
,那么如何获取catch块中的所有语句?