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

VirtualMachine.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import de.fub.bytecode.*;
00004 import edu.ksu.cis.bandera.jjjc.decompiler.*;
00005 import gov.nasa.arc.ase.jpf.*;
00006 import gov.nasa.arc.ase.jpf.jvm.reflection.Reflection;
00007 import gov.nasa.arc.ase.util.Counter;
00008 import gov.nasa.arc.ase.util.Debug;
00009 import gov.nasa.arc.ase.util.Comma;
00010 // ifdef NO_COMPRESSION
00011 import gov.nasa.arc.ase.util.HashPool;
00012 //#endif NO_COMPRESSION
00013 import java.io.*;
00014 import java.lang.reflect.InvocationTargetException;
00015 import java.lang.reflect.Method;
00016 import java.util.*;
00017 
00018 public class VirtualMachine implements iVirtualMachine {
00019   private SystemState system_state;
00020 // ifdef REFERENCE_COUNT
00021 
00022 //#else REFERENCE_COUNT
00023   private KernelState kernel_state;
00024 //#endif REFERENCE_COUNT
00025   private StateStack  stack = new StateStack();
00026   private boolean     first_max_stack_reached = true;
00027   // used by bandera error trail
00028   private String      mainClass;
00029   private JVMPath     errorPath;
00030   private int         pos_in_errorPath;
00031   private Counter     matching_states;
00032 
00033 // ifdef NO_COMPRESSION
00034   public static HashPool fieldsPool = new HashPool();
00035   public static HashPool framePool = new HashPool();
00036   public static HashPool objectInfoPool = new HashPool();
00037   public static HashPool threadPool = new HashPool();
00038 //#endif NO_COMPRESSION
00039 
00040 // ifdef MARK_N_SWEEP
00041   private static boolean gc_needed = false;
00042 //#endif MARK_N_SWEEP
00043 
00044   public static JVMOptions options;
00045 
00046   private static boolean initial_state = true;
00047 
00048 // ifdef REFERENCE_COUNT
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 //#endif REFERENCE_COUNT
00057   public VirtualMachine(String classname) {
00058     new JPFVM();
00059     mainClass = classname;
00060     stack.setMaxDepth(VirtualMachine.options.search_depth);
00061     system_state = new SystemState();
00062     kernel_state = new KernelState();
00063 // ifdef DISTRIBUTED
00064 
00065 
00066 
00067 //#endif DISTRIBUTED
00068 
00069     ClassInfo ci = JPFVM.getJPFVM().getClass(classname);
00070     int mainclass = kernel_state.static_area.addClass(ci);
00071 
00072     ThreadInfo th = ci.executeMain(kernel_state, mainclass);
00073     ci.initialize(system_state, kernel_state, th);
00074 
00075     pushInitialSystemState();
00076     Engine.store.initial(kernel_state);
00077   }
00078   public static void activateGC() { gc_needed = true; }
00079   public boolean Backtrack() {
00080 // ifdef DEBUG_SEARCH
00081 
00082 //#endif DEBUG_SEARCH
00083     if (stack.isEmpty()) return false;
00084 
00085 // ifdef DEBUG
00086 
00087 //#endif DEBUG
00088 
00089     SystemState ss = (SystemState)stack.Pop();
00090     if (ss == null) return false;
00091 
00092     system_state = (SystemState)ss.clone();
00093 
00094 // ifdef NO_COMPRESSION
00095     int[] data;
00096 //#endif NO_COMPRESSION
00097 
00098     // Last system state on the stack
00099 // ifdef NO_FASTBACKTRACK
00100 
00101 //#else NO_FASTBACKTRACK
00102     data = system_state.getBacktrackData();
00103     kernel_state.revertTo(data);
00104 //#endif NO_FASTBACKTRACK
00105 // ifdef REFERENCE_COUNT
00106 
00107 
00108 //#endif REFERENCE_COUNT
00109 // ifdef DEBUG
00110 
00111 
00112 // ifdef REFERENCE_COUNT
00113 
00114 
00115 
00116 
00117 //#endif REFERENCE_COUNT
00118 //#endif DEBUG
00119     system_state.restoreAtomicData(kernel_state);
00120     TransitionResult.atomicLevel = system_state.atomicLevel;
00121 
00122     return true;
00123   }
00124   public Path buildPath() {
00125     int s = stack.size();
00126 // ifdef DISTRIBUTED
00127 // ifdef CHILDREN_LOOKAHEAD
00128 
00129 //#else CHILDREN_LOOKAHEAD
00130 
00131 //#endif CHILDREN_LOOKAHEAD
00132 //#else DISTRIBUTED
00133     JVMPath p  = new JVMPath(s == 0 ? s : s - 1, 0);
00134 //#endif DISTRIBUTED
00135 
00136     for(int index = 1; index < s; index++)
00137       p.set(index-1,
00138       ((SystemState)stack.get(index)).getTrailInfo().getThread());
00139 
00140     return p;
00141   }
00142   public boolean CheckInvariant(iProperty p) {
00143     return p.property(kernel_state);
00144   }
00145   public FilenameLinePair ErrorBackward() {
00146     Backtrack();
00147     pos_in_errorPath--;
00148     JVMPathEntry e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath);
00149     return new FilenameLinePair(e.file, e.line);
00150   }
00151   public FilenameLinePair ErrorForward() {
00152     if (pos_in_errorPath >= errorPath.size())
00153       return null;
00154     JVMPathEntry e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath);
00155     Scheduler sch = system_state.getScheduler();
00156     sch.setCurrentThread(e.thread);
00157     Forward();
00158     pos_in_errorPath++;
00159     if (pos_in_errorPath >= errorPath.size())
00160       return null;
00161     e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath);
00162     return new FilenameLinePair(e.file, e.line);
00163   }
00164   public FilenameLinePair ErrorInit() {
00165     ((JPFOptions)Engine.options).po_reduction = false;
00166     reinit(mainClass);
00167     pos_in_errorPath = 0;
00168     JVMPathEntry e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath);
00169     return new FilenameLinePair(e.file, e.line);
00170   }
00171   public int ErrorPathLength() {
00172     return errorPath.size();
00173   }
00174   public int Forward() {
00175 // ifdef DEBUG_SEARCH
00176 
00177 //#endif DEBUG_SEARCH
00178     boolean result;
00179 
00180     if (stack.Full(system_state.getScheduler().getSafeMoves())) {
00181       if (first_max_stack_reached) {
00182 // ifdef DEBUG
00183 
00184 
00185 
00186 
00187 
00188 //#endif DEBUG
00189     first_max_stack_reached = false;
00190       }
00191       return RESULT.EXIT;
00192     }
00193     //Debug.println(Debug.DEBUG, "\n---> Forward");
00194     result = system_state.nextSuccessor(kernel_state);
00195     if (!result) {
00196       if(system_state.handleIntermediate(kernel_state))
00197     return Forward();
00198       if (kernel_state.isTerminated()) {
00199 // ifdef DEBUG
00200 
00201 //#endif DEBUG
00202     return RESULT.EXIT;
00203       } else {
00204 // ifdef DEBUG
00205 
00206 //#endif DEBUG
00207     return RESULT.END;
00208       }
00209     } else {
00210 // ifdef DEBUG
00211 
00212 //#endif DEBUG
00213 // ifdef MARK_N_SWEEP
00214       if (VirtualMachine.options.garbage_collection && gc_needed) {
00215     kernel_state.gc();
00216     gc_needed = false;
00217       }
00218 //#endif MARK_N_SWEEP
00219 // ifdef DISTRIBUTED
00220 // ifdef CHILDREN_LOOKAHEAD
00221 
00222 
00223 
00224 
00225 //#endif CHILDREN_LOOKAHEAD
00226 //#endif DISTRIBUTED
00227       pushSystemState();
00228 // ifdef DISTRIBUTED
00229 
00230 //#endif DISTRIBUTED
00231     result = Engine.store.put(kernel_state);
00232     if (result)
00233       return RESULT.NEW;
00234     else
00235       return RESULT.OLD;
00236 // ifdef DISTRIBUTED
00237 
00238 
00239 //#endif DISTRIBUTED
00240     }
00241   }
00242   public ErrorTrailInterface getErrorTrail() {
00243     Vector v = new Vector();
00244     v.addElement("");
00245     v.addElement("");
00246     v.addElement("========================");
00247     v.addElement(" *** Path to error: ***");
00248     v.addElement("========================");
00249     int Elements_in_trail = stack.size();
00250     v.addElement("Steps to error: " + (Elements_in_trail-1));
00251     for(int index = 1; index < Elements_in_trail; index++)
00252       try {
00253     v.add(index + ": " + ((SystemState)stack.get(index)).getTrailInfo().toString());
00254       } catch(NullPointerException e) {
00255     v.add(index + ":");
00256       }
00257 
00258     ErrorTrail e = new ErrorTrail(v.size());
00259     for(int index = 0; index < v.size(); index++)
00260       e.add((String)v.elementAt(index));
00261 
00262     return e;
00263   }
00264   /*********************************************************************/
00265 
00266   /*********************************************************************/
00267   // read errorFile into ePath; only in path-simulation mode
00268   /*********************************************************************/
00269   public Path getErrorTrail_from_file() {
00270     JVMPath ePath = null;
00271     try {
00272       String filename = mainClass + ".error.path";
00273       FileReader fr = new FileReader(filename);
00274       LineNumberReader ifr = new LineNumberReader(fr);
00275       String ln = ifr.readLine();
00276       StringTokenizer t;
00277 
00278       if(ln !=null) {
00279     t = new StringTokenizer(ln, " :\t\r\n");
00280     // Size
00281     t.nextToken();
00282     int size = Integer.parseInt(t.nextToken());
00283     ePath = new JVMPath(size);
00284 
00285 
00286     for(int index = 0; index < size; index++) {//??good size
00287       ln = ifr.readLine();
00288       t = new StringTokenizer(ln, " :\t\r\n");
00289 
00290       // Thread #
00291       t.nextToken();
00292       int thread = Integer.parseInt(t.nextToken());
00293 
00294       // Line #
00295       t.nextToken();
00296       int line = Integer.parseInt(t.nextToken());
00297 
00298       // Class name
00299       t.nextToken();
00300       String classname = t.nextToken();
00301 
00302       // Random #
00303       t.nextToken();
00304       int random = Integer.parseInt(t.nextToken());
00305 
00306       ePath.setErrorMove(index, line, classname, thread, random);
00307 
00308     }
00309       }
00310       fr.close();
00311 
00312     } catch (Exception e) {
00313       e.printStackTrace();
00314     }
00315     return ePath;
00316   }
00317   // read errorFile into errorPath
00318 
00319   /*/\/\/\/\/\/\/\/\/\/\ for path simulation ... */
00320   /*************************************************************************/
00321   // when getErrorTrail_to_file is invoked, the error file should be created
00322   /*************************************************************************/
00323   public Path getErrorTrail_to_file() {
00324     int s = stack.size();
00325     int size =   (s == 0 ? s : s - 1);
00326 
00327     // dump the error trace
00328     try {
00329       PrintWriter out = new PrintWriter(new OutputStreamWriter(
00330         new  FileOutputStream(mainClass + ".error.path")));
00331 
00332       out.print("Size:"+ size +"\n"); // size of error path
00333 
00334       for(int index = 1; index < s; index++) {
00335     int line = ((SystemState)stack.get(index)).getTrailInfo().getLine();
00336     String classname = ((SystemState)stack.get(index)).getTrailInfo().getClassname();
00337     int thread = ((SystemState)stack.get(index)).getTrailInfo().getThread();
00338     int random = ((SystemState)stack.get(index)).getTrailInfo().getRandom();
00339 
00340     out.print("Thread:"+ thread +"\t Line:"+ line +"\t Class:"+ classname +"\t Random:"+random +"\n");
00341       }
00342       out.close();
00343     } catch (Exception e) {
00344       /* do cleanup here - - possibly rethrow e */
00345       e.printStackTrace();
00346     }
00347     return null;
00348   }
00349 // ifdef DISTRIBUTED
00350 // ifdef CHILDREN_LOOKAHEAD
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 //#endif CHILDREN_LOOKAHEAD
00376 //#endif DISTRIBUTED
00377 
00378   // new code for production of error trail for Bandera
00379 
00380   public Path getErrorTrail1() {
00381     int s = stack.size();
00382     errorPath = new JVMPath(s == 0 ? s : s - 1);
00383     for(int index = 1; index < s; index++)
00384       errorPath.setErrorMove(index-1,
00385       ((SystemState)stack.get(index)).getTrailInfo().getLine(),
00386       ((SystemState)stack.get(index)).getTrailInfo().getClassname(),
00387       ((SystemState)stack.get(index)).getTrailInfo().getThread(),
00388       ((SystemState)stack.get(index)).getTrailInfo().getRandom()
00389                 );
00390 
00391     // dump errorPath to file
00392 
00393     return errorPath;
00394   }
00395   public iKernelState getKernelState(){
00396     return kernel_state;
00397   }
00398   public int getSafeMoves() {
00399     return system_state.getScheduler().getSafeMoves();
00400   }
00401   public static String getStatus() {
00402 // ifdef NO_COMPRESSION
00403 
00404 //#else NO_COMPRESSION
00405     return " fsp " + Comma.format(fieldsPool.size()) +
00406       " frp " + Comma.format(framePool.size()) +
00407       " tp " + Comma.format(threadPool.size()) +
00408       " oip " + Comma.format(objectInfoPool.size());
00409 //#endif NO_COMPRESSION
00410   }
00411   public iSystemState getSystemState(){
00412     return system_state;
00413   }
00414   public int nextThreadToExecute() {
00415     if (pos_in_errorPath >= errorPath.size())
00416       return -1;
00417     JVMPathEntry e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath);
00418     return e.thread;
00419   }
00420   public int previousThreadToExecute() {
00421     if (pos_in_errorPath < 1)
00422       return -1;
00423     JVMPathEntry e = ((JVMPath)errorPath).getErrorMove(pos_in_errorPath-1);
00424     return e.thread;
00425   }
00426   public void printStackTrace() {
00427     ((ThreadInfo)kernel_state.getThreadInfo(system_state.getScheduler().getCurrentThread())).printStackTrace();
00428   }
00429 // ifdef BUCHI
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 // ifdef MARK_N_SWEEP
00445 
00446 
00447 
00448 
00449 //#endif MARK_N_SWEEP
00450 
00451 
00452 
00453 
00454 
00455 
00456 
00457 
00458 
00459 
00460 
00461 
00462 
00463 
00464 
00465 
00466 
00467 
00468 
00469 
00470 
00471 // ifdef NO_COMPRESSION
00472 
00473 //#endif NO_COMPRESSION
00474 // ifdef NO_FASTBACKTRACK
00475 
00476 //#endif NO_FASTBACKTRACK
00477 
00478 // ifdef NO_FASTBACKTRACK
00479 
00480 
00481 //#endif NO_FASTBACKTRACK
00482 // ifdef REFERENCE_COUNT
00483 
00484 
00485 //#endif REFERENCE_COUNT
00486 
00487 
00488 
00489 
00490 
00491 
00492 
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500 
00501 
00502 
00503 
00504 
00505 
00506 
00507 // ifdef NO_FASTBACKTRACK
00508 
00509 //#endif NO_FASTBACKTRACK
00510 
00511 // ifdef REFERENCE_COUNT
00512 
00513 //#endif REFERENCE_COUNT
00514 
00515 
00516 
00517 // ifdef NO_COMPRESSION
00518 
00519 //#endif NO_COMPRESSION
00520 
00521 // ifdef NO_FASTBACKTRACK
00522 
00523 //#else NO_FASTBACKTRACK
00524 
00525 
00526 //#endif NO_FASTBACKTRACK
00527 
00528 // ifdef REFERENCE_COUNT
00529 
00530 
00531 //#endif REFERENCE_COUNT
00532 
00533 
00534 
00535 
00536 
00537 
00538 
00539 
00540 
00541 
00542 
00543 
00544 
00545 
00546 
00547 
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00555 
00556 
00557 
00558 
00559 
00560 
00561 
00562 
00563 
00564 
00565 
00566 
00567 
00568 
00569 
00570 
00571 
00572 
00573 
00574 
00575 
00576 
00577 
00578 
00579 
00580 
00581 
00582 
00583 
00584 
00585 
00586 
00587 
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00595 
00596 
00597 
00598 
00599 
00600 
00601 
00602 
00603 
00604 
00605 
00606 // ifdef NO_FASTBACKTRACK
00607 
00608 
00609 
00610 
00611 
00612 
00613 
00614 
00615 
00616 
00617 
00618 
00619 
00620 
00621 
00622 
00623 
00624 
00625 
00626 
00627 
00628 
00629 
00630 
00631 
00632 
00633 
00634 //#else NO_FASTBACKTRACK
00635 
00636 
00637 
00638 
00639 
00640 
00641 
00642 
00643 
00644 
00645 
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653 
00654 
00655 
00656 
00657 
00658 
00659 
00660 
00661 
00662 
00663 
00664 
00665 
00666 
00667 
00668 
00669 //#endif NO_FASTBACKTRACK
00670 
00671 
00672 
00673 
00674 
00675 // ifdef NO_FASTBACKTRACK
00676 
00677 //#endif NO_FASTBACKTRACK
00678 
00679 // ifdef REFERENCE_COUNT
00680 
00681 //#endif REFERENCE_COUNT
00682 
00683 
00684 
00685 //#endif BUCHI
00686 
00687   public void pushInitialSystemState() {
00688 // ifdef NO_FASTBACKTRACK
00689 
00690 //#else NO_FASTBACKTRACK
00691     system_state.setBacktrackData(kernel_state.getBacktrackData());
00692 //#endif NO_FASTBACKTRACK
00693 
00694 // ifdef REFERENCE_COUNT
00695 
00696 
00697 //#endif REFERENCE_COUNT
00698 
00699 // ifdef DEBUG
00700 
00701 
00702 // ifdef REFERENCE_COUNT
00703 
00704 
00705 
00706 
00707 //#endif REFERENCE_COUNT
00708 //#endif DEBUG
00709 
00710     SystemState ss = (SystemState)system_state.clone();
00711     stack.Push(ss);
00712   }
00713   public void pushSystemState() {
00714     Scheduler sch = system_state.getScheduler();
00715     stack.UpdateTop(sch);
00716     sch.initialize();
00717     system_state.atomicLevel = TransitionResult.atomicLevel;
00718     TransitionResult.initialize();
00719     stack.UpdateTopExtra(system_state);
00720 // ifdef NO_FASTBACKTRACK
00721 
00722 //#else NO_FASTBACKTRACK
00723     system_state.setBacktrackData(kernel_state.getBacktrackData());
00724 //#endif NO_FASTBACKTRACK
00725 
00726 // ifdef REFERENCE_COUNT
00727 
00728 
00729 //#endif REFERENCE_COUNT
00730 
00731 // ifdef DEBUG
00732 
00733 
00734 // ifdef REFERENCE_COUNT
00735 
00736 
00737 
00738 
00739 //#endif REFERENCE_COUNT
00740 //#endif DEBUG
00741 
00742     SystemState ss = (SystemState)system_state.clone();
00743     stack.Push(ss);
00744   }
00745   public void reinit(String classname){
00746     new JPFVM();
00747 // ifdef RACE
00748     Runner.race_conditions = 0;
00749 //#endif RACE
00750     stack = new StateStack();
00751     stack.setMaxDepth(VirtualMachine.options.search_depth);
00752 
00753     Repository.clearCache();
00754 // ifdef NO_STATIC_SYMMETRY
00755     StaticMap.reset();
00756 //#endif NO_STATIC_SYMMETRY
00757 
00758     system_state = new SystemState();
00759     kernel_state = new KernelState();
00760 
00761     ClassInfo ci = JPFVM.getJPFVM().getClass(classname);
00762     int mainclass = kernel_state.static_area.addClass(ci);
00763 
00764     ThreadInfo th = ci.executeMain(kernel_state, mainclass);
00765     ci.initialize(system_state, kernel_state, th);
00766 
00767     pushInitialSystemState();
00768     Engine.store.initial(kernel_state);
00769   }
00770   public void ShowErrorTrail() {
00771     BufferedWriter out = null;
00772 
00773     Debug.println(Debug.WARNING, "\n");
00774     Debug.println(Debug.WARNING, "========================");
00775     Debug.println(Debug.WARNING, " *** Path to error: ***");
00776     Debug.println(Debug.WARNING, "========================");
00777     int Elements_in_trail = stack.size();
00778     Debug.println(Debug.WARNING, "Steps to error: " + (Elements_in_trail-1));
00779     try{
00780       out = new BufferedWriter(new FileWriter("error.trail"));
00781     } catch (IOException e) {};
00782     for(int index = 1; index < Elements_in_trail; index++) {
00783       Debug.print(Debug.WARNING, index + ": ");
00784       ((SystemState)stack.get(index)).getTrailInfo().print();
00785       ((SystemState)stack.get(index)).getTrailInfo().dump2file(out);
00786     }
00787     try {out.close();} catch (IOException e) {};
00788   }
00789   /*********************************************************************/
00790   /*/\/\/\/\/\/\/\/\/\/\ end ... */
00791 
00792 
00793   public void ShowErrorTrail(Path ePath) {
00794     reinit(mainClass);
00795     for(int i = 0; i < errorPath.size()-1; i++) {
00796       FilenameLinePair pair = ErrorForward();
00797       Debug.println(Debug.WARNING, pair.getFilename() + " " +
00798       pair.getLine());
00799     }
00800   }
00801 // ifdef DISTRIBUTED
00802 
00803 
00804 
00805 
00806 // ifdef DEBUG_SEARCH
00807 
00808 //#endif DEBUG_SEARCH
00809 
00810 
00811 
00812 
00813 
00814 
00815 
00816 
00817 
00818 
00819 
00820 
00821 
00822 
00823 
00824 
00825 
00826 
00827 
00828 
00829 
00830 
00831 
00832 
00833 
00834 
00835 
00836 
00837 
00838 // ifdef NO_FASTBACKTRACK
00839 
00840 //#endif NO_FASTBACKTRACK
00841 // ifdef REFERENCE_COUNT
00842 
00843 //#endif REFERENCE_COUNT
00844 
00845 
00846 
00847 // ifdef CHILDREN_LOOKAHEAD
00848 
00849 
00850 
00851 //#endif CHILDREN_LOOKAHEAD
00852 // ifdef DEBUG_SEARCH
00853 
00854 //#endif DEBUG_SEARCH
00855 
00856 
00857 
00858 //#endif DISTRIBUTED
00859 
00860   public int simForward() {
00861     boolean result;
00862 
00863     result = system_state.nextSuccessor(kernel_state);
00864     if (!result) {
00865       if (kernel_state.isTerminated()){
00866 // ifdef DEBUG
00867 
00868 //#endif DEBUG
00869     return RESULT.EXIT;
00870       }
00871       else{
00872 // ifdef DEBUG
00873 
00874 //#endif DEBUG
00875     return RESULT.END;
00876       }
00877     }
00878     else {
00879 // ifdef DEBUG
00880 
00881 //#endif DEBUG
00882 // ifdef MARK_N_SWEEP
00883       if (VirtualMachine.options.garbage_collection && gc_needed) {
00884     kernel_state.gc();
00885     gc_needed = false;
00886       }
00887 //#endif MARK_N_SWEEP
00888 // ifdef RACE
00889       if (Runner.race_conditions >= VirtualMachine.options.race_level)
00890     return RESULT.EXIT;
00891 //#endif RACE
00892       if (Reader.interrupt()){
00893     Debug.println(Debug.ERROR, "EXECUTION HAS BEEN INTERRUPTED !!");
00894     return RESULT.EXIT;
00895       }
00896       return RESULT.NEW;
00897     }
00898   }
00899   /*********************************************************************/
00900 
00901   /*********************************************************************/
00902   // used in path simulation mode: stuttering equivalence
00903   /*********************************************************************/
00904   public void SimulateErrorTrail(Path ePath) {
00905     JVMPathEntry e;
00906     Scheduler sch;
00907     int s; // stack size
00908 
00909     int old_line = 0; // for stuttering
00910 
00911     reinit(mainClass);
00912     pos_in_errorPath = 0;
00913 
00914     while(pos_in_errorPath < ePath.size()) {
00915       e = ((JVMPath)ePath).getErrorMove(pos_in_errorPath);
00916       // some e's should be ignored when interpreting abstract counterexamples on a concrete program
00917       sch = system_state.getScheduler();
00918       sch.setCurrentThread(e.thread);
00919       sch.setCurrentRandom(e.random);
00920       Forward();
00921       s = stack.size();
00922 
00923       int line_sim = ((SystemState)stack.get(s-1)).getTrailInfo().getLine();
00924       int random_sim = ((SystemState)stack.get(s-1)).getTrailInfo().getRandom();
00925 
00926       if(e.line != line_sim)  {
00927 
00928     while(e.line == old_line && pos_in_errorPath < ePath.size()-1) {//stuttering
00929       pos_in_errorPath++;
00930       e = ((JVMPath)ePath).getErrorMove(pos_in_errorPath);
00931     }
00932 
00933     if(e.line != line_sim)  { // Warning !!!
00934       Debug.println(Debug.ERROR, "!!!!! Warning: mismatch line numbers: program "+ line_sim +" ; error trail "+e.line);
00935       Debug.println(Debug.ERROR, "! This may not be a real counter-example !");
00936 
00937       pos_in_errorPath = ePath.size(); // exit while loop
00938     }
00939       }
00940 
00941       if(e.random != random_sim) // Warning !!!
00942     Debug.println(Debug.ERROR, "!!!!! Warning: mismatch random numbers: program "+ random_sim +" ; error trail "+e.random);
00943 
00944       old_line = e.line;
00945       pos_in_errorPath++;
00946     }
00947   }
00948 }

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