User Tools

Site Tools


lab4a

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lab4a [2018/01/23 16:17] francklab4a [2019/01/29 01:12] (current) franck
Line 1: Line 1:
-====== Lab ======+====== Lab ====== 
 + 
 +Implement a listener, named LocalVariableIds, that prints the set of IDs of the local variables manipulated in the main method. A sample run can be found below. It shows what type of output your listener should produce. Here are some hints that may be useful for implementing your listener. 
  
-Implement a listener, named ArrayListener, that counts the number of reads and writes of array cells within the main method of an app.  A sample run can be found below.  It shows what type of output your listener should produce.  Here are some hints that may be useful for implementing your listener. 
   * Consider the interfaces VMListener and SearchListener, which are part of the packages gov.nasa.jpf.vm and gov.nasa.jpf.search, respectively.   * Consider the interfaces VMListener and SearchListener, which are part of the packages gov.nasa.jpf.vm and gov.nasa.jpf.search, respectively.
   * Consider subclasses of the class Instruction, which is part of the package gov.nasa.jpf.vm.   * Consider subclasses of the class Instruction, which is part of the package gov.nasa.jpf.vm.
-  * If you cannot count the number of reads and writes of array cells within the main method of an app, then count the number of reads and writes of array cells of the entire app+  * If you cannot restrict to the local variables manipulated in the main method, then consider all local variables
-  * If you do not know how to print the total at the end, then print a star (*) every time a read or write of an array cell occurs.+  * If you cannot extract the ID of the local variables, then print a star (*) every time a local variable is manipulated
  
 To compile your listener, use To compile your listener, use
 <code> <code>
-javac -cp /cs/fac/packages/jpf/jpf-core/build/jpf.jar:ArrayListener.java+javac -cp /cs/fac/packages/jpf/jpf-core/build/jpf.jar:LocalVariableIds.java
 </code> </code>
 or add /cs/fac/packages/jpf/jpf-core/build/jpf.jar as an external library to Eclipse. or add /cs/fac/packages/jpf/jpf-core/build/jpf.jar as an external library to Eclipse.
Line 15: Line 16:
 To test your listener, you may want to use the following app. To test your listener, you may want to use the following app.
 <code java> <code java>
-public class ArraySample {+public class LocalVariableIdsSample {
     public static void main(String[] args) {     public static void main(String[] args) {
-        int[] array new int[2]+ int 5
-        array[0] 1+ boolean b true
-        array[1] array[0]+ double d 3.0; 
-        array[0]++; +        i++; 
-        array[1] 2;+        false;
     }     }
 } }
Line 28: Line 29:
 To run JPF on the above app, use the following configuration file. To run JPF on the above app, use the following configuration file.
 <code> <code>
-target=ArraySample+target=LocalVariableIdsSample
 classpath=. classpath=.
-listener=ArrayListener+listener=LocalVariableIds
 native_classpath=/eecs/home/franck/ native_classpath=/eecs/home/franck/
 </code> </code>
-where /eecs/home/franck/ is the path to the directory in which ArrayListener.class can be found.+where /eecs/home/franck/ is the path to the directory in which LocalVariableIds.class can be found.
  
 If the above configuration file is used with the above app, JPF should produce output similar to the following. If the above configuration file is used with the above app, JPF should produce output similar to the following.
 <code> <code>
-JavaPathfinder core system v8.0 (rev 29) - (C) 2005-2014 United States Government. All rights reserved.+JavaPathfinder core system v8.0 (rev 32+) - (C) 2005-2014 United States Government. All rights reserved.
  
  
 ====================================================== system under test ====================================================== system under test
-ArraySample.main()+LocalVariableIdsSample.main()
  
-====================================================== search started: 2/5/17 1:20 PM +====================================================== search started: 2/8/18 12:04 PM 
-***** + 
-Total number of reads and writes of array cells: 6 +====================================================== 
-*****+Local variable ids 
 +LocalVariableIdsSample.main([Ljava/lang/String;)V.3 
 +LocalVariableIdsSample.main([Ljava/lang/String;)V.2 
 +LocalVariableIdsSample.main([Ljava/lang/String;)V.1
  
 ====================================================== results ====================================================== results
Line 56: Line 60:
 search:             maxDepth=1,constraints=0 search:             maxDepth=1,constraints=0
 choice generators:  thread=1 (signal=0,lock=1,sharedRef=0,threadApi=0,reschedule=0), data=0 choice generators:  thread=1 (signal=0,lock=1,sharedRef=0,threadApi=0,reschedule=0), data=0
-heap:               new=347,released=12,maxLive=0,gcCycles=1 +heap:               new=346,released=11,maxLive=0,gcCycles=1 
-instructions:       3184 +instructions:       3165 
-max memory:         238MB +max memory:         57MB 
-loaded code:        classes=60,methods=1320+loaded code:        classes=60,methods=1324
  
-====================================================== search finished: 2/5/17 1:20 PM+====================================================== search finished: 2/8/18 12:04 PM
 </code> </code>
  
-To receive feedback, submit your listener using the submit command before Monday February 5+To receive feedback, submit your listener using the submit command before Tuesday February 12
-submit 4315 lab4 ArrayListener.java+submit 4315 lab5 LocalVariableIds.java 
 + 
  
  
lab4a.1516724258.txt.gz · Last modified: 2018/01/23 16:17 by franck

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki