Debug a Lustre program with rdbg
This Tiny Tutorial shows a basic usage of rdbg
to debug a Lustre program.
Consider this Lustre program, which computes a sinus and a cosinus wave in a discrete manner.
node sincos(omega : real) returns (sin, cos: real);
var pcos, psin: real;
let
pcos = 1.0 fby cos;
psin = 0.0 fby sin;
sin = omega * integrator( pcos,0.1,0.0);
cos = omega * integrator(-psin,0.1,1.0);
tel
node integrator(F,STEP,init: real) returns (Y: real);
let
Y = init -> pre(Y) + ((F + pre(F))*STEP)/2.0;
tel
One can simulate this node:
lv6 sincos.lus -n sincos -exec
In order to avoid the need of providing an input to the sincos
node,
we will run a simpler node sincos_test
, with no input.
node sincos_test() returns (sin, cos: real);
let
sin,cos=sincos(0.2);
tel
Now to simulate this node during 1500 steps, and output the generated
Data in a RIF file named sincos.rif
, one can use lurette as follows:
lurette -sut "lv6 sincos.lus -n sincos_test" -l 1500 -o sincos.rif
gnuplot-rif sincos.rif
In order to inpect the execution of this node (typically for debug),
one just need to replace lurette
by rdbg
.
rdbg -sut "lv6 sincos.lus -n sincos_test" -l 1500 -o sincos.rif
Then at the rdbg
prompt, you can type l
to get the list of
avalaible commands. For instance, try to type:
n
n
ni 20
b
b
bi 20
cg
The last command ougth to display the call graph computed from the
current call. With cgf
, you get a pdf where nodes are
clickable. Then, if you type s
(move forward of one step), the
values on the callgraphs wires ougth to change.
More on rdbg
: http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/rdbg/README.html