From: pcm <pcm...@us...> - 2005-05-10 06:47:03
|
Update of /cvsroot/javapathfinder/javapathfinder/src/gov/nasa/jpf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15058/src/gov/nasa/jpf Added Files: ListenerAdapter.java Log Message: moved the idle loop detection out of the core and into gov.nasa.jpf.tools.IdleFilter listener, which is also a bit more sophisticated. It checks not just for back jump threshold, but abandons the test if it detects ArrayStoreInstructions or InvokeInstructions, assuming both are doing stuff that shouldn't be ignored. The thing can be made vastly more sophisticated, but it nicely shows what can be done with listeners. It passes the int[] a = new int[500]; // init loop -> pass for (int i=0; i<a.length; i++) a[i] = i; for (long l=0; l<1000000; l++); // bad idle loop -> filter test. To ease creation of listeners like this, I've also added a ListenerAdapter, which dummy implements both VMListener and SearchListener, so that tools only have to override their relevant notificatiion methods --- NEW FILE: ListenerAdapter.java --- // //Copyright (C) 2005 United States Government as represented by the //Administrator of the National Aeronautics and Space Administration //(NASA). All Rights Reserved. // //This software is distributed under the NASA Open Source Agreement //(NOSA), version 1.3. The NOSA has been approved by the Open Source //Initiative. See the file NOSA-1.3-JPF at the top of the distribution //directory tree for the complete NOSA document. // //THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY //KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT //LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO //SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR //A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT //THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT //DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. // package gov.nasa.jpf; /** * Adapter class that dummy implements both VMListener and SearchListener interfaces * Used to ease implementation of listeners that only process few notifications */ public class ListenerAdapter implements VMListener, SearchListener { /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#instructionExecuted(gov.nasa.jpf.VM) */ public void instructionExecuted(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#threadStarted(gov.nasa.jpf.VM) */ public void threadStarted(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#threadTerminated(gov.nasa.jpf.VM) */ public void threadTerminated(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#classLoaded(gov.nasa.jpf.VM) */ public void classLoaded(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#objectCreated(gov.nasa.jpf.VM) */ public void objectCreated(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#objectReleased(gov.nasa.jpf.VM) */ public void objectReleased(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#gcBegin(gov.nasa.jpf.VM) */ public void gcBegin(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#gcEnd(gov.nasa.jpf.VM) */ public void gcEnd(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.VMListener#exceptionThrown(gov.nasa.jpf.VM) */ public void exceptionThrown(VM vm) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#stateAdvanced(gov.nasa.jpf.Search) */ public void stateAdvanced(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#stateProcessed(gov.nasa.jpf.Search) */ public void stateProcessed(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#stateBacktracked(gov.nasa.jpf.Search) */ public void stateBacktracked(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#stateRestored(gov.nasa.jpf.Search) */ public void stateRestored(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#propertyViolated(gov.nasa.jpf.Search) */ public void propertyViolated(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#searchStarted(gov.nasa.jpf.Search) */ public void searchStarted(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#searchConstraintHit(gov.nasa.jpf.Search) */ public void searchConstraintHit(Search search) { } /* (non-Javadoc) * @see gov.nasa.jpf.SearchListener#searchFinished(gov.nasa.jpf.Search) */ public void searchFinished(Search search) { } } |