01: //
02: // Copyright (C) 2005 United States Government as represented by the
03: // Administrator of the National Aeronautics and Space Administration
04: // (NASA). All Rights Reserved.
05: //
06: // This software is distributed under the NASA Open Source Agreement
07: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
08: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
09: // directory tree for the complete NOSA document.
10: //
11: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18: //
19: package gov.nasa.jpf.search;
20:
21: import gov.nasa.jpf.*;
22: import gov.nasa.jpf.util.Debug;
23:
24: /**
25: * this is a straight execution pseudo-search - it doesn't search at
26: * all (i.e. it doesn't backtrack), but just behaves like a 'normal' VM,
27: * going forward() until there is no next state
28: *
29: * <2do> pcm - of course it doesn't quite behave like a normal VM, since it
30: * doesn't honor thread priorities yet (needs a special scheduler)
31: *
32: * <?> pcm - it's not really clear to me how this differs from a 'PathSearch'
33: * other than using a different scheduler. Looks like there should be just one
34: *
35: */
36: public class Simulation extends AbstractSearch {
37: public Simulation(Config config, VM vm) {
38: super (config, vm);
39:
40: Debug.println(Debug.WARNING, "Simulation Search");
41: }
42:
43: public void search() {
44: int depth = 0;
45:
46: depth++;
47:
48: if (hasPropertyTermination()) {
49: return;
50: }
51:
52: while (!done) {
53: boolean next = vm.forward();
54:
55: if (next) {
56: if (hasPropertyTermination()) {
57: return;
58: }
59:
60: depth++;
61: } else { // no next state
62:
63: // <2do> we could check for more things here. If the last insn wasn't
64: // the main return, or a System.exit() call, we could flag a JPFException
65: isPropertyViolated();
66: done = true;
67: }
68: }
69: }
70: }
|