[Fb-contrib-commit] SF.net SVN: fb-contrib: [636] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-09-07 22:25:00
|
Revision: 636 http://svn.sourceforge.net/fb-contrib/?rev=636&view=rev Author: dbrosius Date: 2006-09-07 15:24:54 -0700 (Thu, 07 Sep 2006) Log Message: ----------- reduce false positives in LEST by, not looking at finally blocks, and tossing previous catch blocks when pc = handlerpc. This removes some reports due to nested exceptions in catch blocks, but better than too liberal. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-04 21:36:43 UTC (rev 635) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-09-07 22:24:54 UTC (rev 636) @@ -163,14 +163,19 @@ int pc = getPC(); for (CodeException ex : exceptions) { if (pc == ex.getEndPC()) { - if ((seen >= IRETURN) && (seen <= RETURN)) - addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); - else if ((seen == GOTO) || (seen == GOTO_W)) - addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); - else - addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + if (ex.getCatchType() != 0) + { + if ((seen >= IRETURN) && (seen <= RETURN)) + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + else if ((seen == GOTO) || (seen == GOTO_W)) + addCatchBlock(ex.getHandlerPC(), this.getBranchTarget()); + else + addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE); + } return; - } + } else if (pc == ex.getHandlerPC()) { + removePreviousHandlers(pc); + } } Iterator<CatchInfo> it = catchInfos.iterator(); @@ -178,21 +183,8 @@ try { CatchInfo catchInfo = it.next(); if (pc == catchInfo.getStart()) { - if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - int reg = RegisterUtils.getAStoreReg(this, seen); - catchInfo.setReg(reg); - exReg.put(Integer14.valueOf(reg), Boolean.TRUE); - LocalVariableTable lvt = getMethod().getLocalVariableTable(); - if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, pc+2); - if (lv != null) { - int finish = lv.getStartPC() + lv.getLength(); - if (finish < catchInfo.getFinish()) - catchInfo.setFinish(finish); - } - } - break; - } + updateExceptionRegister(catchInfo, seen, pc); + break; } else if (pc > catchInfo.getFinish()) { it.remove(); break; @@ -265,6 +257,34 @@ } } + private void removePreviousHandlers(int pc) + { + //This unnecessarily squashes some nested catch blocks, but better than false positives + Iterator<CatchInfo> it = catchInfos.iterator(); + while (it.hasNext()) { + CatchInfo ci = it.next(); + if (ci.getStart() < pc) + it.remove(); + } + } + + private void updateExceptionRegister(CatchInfo ci, int seen, int pc) { + if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + int reg = RegisterUtils.getAStoreReg(this, seen); + ci.setReg(reg); + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(reg, pc+2); + if (lv != null) { + int finish = lv.getStartPC() + lv.getLength(); + if (finish < ci.getFinish()) + ci.setFinish(finish); + } + } + } + } + private void addCatchBlock(int start, int finish) { CatchInfo ci = new CatchInfo(start, finish); catchInfos.add(ci); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |