[Soot-list] Printing an ExceptionalUnitGraph
John Jorgensen
jorgnsn at lcd.uregina.ca
Sun Nov 4 16:12:41 EST 2007
>>>>> "irem" == irem <irem at nada.kth.se> writes:
irem> public String toString() {
irem> Iterator it = unitChain.iterator();
irem> StringBuffer buf = new StringBuffer();
irem> while(it.hasNext()) {
irem> Unit u = (Unit) it.next();
irem> buf.append("// preds: "+getPredsOf(u)+"\n");
irem> buf.append("// unexceptional preds:
irem> "+getUnexceptionalPredsOf(u)+"\n");
irem> buf.append("// exceptional preds:
irem> "+getExceptionalPredsOf(u)+"\n");
irem> buf.append(u.toString() + '\n');
irem> buf.append("// exception destinations:
irem> "+getExceptionDests(u)+"\n");
irem> buf.append("// unexceptional succs:
irem> "+getUnexceptionalPredsOf(u)+"\n");
irem> buf.append("// exceptional succs:
irem> "+getExceptionalPredsOf(u)+"\n");
irem> buf.append("// succs "+getSuccsOf(u)+"\n");
irem> }
irem> return buf.toString();
irem> }
irem> As you see, it does not print the successors, rather again the
irem> predecessors.
You're right, it's wrong. Thanks for pointing out the error.
Somebody else must have noticed this last summer, since Eric
Bodden committed a fix to the Soot repository in July.
That fix was too recent to make it into the Soot 2.2.4 release,
but I think you could simply download the single corrected file
from
http://svn.sable.mcgill.ca/viewcvs/soot/trunk/src/soot/toolkits/graph/ExceptionalUnitGraph.java?logsort=date&rev=2948&view=markup
and use it to replace the file in the 2.2.4 source.
Incidentally, since you're inspecting control flow graphs, I'd
suggest you try out Soot's "--dump-cfg <phasename>" option, which
produces input files that you can feed to the "dot" command (from
graphviz, http://www.graphviz.org) in order to generate
visualizations of the CFGs.
You need to learn a bit about Soot's phase structure in order to
know what to put in place of <phasename>, but I found the
resulting CFG pictures easier to interpret than textual
representations. Come to think of it, it could be that the
reason I never noticed the bug in ExceptionalUnitGraph.toString()
was that I always looked at the visualizations instead.
There's more about using the CFG visualizations in the mailing
list archive, at
http://www.sable.mcgill.ca/pipermail/soot-list/2006-April/000656.html
More information about the Soot-list
mailing list