Program Monitoring
Course material for part II of CS 119 - Reliable Software: Testing and Monitoring
Caltech, third term 2009, Monday/Wednesday 2:30-3:55, Jorgensen 287
Teacher
Klaus Havelund,
Phone (cell): 650-814-0677, Email: havelund@gmail.com
Teaching Assistant
Mihai Florian,
Phone: 626-395-3552, Email: mflorian@cs.caltech.edu
Part I
Part I of this course
on testing is taught by Alex Groce
Acknowledgements
acknowledgements
Last day of class: Friday May 29, 2009.
Overview
This course offers an introduction to the theory and practice of
program monitoring, or runtime verification as we shall call it.
Runtime verification is the study of how to design
artifacts for monitoring and analyzing program executions. Such
artifacts can be used for a variety of purposes, including testing/program
understanding and fault protection. Although programmers have written
more or less ad-hoc monitors since the birth of the computer, only recently
(last decade) has this areas achieved a status as a field on its own.
In this course we shall specifically focus on notations for specifying
properties of Java programs, and frameworks
for monitoring such. The course will initially address the issue of program
instrumentation and monitoring using aspect oriented programming and Java.
This will not only provide the student with a new useful technology but will
also motivate tools presented later in the course.
At the end of the course the student will have gained insight into the
important problems in the field and will have encountered
a core selection of solutions for monitoring programs.
The course will enable the student to apply monitoring in software development
as well as initiate research in this field.
Although the course focuses on Java, the ideas extend to other languages.
We will study 3 systems: AspectJ (lectures 2-3), JavaMOP (lectures 4-7,) and RuleR (lecture 8).
Systems
- AspectJ (aspect oriented programming)
- MOP
(monitoring oriented programming)
- RuleR
(rule-based monitoring)
Lecture Plan
Lecture 1, Monday May 4 - Introduction
Lecture 2, Wednesday May 6 - Introduction to AspectJ
- Slides:
- Note 2
- Resources: the same as for lecture 1.
Lecture 3, Monday May 11 - Monitoring with AspectJ
- Slides:
- Note 3
- Resources: the same as for lecture 1.
- In addition the following Stack interface, Stack class and user program from the
assignment:
- The following Apache collections framework is used to implement the 3
classes (below):
IdentityHashSet.java
,
WeakIdentityHashSet.java
and
WeakIdentityHashMap.java
.
These are useful for writing realistic monitors.
Install the Apache package and the three classes.
The java.util
package already offers
a IdentityHashMap
.
Identity means:
objects (keys in the case of maps) are compared using
==
rather than equals()
. This is important since
monitored objects may get modfied by the monitored program.
Weak means:
the garbage collector will collect an object (key in the case of maps)
if the only references left are weak (or of course if there are no references).
Lecture 4, Wednesday May 13 - State Machines and Regular Expressions
Lecture 5, Monday May 18 - Parameterized State Machines and Regular Expressions
- Slides:
- Note 5
- Resources:
- Website: JavaMOP
(specifically FSM and ERE).
- JavaMOP generates aspects. To run these you must have
AspectJ
installed.
- The aspects generated furthermore use
Apache commons collections,
which you also need to install as a library visible where you install the generated aspects.
- Test program and aspect for assignment 2:
- Test.java
- Monitor.aj
Your task is to write the same spec as represented by the aspect, but using JavaMOP
regular expressions or/and state machines (see the note for this lecture).
- In case you want to run
Monitor.aj
above, you need to download the classes
IdentityHashSet.java
and WeakIdentityHashSet.java
from lecture 3.
Lecture 6, Wednesday May 20 - Temporal Logic
Lecture 7, Friday May 29 - Context Free Grammars
Note 7 contains an additional last assignment 3 (easy if you solved assignment 2) due Friday June 5.
Lecture 8, Rule-Based Systems
This class was not be held. Slides appear below for those interested.