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

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

Re-organise the Event.t structure
parent 138dbd8f
......@@ -17,7 +17,7 @@ $(EXPDIR):
# make test.rif 6.90s user 0.07s system 98% cpu 7.056 total
# make test 6.66s user 0.10s system 97% cpu 6.893 total
test.rif:
rm -f test.rif .lurette_rc
......
......@@ -79,7 +79,6 @@ let e = next_cond e heat_on;;
(* gdb like Breakpoints *)
reset_rp();add_rp "env:lutin:ex1.lut:main2" ;set_sim2chro false;set_gnuplot false;;
show_src:=true;;
let e = run();;
break "ex1.lut::34" ;;
let e = continue e;;
......@@ -91,8 +90,7 @@ let e = continue e;;
(* hooks and custom traces *)
let my_print_event e =
match e.kind with
| Node n ->
print_string (n()).name
| Node n -> print_string n.name
| _ -> ()
;;
del_hooks "print_event";;
......@@ -101,11 +99,12 @@ let e = nexti e 20;;
del_hooks "print_event";;
let src =
let Node n = e.kind in
List.iter (fun si -> print_string si.str) (n()).src;
n();;
match e.kind with
| Node {port=Exit(cstr,src)}
| Node {port=Fail(cstr,src)} ->
List.iter (fun si -> print_string si.str) (src());
| _ -> ()
;;
......@@ -128,16 +127,6 @@ apropos "show";;
help "profiler";;
(* XXX *)
let src =
let Node n = e.kind in
List.iter (fun si -> print_string si.str) (n()).src;
n();;
......
This diff is collapsed.
......@@ -9,5 +9,5 @@ arg=$@
. "@LURETTEPATH@/bin/set_env_var"
exec "@LURETTEPATH@/bin/ldbg_exe.top" $arg -I @LURETTEPATH@/lib/
exec "@LURETTEPATH@/bin/ldbg_exe.top" $arg -I @LURETTEPATH@/lib/ -I `ocamlc -where`
......@@ -19,28 +19,25 @@ type src_info = {
}
(* Source info related to the elected constraint *)
type cstr_lazy_src_info = (unit -> src_info list)
type port =
| Call
| Exit of string (* The elected contraint that produced the outputs *) * cstr_lazy_src_info
| Fail of string (* The elected contraint that failed *) * cstr_lazy_src_info
type node_info = {
lang : string;
port : port;
name : string;
src : src_info list;
cstr : string; (* The elected contraint *)
lang : string;
inputs : string list;
outputs : string list;
}
type kind =
| Node of (unit -> node_info)
| Node of node_info
| Ltop
| Noinfo
type port =
| Call
| Exit
| Fail
(* type port = *)
(* | Call of string *)
(* | Exit of string * cstr * (unit -> src_info list) *)
(* | Fail of string * cstr * (unit -> src_info list) *)
(* when an elected constraint is unsatisfiable *)
......@@ -49,7 +46,6 @@ type t = {
step : int;
depth : int;
kind : kind;
port : port;
data : Data.subst list;
other : string;
next : unit -> t;
......
......@@ -30,19 +30,23 @@ let print_src_info si =
let (print_src : Event.t -> unit) =
fun e ->
match e.kind with
| Node node -> List.iter print_src_info (node()).src
| Node { port = Exit(_,src) }
| Node { port = Fail(_,src) } ->
List.iter print_src_info (src())
|_ -> ();;
let (print_cstr : Event.t -> unit) =
fun e ->
match e.kind with
| Node node -> print_string (" \"" ^(node()).cstr ^ "\"")
| Node { port = Exit(cstr,_) }
| Node { port = Fail(cstr,_) } ->
print_string (" \"" ^cstr ^ "\"")
|_ -> ();;
let (port2str: Event.port -> string) =
function
| Exit -> "exit"
| Fail -> "fail"
| Exit (_,_)-> "exit"
| Fail (_,_) -> "fail"
| Call -> "call"
let print_event (e:t) =
......@@ -52,11 +56,9 @@ let print_event (e:t) =
let blanks = String.make e.depth ' ' in
(match e.kind with
| Node n ->
Printf.printf "%3i %3i %s%s %-15s\t[%s]" e.nb e.step blanks (port2str e.port) (n()).name vals;
Printf.printf "%3i %3i %s%s %-15s\t[%s]" e.nb e.step blanks (port2str n.port) n.name vals;
| Ltop ->
Printf.printf "%3i %3i %s%s %-15s\t[%s]" e.nb e.step blanks (port2str e.port) "ltop" vals;
| Noinfo ->
Printf.printf "%3i %3i %s%s %-15s\t[%s]" e.nb e.step blanks (port2str e.port) "??" vals;
Printf.printf "%3i %3i %s%s %-15s\t[%s]" e.nb e.step blanks "exit" "ltop" vals;
);
if !show_constraint then print_cstr e;
print_string "\n";
......@@ -98,7 +100,7 @@ let rec (next_node : Event.t -> string -> Event.t) =
fun e n ->
let is_node_n e =
match e.kind with
| Node node -> (node()).name=n
| Node node -> node.name=n
| _ -> false
in
next_cond e is_node_n
......@@ -130,12 +132,13 @@ let rec (next_line : Event.t -> string -> int -> Event.t) =
fun e f line ->
let the_line e =
match e.kind with
| Node node ->
| Node { port = Exit(_,src)}
| Node { port = Fail(_,src)} ->
List.exists
(fun si ->
Filename.basename si.file = f &&
(fst si.line <= line && line <= snd si.line))
(node()).src
(src())
| _ -> false
in
next_cond e the_line
......@@ -156,26 +159,27 @@ let (break_matches : Event.t -> string -> bool) =
let i = try int_of_string ln with _ -> -1 in
(d <= i && i <= f)
in
match e.kind, Str.split (Str.regexp "::") b with
| (Ltop|Noinfo),_ -> false
| Node _, [] -> false
| Node n, str::tail ->
let ni = n() in
match e.kind, Str.split (Str.regexp "::") b with
| (Ltop),_ -> false
| Node _, [] -> false
| Node { port = Call}, _ -> false
| Node { name=name; port = Fail(_,src)}, str::tail
| Node { name=name; port = Exit(_,src)}, str::tail ->
if Sys.file_exists str then
match tail with
| [ln] ->
List.exists
(fun si -> si_match_file str si && si_match_line ln si) ni.src
| [] -> List.exists (si_match_file str) ni.src
(fun si -> si_match_file str si && si_match_line ln si) (src())
| [] -> List.exists (si_match_file str) (src())
| _ -> false
else
(* str in a node *)
ni.name = str &&
(match tail with
| [] -> true
| [ln] -> List.exists (si_match_line ln) ni.src
| _ -> false
)
name = str &&
(match tail with
| [] -> true
| [ln] -> List.exists (si_match_line ln) (src())
| _ -> false
)
let (goto : Event.t -> string -> Event.t) =
fun e b ->
......@@ -232,7 +236,9 @@ let incr_prof si =
let (prof_add: Event.t -> unit) =
fun e ->
match e.kind with
| Node n -> List.iter incr_prof (n()).src
| Node { port = Exit(_,src) }
| Node { port = Fail(_,src) } ->
List.iter incr_prof (src())
| _ -> ()
let (profiler : bool -> unit) =
......
......@@ -402,7 +402,6 @@ let (start : unit -> Event.t) =
Event.step = i;
Event.kind = Event.Ltop;
Event.depth = 1;
Event.port = Event.Exit;
Event.data = edata;
Event.other = "";
Event.next =
......
......@@ -1435,25 +1435,24 @@ let rec (genpath_ldbg : t -> store -> CoTraceExp.t -> Event.ctx -> (behavior ->
br_cont.doit_ldbg (Goto (new_acc, TE_eps)) cont
else
let lazy_si () = List.map to_src_info (
if snd si = [] then acc.g_src else (snd si)::acc.g_src)
in
let event =
{
Event.step = ctx.Event.ctx_step;
Event.nb = Event.get_nb ();
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Fail;
Event.kind = (* compute it if necessary only *)
Event.Node (* CstrUnsat ? *)
(fun () -> {
Event.lang = "lutin";
Event.name = ctx.Event.ctx_name;
Event.src =
List.map to_src_info (
if snd si = [] then acc.g_src else (snd si)::acc.g_src);
Event.cstr = CoAlgExp.lus_dumps ae;
Event.inputs = ctx.Event.ctx_inputs; (* get it from ctx *)
Event.outputs = ctx.Event.ctx_outputs;
});
{
Event.lang = "lutin";
Event.name = ctx.Event.ctx_name;
Event.port = Event.Fail (CoAlgExp.lus_dumps ae, lazy_si);
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
};
Event.other = "";
Event.data = ctx.Event.ctx_data;
Event.next =
......@@ -2110,29 +2109,28 @@ and (to_reactive_prg_ldbg : Event.ctx -> string -> t -> internal_state -> Value.
(loc_var_list it)
in
let enb = Event.incr_nb (); Event.get_nb () in
let lazy_si () = List.map to_src_info zeguard.g_src in
let event =
{
Event.step = ctx.Event.ctx_step;
Event.nb = enb;
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.kind =
Event.Node
(fun () -> {
Event.lang = "lutin";
Event.name = rid;
Event.src = List.map to_src_info zeguard.g_src;
Event.cstr = guard_to_string zeguard;
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
});
{
Event.lang = "lutin";
Event.port = Event.Exit (guard_to_string zeguard, lazy_si);
Event.name = rid;
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
};
Event.other = "";
Event.data = edata;
Event.next =
(fun () ->
Event.event_nb := enb ;
cont (Reactive.DoStep_ldbg (to_reactive_prg_ldbg ctx rid it state'))
outvals );
Event.event_nb := enb ;
cont (Reactive.DoStep_ldbg (to_reactive_prg_ldbg ctx rid it state'))
outvals );
Event.terminate = ctx.Event.ctx_terminate;
}
in
......@@ -2143,16 +2141,14 @@ and (to_reactive_prg_ldbg : Event.ctx -> string -> t -> internal_state -> Value.
Event.step = ctx.Event.ctx_step;
Event.nb = (Event.incr_nb (); Event.get_nb ());
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Call;
Event.kind =
Event.Node (fun () -> {
Event.lang = "lutin";
Event.name = rid;
Event.src = [];
Event.cstr = "";
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
});
Event.Node {
Event.lang = "lutin";
Event.port = Event.Call;
Event.name = rid;
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
};
Event.data = edata @ predata;
Event.other = "";
Event.next = (fun () -> genpath_ldbg it data cstate ctx cont2 );
......@@ -2297,20 +2293,19 @@ let (step_ldbg: Event.ctx -> string -> t -> control_state -> data_state ->
let edata = edata @ (get_sl (out_var_list prog) outs) in
let edata = edata @ (get_sl (loc_var_list prog) locs) in
let enb = Event.incr_nb (); Event.get_nb () in
let lazy_si () = List.map to_src_info zeguard.g_src in
{
Event.step = ctx.Event.ctx_step;
Event.nb = enb;
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.kind =
Event.Node (fun () -> {
Event.lang = "lutin";
Event.name = node;
Event.src = List.map to_src_info zeguard.g_src;
Event.cstr = guard_to_string zeguard;
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
});
Event.Node {
Event.lang = "lutin";
Event.name = node;
Event.port = Event.Exit (guard_to_string zeguard, lazy_si);
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
};
Event.data = ctx.Event.ctx_data @ edata;
Event.other = "";
Event.next = (fun () -> Event.event_nb := enb ; cont ctrl data);
......@@ -2323,16 +2318,14 @@ let (step_ldbg: Event.ctx -> string -> t -> control_state -> data_state ->
Event.step = ctx.Event.ctx_step;
Event.nb = (Event.incr_nb (); Event.get_nb ());
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Call;
Event.kind =
Event.Node (fun () -> {
Event.lang = "lutin";
Event.name = node;
Event.src = [];
Event.cstr = "";
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
});
Event.Node {
Event.lang = "lutin";
Event.name = node;
Event.port = Event.Call;
Event.inputs = ctx.Event.ctx_inputs;
Event.outputs = ctx.Event.ctx_outputs;
};
Event.data = ctx.Event.ctx_data;
Event.other = "";
Event.next = (fun () ->
......
......@@ -478,6 +478,11 @@ ldbg: $(OBJDIR)
$(MAKE) -k ln -f ../Lurettetop/Makefile.ldbg && \
$(MAKE) -k top -f ../Lurettetop/Makefile.ldbg
ldbgbc: $(OBJDIR)
cd $(OBJDIR) && \
$(MAKE) -k ln -f ../Lurettetop/Makefile.ldbg && \
$(MAKE) -k bcl -f ../Lurettetop/Makefile.ldbg
ldbgnc: $(OBJDIR)
cd $(OBJDIR) && \
$(MAKE) -k ln -f ../Lurettetop/Makefile.ldbg && \
......
......@@ -92,17 +92,15 @@ let (make_ec : string -> vars * vars * (string -> unit) *
Event.nb = Event.get_nb ();
Event.step = ctx.Event.ctx_step;
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.kind = Event.Node (fun () ->
Event.kind = Event.Node
{
Event.lang = "lustre";
Event.port = Event.Exit("",fun () -> []);
Event.name=ec_file;
Event.src = [];
Event.cstr = "";
Event.inputs = [] ;
Event.outputs = [];
});
};
Event.other = "";
Event.data = ctx.Event.ctx_data;
Event.next = (fun () -> cont (step sl) ctx);
......@@ -216,18 +214,16 @@ let (make_socket_do : string -> int -> in_channel *
Event.step = ctx.Event.ctx_step;
Event.data = ctx.Event.ctx_data;
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.nb = Event.get_nb ();
Event.kind = Event.Node (fun () ->
Event.kind = Event.Node
{
Event.lang = "socket";
Event.name=sock_adr ^ ":" ^ (string_of_int port);
Event.src = [];
Event.cstr = "";
Event.port = Event.Exit("",fun () -> []);
Event.inputs = [] ;
Event.outputs = [];
});
};
Event.other = "";
Event.next = (fun () -> cont (step sl) ctx);
Event.terminate = ctx.Event.ctx_terminate;
......@@ -322,13 +318,11 @@ let (make_ec_exe : string -> vars * vars * (string -> unit) *
Event.data = ctx.Event.ctx_data;
Event.nb = Event.get_nb ();
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.kind = Event.Node (fun () ->
Event.kind = Event.Node (
{
Event.lang = "ec";
Event.name=ec_file;
Event.src = [];
Event.cstr = "";
Event.port = Event.Exit("",fun() -> []);
Event.inputs = [] ;
Event.outputs = [];
......@@ -508,13 +502,11 @@ let (make_ocaml : string -> vars * vars *
Event.data = ctx.Event.ctx_data;
Event.nb = Event.get_nb ();
Event.depth = ctx.Event.ctx_depth;
Event.port = Event.Exit;
Event.kind = Event.Node (fun () ->
Event.kind = Event.Node (
{
Event.lang = "ocaml";
Event.name=cmxs;
Event.src = [];
Event.cstr = "";
Event.port = Event.Exit("",fun() -> []);
Event.inputs = [] ;
Event.outputs = [];
......
......@@ -62,13 +62,13 @@
(looking-at "--")))
(setq comment-start "(*")
(setq comment-end "*)")
(setq comment-start "-- ")
(setq comment-end "")
(setq comment-start "(*")
(setq comment-end "*)")
;;; Major-mode
(defun lutin-mode ()
......
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