Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

JPF.java

00001 package gov.nasa.arc.ase.jpf;
00002 
00003 import java.io.PrintStream;
00004 import java.io.FileOutputStream;
00005 import java.io.IOException;
00006 
00007 import gov.nasa.arc.ase.util.Debug;
00008 import gov.nasa.arc.ase.util.kMG;
00009 import gov.nasa.arc.ase.util.Comma;
00010 
00011 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00012 
00013 //#ifdef LOCK_ORDER
00014 
00015 //#endif LOCK_ORDER
00016 
00017 /**
00018  * This class contains references to the different object that
00019  * make a verification run.
00020  *
00021  * @author Flavio Lerda
00022  * @version 1.0
00023  * @since 1.0
00024  */
00025 public class JPF implements Runnable {
00026   /**
00027    * Used to store the states.
00028    */
00029   public iStore          store;
00030 
00031   /**
00032    * Maintains the current status of the model checker.
00033    */
00034   public Status     status;
00035 
00036   /**
00037    * Generates period reports.
00038    */
00039   public iReporter  reporter;
00040 
00041   /**
00042    * Reference to the virtual machine used by the model checker.
00043    */
00044   public iVirtualMachine vm;
00045 
00046   /**
00047    * The search engine used to visit the state space.
00048    */
00049   public iSearch         search;
00050 
00051 //#ifdef BUCHI
00052 
00053   /**
00054    * Buchi automaton that represent the property to be checked.
00055    */ 
00056   public SM     buchi;
00057 
00058 //#endif BUCHI
00059 
00060   /**
00061    * Time of the last report.
00062    */
00063   protected long lastReportTime = System.currentTimeMillis();
00064 
00065   /**
00066    * Number of transition in last report.
00067    */
00068   protected int lastReportTransitions = 0;
00069 
00070   /**
00071    * Initialize the model checking environment.
00072    */
00073   public JPF() {
00074   }  
00075   /**
00076    * Called after the virtual machine has been initialized.
00077    */
00078   public void initialized() {
00079   }  
00080   /**
00081    * Prints the results of the verification.
00082    */
00083   private void printResults() {
00084     if(search.hasFailed()) {
00085 //#ifdef BANDERA
00086       if(Engine.options.bandera)
00087     vm.ShowErrorTrail(search.getErrorPath());
00088       else {
00089 //#endif BANDERA
00090     vm.getErrorTrail_to_file();
00091     search.getError().print();
00092     try {
00093       PrintStream out = new PrintStream(new FileOutputStream("error.trail"));
00094       search.getError().print(out);
00095       out.close();
00096     } catch(IOException e) {
00097     }
00098     printResults(search.getErrorMessage());
00099 //#ifdef BANDERA
00100       }
00101 //#endif BANDERA
00102     } else
00103       printResults(search.getErrorMessage());
00104   }  
00105   /**
00106    * Prints the results contained in the status field. 
00107    *
00108    * @param msg a string that has to be printed as the result of the verification
00109    */
00110   private void printResults(String msg) {
00111     Debug.println(Debug.ERROR);
00112     Debug.println(Debug.ERROR);
00113     Debug.println(Debug.ERROR, "===================================");
00114     Debug.println(Debug.ERROR, msg);
00115     Debug.println(Debug.ERROR, "===================================");
00116     Debug.println(Debug.ERROR);
00117     status.print();
00118   }  
00119   /**
00120    * Prints a periodic one line report.
00121    */
00122   public void report() {
00123 //#ifdef COVERAGE
00124 
00125 
00126 
00127 
00128 
00129 
00130 //#endif COVERAGE
00131 
00132     long currentTime = System.currentTimeMillis();
00133     lastReportTransitions = 
00134       status.report(currentTime - lastReportTime, lastReportTransitions);
00135     lastReportTime = currentTime;
00136   }  
00137   /**
00138    * Executes the verification.
00139    */ 
00140   public void run() {
00141     if(!Engine.options.interactive)
00142       reporter.start();
00143     search.search();
00144     if(!Engine.options.interactive)
00145       reporter.stop();
00146 
00147 //#ifdef LOCK_ORDER
00148 
00149 
00150 //#endif LOCK_ORDER
00151     printResults();
00152   }  
00153 }

Generated at Thu Feb 7 06:48:52 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001