printf output using Promela and SPIN?

I am a beginner trying to use Promela and SPIN. As I am developing some simple Promela specifications, I want to check the values of variables in my program by using printf(). I have read this man page and am trying to run a simple hello world program, but I don't see any output text. Here is the sample hello world file:

init {
    printf("MSC: passed first test!\n")

The steps that I use to compile and run are

spin -a hello.pml
cc -o run pan.c

The output from running is

hint: this search is more efficient if pan.c is compiled -DSAFETY
(Spin Version 4.2.6 -- 27 October 2005)
        + Partial Order Reduction

Full statespace search for:
        never claim             - (none specified)
        assertion violations    +
        acceptance   cycles     - (not selected)
        invalid end states      +

State-vector 12 byte, depth reached 2, errors: 0
       3 states, stored
       0 states, matched
       3 transitions (= stored+matched)
       0 atomic steps
hash conflicts: 0 (resolved)

4.879   memory usage (Mbyte)

unreached in proctype :init:
        (0 of 2 states)

So, where can I find my output from the printf statement? I have tried printf statements in more complicated promela files as well, but obviously I want to get it working for the simple case first. Any insight would be appreciated. Thanks!


When you run a SPIN verification there is no printed output; only an indication of whether or not errors were found (and other performance information). Note, since you are a beginner, you 'run a SPIN verification' when you invoke spin with 'spin -a …' and then run the compiled code.

There are two ways to see output. First, use SPIN in simulation mode by using spin hello.pml. For example:

$ cat >hello.pml <<EOF
> init { printf ("hello world\n"); }
$ spin hello.pml 
      hello world
1 process created

Second, use SPIN in verification mode but inject an error into your program. After the error occurs, examine the trail file. For example:

$ cat >hello.pml <<EOF
> init { printf ("hello world\n"); assert (0); }
$ spin -a hello.pml
$ gcc -o hello pan.c
$ ./hello
hint: this search is more efficient if pan.c is compiled -DSAFETY
pan:1: assertion violated 0 (at depth 0)
pan: wrote hello.pml.trail
State-vector 12 byte, depth reached 0, errors: 1
pan: elapsed time 0 seconds
$ spin -p -t hello.pml
using statement merging
      hello world
  1:    proc  0 (:init:) hello.pml:1 (state 1)  [printf('hello world\\n')]
spin: hello.pml:1, Error: assertion violated
spin: text of failed assertion: assert(0)
  1:    proc  0 (:init:) hello.pml:1 (state 2)  [assert(0)]
spin: trail ends after 1 steps
#processes: 1
  1:    proc  0 (:init:) hello.pml:1 (state 3) <valid end state>
1 process created

You can find 'hello world' in the above after spin -p -t hello.pml

Need Your Help

Java, setting layout to null

java swing layout-manager

I have been using a null layout and I alot of people will say it shouldn't be done this way. Is there a better way?

Structuring my data - Firebase

database firebase

I'm creating a prototype group list application. I want the following objects: