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

Engine.java

00001 package gov.nasa.arc.ase.jpf;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00004 import gov.nasa.arc.ase.util.Debug;
00005 import gov.nasa.arc.ase.util.Options;
00006 import gov.nasa.arc.ase.util.Statistics;
00007 //#ifdef HEURISTIC
00008 
00009 //#endif HEURISTIC
00010 import java.io.*;
00011 import java.net.*;
00012 import java.util.*;
00013 //#ifdef DISTRIBUTED
00014 
00015 //#endif DISTRIBUTED
00016 //#ifdef RACE || LOCK_ORDER
00017 
00018 
00019 //#endif RACE || LOCK_ORDER
00020 //#ifdef JDK11
00021 
00022 //#endif JDK11
00023 //#ifdef PARALLEL
00024 
00025 //#endif PARALLEL
00026 
00027 /**
00028  * Main engine of the model checker.
00029  *
00030  * @author Flavio Lerda
00031  * @author Willem Visser
00032  * @version 1.0
00033  * @since 1.0
00034  */
00035 public class Engine {
00036   /**
00037    * A String containing the version of the model checker engine. This field is
00038    * used to output the version information.
00039    *
00040    * @see #start()
00041    */
00042   public static String VERSION = "JPF 0.1 - (C) 2000 RIACS/NASA Ames Research Center";
00043 
00044   /**
00045    * Parsed program arguments.
00046    */
00047   public static JPFOptions      options;
00048 
00049   /**
00050    * Arguments given to the model checker.
00051    */
00052   public static String[]    arguments;
00053 
00054   /**
00055    * Facility used to maintain statistics about the verification.
00056    */
00057   public static Statistics  statistics;
00058 
00059   /**
00060    * Local object which contains all the thread specific information.
00061    * Used by the parallel version in order to have this information accessible
00062    * without passing a reference thorught each method call, and avoiding to have
00063    * to share it between the threads.
00064    */
00065 //#ifdef BANDERA
00066   private static JPF xjpf;
00067 //#ifdef PARALLEL
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 //#endif PARALLEL
00168 //#ifdef PARALLEL
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 //#ifdef JDK11
00180 
00181 //#endif JDK11
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 //#endif PARALLEL
00243 
00244 //#ifdef RACE || LOCK_ORDER
00245 
00246 
00247 
00248 
00249 
00250 
00251 //#ifdef DEBUG
00252 
00253 //#endif DEBUG
00254 
00255 
00256 
00257 
00258 
00259 
00260 //#ifdef RACE && LOCK_ORDER
00261 
00262 
00263 
00264 
00265 
00266 //#else RACE && LOCK_ORDER
00267 
00268 //#ifdef RACE
00269 
00270 
00271 
00272 
00273 //#endif RACE
00274 
00275 //#ifdef LOCK_ORDER
00276 
00277 
00278 
00279 
00280 //#endif LOCK_ORDER
00281 
00282 //#endif RACE && LOCK_ORDER
00283 
00284 
00285 
00286 //#ifdef RACE
00287 
00288 //#endif RACE
00289 //#ifdef LOCK_ORDER
00290 
00291 //#endif LOCK_ORDER
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 //#endif RACE
00304 
00305   /**
00306    * Accesses the thread local copy of a JPF object.
00307    *
00308    * @return the local JPF object
00309    */
00310   public static JPF getJPF() {
00311 //#ifdef BANDERA
00312     return xjpf;
00313 //#else BANDERA
00314 
00315 //#endif BANDERA
00316   }  
00317 //#else BANDERA
00318 //#ifdef JDK11
00319 
00320 //#else JDK11
00321 
00322 //#endif JDK11
00323 //#endif BANDERA
00324 
00325   /**
00326    * Initialize the model checker.
00327    * <UL>
00328    * <LI>Prints the version information.
00329    * <LI>Parses the program arguments in the options field.
00330    * <LI>Check for correctness of the arguments.
00331    * <LI>Handles the -help and -version switches.
00332    * <LI>Prints the current options if necessary.
00333    * </UL>
00334    *
00335    * @param args  arguments the program has been called with
00336    */
00337   public static void init(String[] args) {
00338     printVersion();
00339 
00340     arguments = options.parse(args);
00341 
00342     if(options.version) { System.exit(0); }
00343 
00344     if(options.help) {
00345       options.usage();
00346       System.exit(0);
00347     }
00348 
00349     if(Engine.options.print_options)
00350       options.print();
00351   }  
00352   /**
00353    * Creates a new iSearch object based on the current options
00354    *
00355    * @return an iSearch that is going to be used to do the search
00356    */
00357   public static iSearch newSearchAlgorithm() {
00358     if(options.path_simulation)
00359       return new Simulation();
00360 
00361 //#ifdef BUCHI
00362     if(options.buchi != null)
00363       return new LTL();
00364     else
00365 //#endif BUCHI
00366       if(options.verify)
00367 //#ifdef HEURISTIC
00368 
00369 //#endif HEURISTIC
00370       return new MC();
00371 //#ifdef HEURISTIC
00372 
00373 
00374 //#endif HEURISTIC
00375       else
00376     return new Simulation();
00377   }  
00378   /**
00379    * Prints the statistics accumulated during model checking.
00380    */
00381   private static void printStatistics() {
00382     statistics.print();
00383 
00384 //#ifdef COVERAGE
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 
00393 
00394 //#endif COVERAGE
00395 
00396   }  
00397 //#ifdef DISTRIBUTED
00398 
00399 
00400 
00401 
00402 
00403 
00404 
00405 
00406 
00407 
00408 
00409 //#ifdef JDK11
00410 
00411 //#endif JDK11
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 //#endif DISTRIBUTED
00443 
00444   /**
00445    * Prints the version information about the model checker.
00446    */
00447   private static void printVersion() {
00448     Debug.println(Debug.ERROR, VERSION);
00449     try {
00450       Debug.println(Debug.ERROR, options.getMainClass().getField("VERSION").get(null));
00451     } catch(NoSuchFieldException e) {
00452     } catch(IllegalAccessException e) {
00453     }
00454     Debug.println(Debug.ERROR, "Build " + Build.getBuild() + " (" + Build.getBuildDate() + ")");
00455     Debug.println(Debug.ERROR);
00456   }  
00457   /**
00458    * Runs the model checking. First initializes the virtual machine with the
00459    * arguments received from the command line, initializes the internal
00460    * structures and then starts the search algorithm.
00461    *
00462    * @param vm  a iVirtualMachine implementation
00463    */
00464   public static void run(iVirtualMachine vm) {
00465     JPF jpf = new JPF();
00466 
00467     setJPF(jpf);
00468 
00469     jpf.store = new Store();
00470     jpf.status = new Status();
00471     jpf.reporter = new Reporter();
00472 //#ifdef JDK11
00473 
00474 //#endif JDK11
00475 
00476     jpf.vm = vm;
00477     jpf.search = newSearchAlgorithm();
00478 
00479     statistics = new Statistics();
00480 
00481     vm.init(arguments);
00482 
00483     jpf.run();
00484 
00485 //#ifdef RACE || LOCK_ORDER
00486 
00487 //#endif RACE || LOCK_ORDER
00488 
00489     printStatistics();
00490   }  
00491   /**
00492    * Sets the local JPF object into the thread local object.
00493    *
00494    * @param jpf a JPF object
00495    */
00496   static void setJPF(JPF jpf) {
00497 //#ifdef BANDERA
00498     xjpf = jpf;
00499 //#else BANDERA
00500 
00501 //#endif BANDERA
00502   }  
00503 }

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