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

JPFOptions.java

00001 package gov.nasa.arc.ase.jpf;
00002 
00003 import gov.nasa.arc.ase.util.*;
00004 //#ifdef BUCHI
00005 import gov.nasa.arc.ase.ltl.LTL2Buchi;
00006 //#endif BUCHI
00007 //#ifdef BUCHI && BANDERA
00008 import gov.nasa.arc.ase.jpf.tools.PredicateCompiler;
00009 //#endif BUCHI && BANDERA
00010 import java.util.*;
00011 import java.net.*;
00012 import java.io.*;
00013 
00014 public class JPFOptions extends Options {
00015   public boolean    help            = false;
00016   public boolean    version         = false;
00017   public boolean    print_options       = false;
00018   
00019   public boolean    debug           = false;
00020   public boolean    verbose         = false;
00021   public boolean    quiet           = false;
00022 
00023   public Debug      debugs          = null;
00024 
00025   public boolean    bandera         = false;
00026   public boolean    multiple_errors     = false;
00027   public boolean    po_reduction        = false;
00028   public boolean    notify          = false;
00029 
00030   public boolean    verify          = true;
00031   public boolean    assertions      = true;
00032   public boolean    deadlocks       = true;
00033 
00034   public boolean        random_order            = false;
00035   public long           random_seed             = 0L;
00036   public boolean        use_time_for_seed       = true;
00037 
00038 //#ifdef BUCHI && BANDERA
00039   public String     predicate       = null;
00040   public String     predicate_class     = null;
00041   public String     predicate_method    = null;
00042 //#endif BUCHI && BANDERA
00043 
00044   public int        search_depth        = -1;
00045   public boolean        no_storing              = false;
00046 
00047 //#ifdef BUCHI
00048   public String     buchi           = null;
00049   public String     ltl         = null;
00050 //#endif BUCHI
00051 
00052 //#ifdef HEURISTIC
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 //#ifdef COVERAGE
00063 
00064 
00065 
00066 //#endif COVERAGE
00067 //#endif HEURISTIC
00068 
00069 //#ifdef HEURISTIC_DEBUG
00070 
00071 //#endif HEURISTIC_DEBUG
00072 
00073   /**************************************************************/
00074   public boolean        real_counterexample     = false;
00075   public boolean        path_simulation         = false;
00076   /**************************************************************/
00077 
00078 //#ifdef COVERAGE
00079 
00080 
00081 
00082 
00083 
00084 
00085 //#endif COVERAGE
00086 
00087 //#ifdef PARALLEL
00088 
00089 
00090 //#endif PARALLEL
00091 //#ifdef DISTRIBUTED
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 //#ifdef SIBLING_STORING
00103 
00104 //#endif SIBLING_STORING
00105 //#ifdef SIBLING_CACHING
00106 
00107 
00108 //#endif SIBLING_CACHING
00109 //#ifdef CHILDREN_LOOKAHEAD
00110 
00111 
00112 //#endif CHILDREN_LOOKAHEAD
00113 //#endif DISTRIBUTED
00114 //#ifdef DISTRIBUTED || PARALLEL
00115 
00116 
00117 //#endif DISTRIBUTED || PARALLEL
00118 
00119   public boolean    interactive     = false;
00120   public int        report_period       = 10;
00121 
00122 //#endif BUCHI && BANDERA
00123   public JPFOptions(Class m) {
00124     super(m, "class", true);
00125     addParser("[Ljava.lang.String;", "parseStringArray");
00126     addParser("gov.nasa.arc.ase.util.Debug", "parseDebug");
00127     addPrinter("[Ljava.lang.String;", "printStringArray");
00128     addPrinter("gov.nasa.arc.ase.util.Debug", "printDebug");
00129   }  
00130 //#ifdef DISTRIBUTED
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 //#endif DISTRIBUTED
00155 
00156 //#ifdef BUCHI
00157   private String loadLTL(String fname) {
00158     try {
00159       BufferedReader in = new BufferedReader(new FileReader(fname));
00160 
00161       return in.readLine();
00162     } catch(FileNotFoundException e) {
00163       throw new JPFErrorException("Can't load LTL formula: " + fname);
00164     } catch(IOException e) {
00165       throw new JPFErrorException("Error read on LTL formula: " + fname);
00166     }
00167   }  
00168   public String[] parse(String[] args) {
00169     String[] p = super.parse(args);
00170 
00171     if(debug)
00172       Debug.setDebugLevel(Debug.DEBUG);
00173     else if(verbose)
00174       Debug.setDebugLevel(Debug.MESSAGE);
00175     else if(quiet)
00176       Debug.setDebugLevel(Debug.ERROR);
00177     else
00178       Debug.setDebugLevel(Debug.WARNING);
00179 
00180 //#ifdef BUCHI && BANDERA
00181     if(predicate != null)
00182       translatePredicate();
00183 //#endif BUCHI && BANDERA
00184 
00185 //#ifdef DISTRIBUTED
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 //#ifdef SIBLING_STORING && SIBLING_CACHING
00214 
00215 
00216 
00217 
00218 
00219 //#endif SIBLING_STORING && SIBLING_CACHING
00220 
00221 //#endif DISTRIBUTED
00222 
00223 //#ifdef BUCHI
00224     if(ltl != null && buchi == null) {
00225       if(ltl.endsWith(".ltl")) {
00226     ltl = loadLTL(ltl);
00227       } else if(ltl.equals("-")) {
00228     ltl = readLTL();
00229       }
00230 
00231       if(ltl.equals(""))
00232     throw new JPFErrorException("empty LTL formula");
00233 
00234       try {
00235 //#ifdef BANDERA
00236     LTL2Buchi.translate("!(" + ltl + ")").save(System.getProperty("user.dir")+File.separator+"ba.sm");
00237 //#else BANDERA
00238 
00239 //#endif BANDERA
00240       } catch(IOException e) {
00241     throw new JPFErrorException(e.getMessage());
00242       }
00243 //#ifdef BANDERA
00244       buchi = System.getProperty("user.dir")+File.separator+"ba.sm";
00245 //#else BANDERA
00246 
00247 //#endif BANDERA
00248     }
00249 //#endif BUCHI
00250 
00251     return p;
00252   }  
00253   public Object parseDebug(String s) {
00254     if(s == null) throw new IllegalArgumentException();
00255 
00256     StringTokenizer ps = new StringTokenizer(s, ",");
00257 
00258     while(ps.hasMoreTokens()) {
00259       String p = ps.nextToken();
00260 
00261       StringTokenizer st = new StringTokenizer(p, "=");
00262       if(st.countTokens() == 1) {
00263     String kind = st.nextToken();
00264     int k;
00265 
00266     if((k = Debug.mapKind(kind)) == -1) {
00267       Debug.println(Debug.ERROR, "invalid debug kind -- " + kind);
00268       return null;
00269     }
00270 
00271     Debug.setDebugLevel(Debug.DEBUG, k);
00272       } else if(st.countTokens() == 2) {
00273     String kind = st.nextToken();
00274     String level = st.nextToken();
00275     int k, l;
00276 
00277     if((k = Debug.mapKind(kind)) == -1) {
00278       Debug.println(Debug.ERROR, "invalid debug kind -- " + kind);
00279       return null;
00280     }
00281     if((l = Debug.mapLevel(level)) == -1) {
00282       Debug.println(Debug.ERROR, "invalid debug level -- " + level);
00283       return null;
00284     }
00285 
00286     Debug.setDebugLevel(l, k);
00287       } else {
00288     Debug.println(Debug.ERROR, "invalid syntax -- -debugs " + s);
00289     return null;
00290       }
00291     }
00292 
00293     return null;
00294   }  
00295   public Object parseStringArray(String s) {
00296     if(s == null) throw new IllegalArgumentException();
00297     StringTokenizer st = new StringTokenizer(s, ",");
00298     int l = st.countTokens();
00299     String[] strs = new String[l];
00300 
00301     for(int i = 0; i < l; i++)
00302       strs[i] = st.nextToken();
00303 
00304     return strs;
00305   }  
00306   public String printDebug(Object o) {
00307     return Debug.status();
00308   }  
00309   public String printStringArray(Object o) {
00310     if(o == null) return "null";
00311 
00312     String[] s = (String[])o;
00313     StringBuffer sb = new StringBuffer("[");
00314 
00315     for(int i = 0; i < s.length; i++) {
00316       if(i != 0) sb.append(",");
00317       sb.append(" ");
00318       sb.append(s[i]);
00319     }
00320     if(s.length != 0) sb.append(" ");
00321     sb.append("]");
00322 
00323     return sb.toString();
00324   }  
00325   private String readLTL() {
00326     try {
00327       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
00328 
00329       System.out.print("Insert LTL formula: ");
00330       return in.readLine();
00331     } catch(IOException e) {
00332       throw new JPFErrorException("Invalid LTL formula");
00333     }
00334   }  
00335 //#endif BUCHI
00336 
00337 //#ifdef BUCHI && BANDERA
00338   private void translatePredicate() {
00339     String[] args;
00340 
00341     if(predicate_class != null) {
00342       if(predicate_method != null) {
00343     args = new String[3];
00344     args[0] = predicate;
00345     args[1] = predicate_class;
00346     args[2] = predicate_method;
00347       } else {
00348     args = new String[2];
00349     args[0] = predicate;
00350     args[1] = predicate_class;
00351       }
00352     } else {
00353       args = new String[1];
00354       args[0] = predicate;
00355     }
00356     
00357     PredicateCompiler.main(args);
00358     throw new JPFErrorException("Successful termination in translatePredicate"); //System.exit(0);
00359   }  
00360 }

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