[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another CFG problem.
A quick hack is to change two lines code, but it will trigger a bug in
jasmin parser. Changes in jasmin parser are necessary (see below).
> (Merge-Parents)
Index: 1.2.2.dev.41/src/soot/coffi/CFG.java
868c868,869
< Instruction newdefault = (Instruction)replacedInsns.get(switchinsn.default_inst);
---
> Instruction newdefault =
> (Instruction)replacedInsns.get(switchinsn.default_inst);
874,875c875,876
<
< for (int i=0; i<switchinsn.match_insts.length; i++)
---
>
> for (int i=0; i<switchinsn.npairs; i++)
877c878,879
< Instruction newtgt = (Instruction)replacedInsns.get(switchinsn.match_insts[i]);
---
> Instruction newtgt =
> (Instruction)replacedInsns.get(switchinsn.match_insts[i]);
898c900
< for (int i=0; i<switchinsn.jump_insts.length; i++)
---
> for (int i=0; i<switchinsn.high-switchinsn.low; i++)
900c902,903
< Instruction newtgt = (Instruction)replacedInsns.get(switchinsn.jump_insts[i]);
---
> Instruction newtgt =
> (Instruction)replacedInsns.get(switchinsn.jump_insts[i]);
Temporarily fix-up in Jasmin parser :
jasmin/src/jasmin/parser.cup
lookup ::=
lookup_args
lookup_list_t
lookup_default
;
lookup_list_t ::=
| lookup_list
;
table ::=
table_args
table_list_t
table_default
;
table_list_t ::=
| table_list
;
====================
Feng Qian fqian@sable.mcgill.ca
On Fri, 5 Oct 2001, Stephen Andrew Neuendorffer wrote:
> The code below:
>
> package ptolemy.copernicus.java.test;
>
> public class test {
> public static int s[] = new int[5];
>
> public static final int foo() {
> int i = 1;
> int startsAt = 0;
>
> for (;;) {
> MatchLoop:
> do {
> switch(s[--i]) {
> default : break;
> }
> } while(i != startsAt);
> }
> }
> }
>
> compiled into the attached class file throws an exception:
>
> Transforming ptolemy.copernicus.java.test... java.lang.NullPointerException
> at soot.coffi.CFG.adjustBranchTargets(CFG.java:735)
> at soot.coffi.CFG.eliminateJsrRets(CFG.java:456)
> at soot.coffi.CFG.<init>(CFG.java:85)
> at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:87)
> at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:83)
> at soot.SootMethod.retrieveActiveBody(SootMethod.java:276)
> at soot.Main.handleClass(Main.java:1795)
> at soot.Main.run(Main.java:1557)
> at java.lang.Thread.run(Thread.java:484)
>
> It appears that the switch is not being handled properly?
> This is a stripped down example of some code generated using JavaCC using
> the standard soot 1.2.2 and jdk1.3.1
>
> Steve