lab4
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab4 [2017/01/27 19:42] – franck | lab4 [2018/01/23 02:56] (current) – franck | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | |||
+ | ====== LAB 3 ====== | ||
+ | |||
+ | ====== Listeners ====== | ||
+ | |||
+ | |||
Choose one of the following listeners (please don't all choose the first one). Write one or more sample programs to illustrate the use of the listener. | Choose one of the following listeners (please don't all choose the first one). Write one or more sample programs to illustrate the use of the listener. | ||
Line 6: | Line 13: | ||
* gov.nasa.jpf.listener.MethodTracker | * gov.nasa.jpf.listener.MethodTracker | ||
* gov.nasa.jpf.listener.NoStateCycles | * gov.nasa.jpf.listener.NoStateCycles | ||
- | * gov.nasa.jpf.listener.NumericValueChecker | + | * gov.nasa.jpf.listener.NumericValueChecker\\ |
- | Examples of properties | + | |
* range.fields=speed, | * range.fields=speed, | ||
- | - range.speed.field=x.y.SomeClass.velocity | + | * range.speed.field=x.y.SomeClass.velocity |
- | - range.speed.min=300 | + | |
- | - range.speed.max=500 | + | |
+ | * range.vars=altitude, | ||
+ | * range.altitude.var=x.y.SomeClass.computeTrajectory(int): | ||
+ | * range.altitude.min=125000 | ||
+ | * gov.nasa.jpf.listener.ObjectTracker | ||
+ | * ot.include | ||
+ | * ot.exclude | ||
+ | * ot.refs | ||
+ | * ot.log_calls | ||
+ | * ot.log_fields | ||
+ | * gov.nasa.jpf.listener.OOMEInjector | ||
+ | * oome.locations | ||
+ | * oome.types | ||
+ | * gov.nasa.jpf.listener.PathOutputMonitor | ||
+ | * perturb.fields = altitude, | ||
+ | * perturb.altitude.field = x.y.MyClass.alt | ||
+ | * perturb.altitude.class = .perturb.IntOverUnder | ||
+ | * perturb.altitude.location = MyClass.java: | ||
+ | * perturb.altitude.delta = 1 | ||
+ | * perturb.returns = velocity, | ||
+ | * perturb.velocity.method = x.y.MyClass.computeVelocity() | ||
+ | * perturb.velocity.class = .perturb.IntOverUnder | ||
+ | * perturb.velocity.delta = 50 | ||
+ | * perturb.params = foo, ... | ||
+ | * perturb.foo.method = x.y.MyClass.send(int, | ||
+ | * perturb.foo.location = MyClass.java: | ||
+ | * perturb.class = .perturb.dataAbstractor | ||
+ | * gov.nasa.jpf.listener.ReferenceLocator | ||
+ | * refloc.create | ||
+ | * refloc.release | ||
+ | * refloc.use | ||
+ | * gov.nasa.jpf.listener.SearchStats | ||
+ | * gov.nasa.jpf.listener.StackDepthChecker | ||
+ | * sdc.max_stack_depth | ||
+ | * gov.nasa.jpf.listener.StackTracker | ||
+ | * jpf.stack_tracker.log_period | ||
+ | * gov.nasa.jpf.listener.StateCountEstimator | ||
+ | * jpf.state_count_estimator.log_period | ||
+ | * gov.nasa.jpf.listener.StateTracker | ||
+ | * jpf.state_tracker.log_period | ||
+ | * gov.nasa.jpf.listener.VarRecorder | ||
+ | * var_recorder.include | ||
+ | * var_recorder.exclude | ||
+ | * var_recorder.fields | ||
+ | * var_recorder.locals | ||
+ | * var_recorder.arrays | ||
+ | * gov.nasa.jpf.listener.VarTracker | ||
+ | * vt.include | ||
+ | * vt.exclude | ||
+ | * vt.max_vars | ||
+ | * vt.methods | ||
+ | |||
+ | To receive feedback, submit your work as a text file using the submit command before Wednesday January 31:\\ | ||
+ | submit 4315 lab3 <name of the listener> | ||
+ | |||
+ | ====== Sample ====== | ||
+ | |||
+ | The listener BudgetChecker, | ||
+ | set constraints for JPF. For example, one can set the maximum number of milliseconds used | ||
+ | by JPF. If JPF takes more time than this maximum when using this listener, JPF will | ||
+ | terminate and will report that it took more than the set maximum. | ||
+ | can also constrain the amount of heap space used, the number of instructions executed, | ||
+ | the depth of the search, the number of new states, and the number of non-replayed new states. | ||
+ | To specify these constraints, | ||
+ | application properties file, as we will show below. | ||
+ | |||
+ | To illustrate the BudgetChecker listener, we consider the following app. | ||
+ | |||
+ | <code java> | ||
+ | import java.util.ArrayList; | ||
+ | import java.util.List; | ||
+ | import java.util.Random; | ||
+ | |||
+ | public class Constraints { | ||
+ | public static void main(String[] args) { | ||
+ | Random random = new Random(); | ||
+ | List< | ||
+ | for (int i = 0; random.nextBoolean(); | ||
+ | list.add(new Integer(i)); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | We can run the listener BudgetChecker without setting any of its properties | ||
+ | and, hence, not setting any constraints, | ||
+ | |||
+ | < | ||
+ | target=Constraints | ||
+ | classpath=. | ||
+ | cg.enumerate_random=true | ||
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | </ | ||
+ | |||
+ | In this case, no constraints are set. As a result, JPF will run out of memory producing | ||
+ | the following output | ||
+ | |||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | Constraints.main() | ||
+ | |||
+ | ====================================================== search started: 1/27/17 1:01 PM | ||
+ | [SEVERE] JPF out of memory | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | We can constrain the maximum amount time used by JPF to 1000 milliseconds as follows. | ||
+ | We can assign any long value to the property budget.max_time. | ||
+ | |||
+ | < | ||
+ | target=Constraints | ||
+ | classpath=. | ||
+ | cg.enumerate_random=true | ||
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | budget.max_time=1000 | ||
+ | </ | ||
+ | |||
+ | Since JPF cannot complete within one second, it stops after one second and produces the following output. | ||
+ | |||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | Constraint.main() | ||
+ | |||
+ | ====================================================== search started: 1/27/17 1:22 PM | ||
+ | |||
+ | ====================================================== search constraint | ||
+ | max time exceeded: 00:00:01 >= 00:00:01 | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | The amount heap space used by JPF can be constrained to a maximum number of bits as follows. | ||
+ | We can assign any long value to the property budget.max_heap. | ||
+ | |||
+ | < | ||
+ | target=Constraints | ||
+ | classpath=. | ||
+ | cg.enumerate_random=true | ||
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | budget.max_heap=10000000 | ||
+ | </ | ||
+ | |||
+ | Note that 10000000 bits = 10000000 / (1024 * 1024) megabytes = 9.5 megabytes. | ||
+ | JPF needs more heap space, it stops and produces the following output. | ||
+ | |||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | Constraints.main() | ||
+ | |||
+ | ====================================================== search started: 1/27/17 1:36 PM | ||
+ | |||
+ | ====================================================== search constraint | ||
+ | max heap exceeded: 10MB >= 9MB | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | One can constrain JPF from checking more than 100 bytecode instructions as follows. | ||
+ | We can assign any long value to the property budget.max_insn. | ||
+ | |||
+ | < | ||
+ | target=Constraints | ||
+ | classpath=. | ||
+ | cg.enumerate_random=true | ||
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | budget.max_insn=100 | ||
+ | </ | ||
+ | |||
+ | Since this constraint is violated, JPF produces the following output. | ||
+ | |||
+ | < | ||
+ | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. | ||
+ | |||
+ | |||
+ | ====================================================== system under test | ||
+ | Constraints.main() | ||
+ | |||
+ | ====================================================== search started: 1/27/17 1:47 PM | ||
+ | |||
+ | ====================================================== search constraint | ||
+ | max instruction count exceeded: 100 | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | We can also limit the number of states that JPF explores by setting the property budget.max_state. | ||
+ | |||
+ | < | ||
+ | target=Constraints | ||
+ | classpath=. | ||
+ | cg.enumerate_random=true | ||
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | budget.max_state=100 | ||
+ | </ | ||
+ | |||
+ | Since the statespace of this app consists of more than 100 states, JPF stops and produces the following output. | ||
- | - range.vars=altitude, | + | < |
- | - range.altitude.var=x.y.SomeClass.computeTrajectory(int):a | + | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. |
- | - range.altitude.min=125000 | + | |
- | gov.nasa.jpf.listener.ObjectTracker | ||
- | - ot.include | ||
- | - ot.exclude | ||
- | - ot.refs | ||
- | - ot.log_calls | ||
- | - ot.log_fields | ||
- | gov.nasa.jpf.listener.OOMEInjector | + | ====================================================== system under test |
- | - oome.locations | + | Constraints.main() |
- | - oome.types | + | |
- | gov.nasa.jpf.listener.PathOutputMonitor | + | ====================================================== search started: |
- | Examples | + | |
- | - perturb.fields | + | |
- | - perturb.altitude.field | + | |
- | - perturb.altitude.class | + | |
- | - perturb.altitude.location | + | |
- | - perturb.altitude.delta | + | |
- | - perturb.returns | + | ====================================================== search constraint |
- | - perturb.velocity.method | + | max states exceeded: 100 |
- | - perturb.velocity.class = .perturb.IntOverUnder | + | ... |
- | - perturb.velocity.delta = 50 | + | </ |
- | - perturb.params = foo, ... | + | We can also constrain the depth of the search. The corresponding property, budget.max_depth, can take any int value. |
- | - perturb.foo.method = x.y.MyClass.send(int, float, boolean) | + | |
- | - perturb.foo.location = MyClass.java: | + | |
- | - perturb.class = .perturb.dataAbstractor | + | |
- | gov.nasa.jpf.listener.ReferenceLocator | + | < |
- | - refloc.create | + | target=Constraints |
- | - refloc.release | + | classpath=. |
- | - refloc.use | + | cg.enumerate_random=true |
+ | listener=gov.nasa.jpf.listener.BudgetChecker | ||
+ | budget.max_depth=100 | ||
+ | </ | ||
- | gov.nasa.jpf.listener.SearchStats | + | Since the depth of the search is greater than 100 for this app, JPF stops and produces the following output. |
- | gov.nasa.jpf.listener.StackDepthChecker | + | < |
- | - sdc.max_stack_depth | + | JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved. |
- | gov.nasa.jpf.listener.StackTracker | ||
- | - jpf.stack_tracker.log_period | ||
- | gov.nasa.jpf.listener.StateCountEstimator | + | ====================================================== system under test |
- | - jpf.state_count_estimator.log_period | + | Constraints.main() |
- | gov.nasa.jpf.listener.StateTracker | + | ====================================================== search started: 1/27/17 1:53 PM |
- | - jpf.state_tracker.log_period | + | |
- | gov.nasa.jpf.listener.VarRecorder | + | ====================================================== search constraint |
- | - var_recorder.include | + | max search depth exceeded: 100 |
- | - var_recorder.exclude | + | ... |
- | - var_recorder.fields | + | </ |
- | - var_recorder.locals | + | |
- | - var_recorder.arrays | + | |
- | gov.nasa.jpf.listener.VarTracker | ||
- | - vt.include | ||
- | - vt.exclude | ||
- | - vt.max_vars | ||
- | - vt.methods | ||
lab4.1485546136.txt.gz · Last modified: 2017/01/27 19:42 by franck