Contents:
You can obtain more information about Daikon from its website. In particular, you can read its manual (HTML, PDF) or download it. If you have any problems with Daikon, please send mail to daikon-developers@pag.lcs.mit.edu and/or ask a 6.170 staff member.
athena% daikon
Usage: daikon [OPTIONS] <CLASS TO OBSERVE> <TEST DRIVER> [MAIN ARGUMENTS]
Options:
-o, --output FILE Save invariants in FILE.inv
...
The "CLASS TO OBSERVE" variable specifies the class file Daikon
will observe for invariant detection while running your test driver.
For the test driver, you must supply the name of a "main" class which
provides the method
"public static void main(String[] args)".
Daikon will run this class to exercise your program.
See the command line options section for
details on the available options for daikon.
The GUI (Graphical User Interface) shows a tree view of the results. On the first level, it shows a list of the classes under inspection. As each class is expanded, a list of program points is displayed.
A program point is usually associated with a specific place in the source code. For example, the ENTER point under the foo() node represents the preconditions upon entry to the foo() method.
The ENTER and EXIT program points identify points at the entry and exit of the given method. The OBJECT program point indicates representation invariants (sometimes called object invariants) that hold for any object of the given class, from the point of view of a client or user. These properties hold at entry to and exit from every public method of the class. The CLASS program point is like the OBJECT program point, but for static variables only.
In the output, the application of orig(x) to a variable x refers to the original value of a formal parameter. orig() variables appear only at EXIT program points.
Negative array indices count backwards from the length of the array; for instance, a[-1] denotes the last element of array a; it is just syntactic sugar for a[a.length-1].
While the method given above will be sufficient for most users, some may want to explore further. This section describes how to use Daikon without the help of the wrapper script. One reason you might want to do this is because it lets you control invariant detection (for instance, which classes are examined and which are ignored). Another benefit is that you may edit and reinstrument some files without starting the whole process each time. Finally, by doing the steps individually, you will gain a better understanding of what is going on behind the scenes. More complete details (including an example of using Daikon) appear in the Daikon manual.
Detecting invariants involves three steps:
Run dfej, the Daikon Front End for Java, on your Java source files:
dfej filename1.java filename2.java ...
The Daikon Front End for Java does two things:
Only the specified Java files will be instrumented; other files will be run uninstrumented. This permits you to control the scope of invariant detection.
Compile the generated files, e.g.
javac daikon-java/*.java
After instrumentation, there are two versions of the program: the original version, and the instrumented version which appears in the daikon-java/ directory. Make sure that the daikon-java/ directory appears on your class path before the directory containing the original Java code. You can do this by running the program from that directory, if "." (the current directory) appears early on your class path, or you can add the daikon-java/ directory to your class path explicitly.
Run the Daikon invariant detector via the command
java daikon.Daikon decl-files... trace-files...
The decl-files are declaration (.decl) files created at
instrumentation time.
The trace-files are data trace (.dtrace) files created by
running the instrumented program.
Be sure to include all declaration files that are needed for the particular
data trace file; the simplest way is to include all the declaration files
created when instrumenting the program that is read.
By default, Daikon produces a textual listing of invariants to standard output (the terminal); however, it can also produce a file that can be loaded in the GUI, using the -o option:
java daikon.Daikon -o foo.inv decl-files... trace-files...
Then, you may run the GUI on that file:
java daikon.gui.InvariantsGUI foo.inv