Commit e3e449d4 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

A third step towards a Morphine lutin/lustre debugger for lurette/lutin/lustre.

Now I can trace lutin step called from run statements!

I've duplicated a lot of code in LutExe ; i'll fix that later...
parent e4303116
......@@ -355,6 +355,7 @@ LUTIN_FILES = \
$(OBJDIR)/errors.ml \
$(OBJDIR)/lutParser.mly \
$(OBJDIR)/lutLexer.mll \
$(OBJDIR)/event.ml \
$(OBJDIR)/reactive.mli \
$(OBJDIR)/reactive.ml \
$(OBJDIR)/syntaxe.ml \
......
../up_and_down/ud.lut
\ No newline at end of file
let between(x, min, max : real) : bool = ((min < x) and (x < max))
node up(init, delta:real) returns( x : real) =
x = init fby loop { between(x, pre x, pre x + delta) }
node down(init, delta:real) returns( x : real) =
x = init fby loop { between(x, pre x - delta, pre x) }
node up_and_down(min, max, delta : real) returns (x : real) =
between(x, min, max)
fby
loop {
| run x := up(pre x, delta) in loop { x < max }
| run x := down(pre x, delta) in loop { x > min }
}
node main () returns (x : real) =
run x:= up_and_down(0.0, 100.0, 5.0)
......@@ -46,3 +46,25 @@ node main2(Heat_on : bool) returns (
T3 : real) =
loop T3 = 0.0
--------------------------------------------------------
node draw_temp(h:bool; t:real) returns (nt:real) =
assert (abs(t - nt) < 1.0 ) in
loop { if h then nt >= t else nt <= t }
node main3(Heat_on : bool) returns (
T : real;
T1 : real;
T2 : real;
T3 : real) =
assert abs(T-T1) < 0.5 in
assert abs(T-T2) < 0.5 in
assert abs(T-T3) < 0.5 in
between(T, 6.0, 9.0)
fby
loop
run T := draw_temp(Heat_on, pre T)
......@@ -8,6 +8,7 @@ type ctx = (* herited debug info *)
type t = {
step : int;
kind : string; (* XXX Mettre un type somme bien propre à terme *)
src : (string * int * int) list;
data: Data.subst list;
next: unit -> t;
terminate: unit -> unit;
......
......@@ -15,12 +15,15 @@ let stl i = ltop ("stl " ^ (string_of_int i))
let add_rp str = ltop ("add_rp \"" ^ str ^ "\"")
(* XXX finish me! *)
let no_gnuplot () = LtopArg.args.LtopArg.display_gnuplot <- false
let no_sim2chro () = LtopArg.args.LtopArg.display_sim2chro <- false
let run = RunDirect.start
let next = Event.next
let data = Event.data
let terminate = Event.terminate
let off () = fun () -> LtopArg.args.LtopArg.ldbg <- false
let on () = fun () -> LtopArg.args.LtopArg.ldbg <- true
let off () = LtopArg.args.LtopArg.ldbg <- false
let on () = LtopArg.args.LtopArg.ldbg <- true
let rec (goto : Event.t -> int -> Event.t) =
fun e i ->
......
......@@ -363,6 +363,7 @@ let (start : unit -> Event.t) =
Event.step = i;
Event.data = edata;
Event.kind = "ltop_step";
Event.src = [];
Event.next =
(fun () ->
loop (check_oracles oracle_in_vals i oracle_out_l oracle_out_vals_l cov)
......
......@@ -71,10 +71,12 @@ type t =
| TE_erun of string * escope * CoAlgExp.t list * t
(* internal run (running) *)
| TE_dyn_erun of string * Reactive.prg * CoIdent.t list * CoAlgExp.t list * t
| TE_dyn_erun_ldbg of string * Reactive.prg_ldbg * CoIdent.t list * CoAlgExp.t list * t
(* internal run (not running) *)
| TE_run of string * CoAlgExp.t * escope * CoAlgExp.t list * t
(* internal run (running) *)
| TE_dyn_run of string * Reactive.prg * CoAlgExp.t * escope * CoAlgExp.t list * t
| TE_dyn_run_ldbg of string * Reactive.prg_ldbg * CoAlgExp.t * escope * CoAlgExp.t list * t
(** Batterie de créateurs *)
......@@ -273,6 +275,7 @@ let rec _dump (pr: string -> unit) te = (
pr " in ";
_dump pr e ;
)
| TE_dyn_erun_ldbg (rid, _, vars, args, e)
| TE_dyn_erun (rid, _, vars, args, e) -> (
pr "erun ";
let pp i = (
......@@ -288,6 +291,7 @@ let rec _dump (pr: string -> unit) te = (
pr " in ";
_dump pr e ;
)
| TE_dyn_run_ldbg (rid, _, _, vars, args, e)
| TE_dyn_run (rid, _, _, vars, args, e) -> (
pr "erun ";
let pp (i,vo) = (
......
......@@ -47,8 +47,10 @@ type t =
(* internal run *)
| TE_erun of string * escope * CoAlgExp.t list * t
| TE_dyn_erun of string * Reactive.prg * CoIdent.t list * CoAlgExp.t list * t
| TE_dyn_erun_ldbg of string * Reactive.prg_ldbg * CoIdent.t list * CoAlgExp.t list * t
| TE_run of string * CoAlgExp.t * escope * CoAlgExp.t list * t
| TE_dyn_run of string * Reactive.prg * CoAlgExp.t * escope * CoAlgExp.t list * t
| TE_dyn_run_ldbg of string * Reactive.prg_ldbg * CoAlgExp.t * escope * CoAlgExp.t list * t
(** Réinitialisation du module
pour les compteurs de loop (au cas où) ? *)
......
......@@ -1440,7 +1440,7 @@ and
List.iter f newidlist;
(* on continu dans ce nouvel env ... *)
let res = treat_trace zeres env sstack ee in
CoTraceExp.of_exist zescope.sco_escope res
CoTraceExp.of_exist zescope.sco_escope res
)
| ERUN_n (varlist, edef, e1) -> (
(* edef doit etre un node call (pour l'instant !) *)
......
This diff is collapsed.
......@@ -87,7 +87,9 @@ val make_pre : t -> Var.env_in -> Var.env_out -> Var.env_loc -> Var.env
(*
May raise Deadlock
*)
val step: t -> control_state -> data_state -> control_state * data_state
val step: t -> control_state -> data_state -> control_state * data_state
val step_ldbg: Event.ctx -> string -> t -> control_state -> data_state ->
(control_state -> data_state -> Event.t) -> Event.t
(***** Interface for building simple step main loop (e.g. for run statements *)
......
......@@ -4,3 +4,9 @@
type prg = DoStep of (Value.t list -> Value.t list * prg)
let step p = match p with DoStep _p -> _p
type prg_ldbg = DoStep_ldbg of ( Value.t list -> (prg_ldbg -> Value.t list -> Event.t) -> Event.t)
let (step_ldbg : prg_ldbg -> Value.t list -> (prg_ldbg -> Value.t list -> Event.t) -> Event.t) =
fun p vl cont ->
match p with DoStep_ldbg _p -> _p vl cont
......@@ -4,3 +4,9 @@
type prg = DoStep of (Value.t list -> Value.t list * prg)
val step : prg -> Value.t list -> (Value.t list * prg)
type prg_ldbg =
DoStep_ldbg of ( Value.t list -> (prg_ldbg -> Value.t list -> Event.t) -> Event.t)
val step_ldbg : prg_ldbg -> Value.t list -> (prg_ldbg -> Value.t list -> Event.t) -> Event.t
......@@ -92,6 +92,7 @@ let (make_ec : string -> vars * vars * (string -> unit) *
Event.step = ctx.Event.ctx_step;
Event.data = ctx.Event.ctx_data;
Event.kind = "lustre_step";
Event.src = [];
Event.next = (fun () -> cont (step sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
}
......@@ -202,6 +203,7 @@ let (make_socket_do : string -> int -> in_channel *
{
Event.step = ctx.Event.ctx_step;
Event.data = ctx.Event.ctx_data;
Event.src = [];
Event.kind = "socket_step";
Event.next = (fun () -> cont (step sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
......@@ -294,6 +296,7 @@ let (make_ec_exe : string -> vars * vars * (string -> unit) *
{
Event.step = ctx.Event.ctx_step;
Event.data = ctx.Event.ctx_data;
Event.src = [];
Event.kind = "ec_step";
Event.next = (fun () -> cont (step sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
......@@ -467,6 +470,7 @@ let (make_ocaml : string -> vars * vars *
{
Event.step = ctx.Event.ctx_step;
Event.data = ctx.Event.ctx_data;
Event.src = [];
Event.kind = "ocaml_step";
Event.next = (fun () -> cont (OcamlRM.get_step cmxs sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
......
......@@ -50,18 +50,26 @@ let make_lut argv =
let (lut_step_dbg:
Data.subst list -> Event.ctx -> (Data.subst list -> Event.ctx -> Event.t) -> Event.t) =
fun sl ctx cont ->
{
Event.step = ctx.Event.ctx_step;
Event.kind = "lutin_step prog='" ^ (String.concat "," prog) ^
"' node ='" ^ node ^ "' \n dump expr =" ^
(LutExe.string_of_control_state !ctrl_state) ^ " \n stack : "
(* ^ *)
(* (CoIdent.string_of_src_stack ()) *)
;
Event.data = ctx.Event.ctx_data;
Event.next = (fun () -> cont (lut_step sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
}
let cont_lut_step =
fun new_cs new_ds ->
ctrl_state := new_cs;
data_state := new_ds;
cont (to_subst_list lut_out new_ds.LutExe.outs) ctx
in
data_state := { !data_state with LutExe.ins = to_vals sl };
(* { (* XXX l'enlever quand j'aurais trouvé le bon endroit dans lutExe ?? *) *)
(* Event.step = ctx.Event.ctx_step; *)
(* Event.kind = "lutin_step prog='" ^ (String.concat "," prog) ^ *)
(* "' node ='" ^ node ^ "' \n dump expr =" ^ *)
(* (LutExe.string_of_control_state !ctrl_state) ^ " \n stack : " *)
(* (* ^ *) *)
(* (* (CoIdent.string_of_src_stack ()) *) *)
(* ; *)
(* Event.data = ctx.Event.ctx_data; *)
(* Event.next = (fun () -> *)
LutExe.step_ldbg ctx node lut_mach !ctrl_state !data_state cont_lut_step;
(* Event.terminate = ctx.Event.ctx_terminate; *)
(* } *)
in
let mems_in =
List.fold_left
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment