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

Enhancements in the rdbg plugin

- fix the column number (was the char number in the file)
- fix the depth of exit events
parent 050dc38d
OASISFormat: 0.4
Name: Lutin
Version: 2.13
Version: 2.14
Authors: Erwan Jahier
Maintainers: erwan.jahier@imag.fr
License: PROP
......
......@@ -471,28 +471,48 @@ let check_satisfiablity (it:t) (g: guard) = (
) with Not_found -> false
)
let min_max_src (bl1,el1,bc1,ec1,bchar1,echar1) (bl2,el2,bc2,ec2,bchar2,echar2) =
let bl,bc =
if bl1 < bl2 then bl1,bc1 else if
bl1 > bl2 then bl2,bc2 else bl1, min bc1 bc2
in
let el,ec =
if el1 > el2 then el1,ec1 else if
el1 < el2 then el2,ec2 else el1, max ec1 ec2
in
(bl,el,bc,ec, min bchar1 bchar2, max echar1 echar2)
(* Returns the begin/end line/char of a val_exp *)
let (cstr_src_info_of_val_exp : Syntaxe.val_exp -> int * int * int * int) =
fun e ->
let rec aux (bl,el,bc,ec) e =
let bl = min bl e.Lexeme.src.Lexeme.line
and el = max el e.Lexeme.src.Lexeme.line
and bc = min bc e.Lexeme.src.Lexeme.chstart
and ec = max ec e.Lexeme.src.Lexeme.chend in
let acc = (bl,el,bc,ec) in
let (cstr_src_info_of_val_exp : Syntaxe.val_exp -> int * int * int * int * int * int) =
fun e ->
let rec aux (bl,el,bc,ec,bchar,echar) e =
let acc =
min_max_src (bl,el,bc,ec,bchar,echar)
(e.Lexeme.src.Lexeme.line,
e.Lexeme.src.Lexeme.line,
e.Lexeme.src.Lexeme.cstart,
e.Lexeme.src.Lexeme.cend,
e.Lexeme.src.Lexeme.chstart,
e.Lexeme.src.Lexeme.chend
)
in
match e.Lexeme.it with
| Syntaxe.PRE_n id ->
(min bl id.Lexeme.src.Lexeme.line,
max el id.Lexeme.src.Lexeme.line,
min bc id.Lexeme.src.Lexeme.chstart,
max ec id.Lexeme.src.Lexeme.chend)
| Syntaxe.CALL_n (_,vel) -> List.fold_left aux acc vel
| Syntaxe.ERUN_n(_, ve1, ve2) -> aux (aux acc ve1) ve2
| Syntaxe.RUN_n (_, ve1, _) -> aux acc ve1
| Syntaxe.ASSERT_n (_, ve1, _) -> aux acc ve1
| _ -> acc
in
| Syntaxe.PRE_n id -> min_max_src acc
(id.Lexeme.src.Lexeme.line,
id.Lexeme.src.Lexeme.line,
id.Lexeme.src.Lexeme.cstart,
id.Lexeme.src.Lexeme.cend,
id.Lexeme.src.Lexeme.chstart,
id.Lexeme.src.Lexeme.chend)
| Syntaxe.CALL_n (_,vel) -> List.fold_left aux acc vel
| Syntaxe.ERUN_n(_, ve1, ve2) -> aux (aux acc ve1) ve2
| Syntaxe.RUN_n (_, ve1, _) -> aux acc ve1
| Syntaxe.ASSERT_n (_, ve1, _) -> aux acc ve1
| _ -> acc
in
aux (e.Lexeme.src.Lexeme.line, e.Lexeme.src.Lexeme.line,
e.Lexeme.src.Lexeme.cstart, e.Lexeme.src.Lexeme.cend,
e.Lexeme.src.Lexeme.chstart, e.Lexeme.src.Lexeme.chend) e
exception No_src_info
......@@ -505,22 +525,24 @@ let rec (to_src_info: CoIdent.src_stack -> Event.src_info_atom) =
{
Event.file = lxm.Lexeme.file;
Event.line = lxm.Lexeme.line, lxm.Lexeme.line;
Event.char = lxm.Lexeme.chstart, lxm.Lexeme.chend;
Event.char = lxm.Lexeme.cstart, lxm.Lexeme.cend;
Event.stack = if tl=[] then None else Some (to_src_info tl);
Event.str = lxm.Lexeme.str;
}
| (lxm,_,Some ve)::tl ->
let line_b, line_e, char_b, char_e = cstr_src_info_of_val_exp ve in
let line_b, line_e, col_b, col_e, char_b, char_e = cstr_src_info_of_val_exp ve in
let file = lxm.Lexeme.file in
let filecontent = Util.readfile file in
{
Event.str =
(try String.sub filecontent char_b (char_e - char_b + 1)
with _ ->
try String.sub filecontent char_b (String.length filecontent - char_b)
with _ ->
Printf.sprintf "%s: fail to get chars %i-%i" file char_b char_e);
Event.file = file;
Event.line = line_b, line_e;
Event.char = char_b, char_e;
Event.char = col_b, col_e;
Event.stack = if tl=[] then None else Some (to_src_info tl);
}
......@@ -2269,6 +2291,7 @@ and (to_reactive_prg_ldbg :
let edata = List.map (fun (n,v) -> n, Value.to_data_val v) edata in
let predata = (Value.OfIdent.content data.pres) in
let predata = List.map (fun (n,v) -> "pre_"^n, Value.to_data_val v) predata in
let ctx_save = ctx in
let ctx = { ctx with
Event.name = rid;
Event.data = edata@predata;
......@@ -2276,10 +2299,12 @@ and (to_reactive_prg_ldbg :
Event.outputs = List.map to_event_var (out_var_list it);
}
in
let (cont2: ctx -> behavior -> e) = fun ctx b ->
let ctx = Event.incr_event_depth ctx in
let d = ctx.Event.depth in
let (cont2: ctx -> behavior -> e) = fun ctx2 b ->
match b with
| Raise x -> excn_cont ctx x
| Vanish -> fail_cont ctx
| Raise x -> excn_cont ctx2 x
| Vanish -> fail_cont ctx2
| Goto (zeguard, ctrl') ->
(* THIS IS THE NORMAL BEHAVIOR *)
let (outs, locs) =
......@@ -2308,20 +2333,20 @@ and (to_reactive_prg_ldbg :
Value.to_data_val (Value.OfIdent.get locs (Var.name x)))
(loc_var_list it)
in
let enb,d = ctx.Event.nb, ctx.Event.depth in
let ctx = event_incr ctx it.arg_opt in
let ctx = Event.decr_event_depth ctx in
let si_atoms = List.map to_src_info zeguard.g_src in
let cstr = Exp.to_expr zeguard.g_form in
let ctx = { ctx with
Event.name = rid_ctx;
Event.depth = d_ctx;
}
in
let ctx2 = { ctx_save with
(* once we exit, we return back to the previous ctx *)
Event.nb = ctx2.Event.nb;
Event.data = edata; (* used? *)
Event.depth = ctx.Event.depth -1
}
in
let ctx2 = event_incr ctx2 it.arg_opt in
let event =
{
Event.step = ctx.Event.step;
Event.nb = enb;
Event.nb = ctx2.Event.nb-1;
Event.depth = ctx.Event.depth;
Event.kind = Event.Exit;
Event.lang = "lutin";
......@@ -2338,7 +2363,7 @@ and (to_reactive_prg_ldbg :
});
Event.next =
(fun () ->
cont ctx (Reactive.DoStep_ldbg (to_reactive_prg_ldbg rid it state'))
cont ctx2 (Reactive.DoStep_ldbg (to_reactive_prg_ldbg rid it state'))
outvals );
Event.terminate = ctx.Event.terminate;
}
......@@ -2347,11 +2372,11 @@ and (to_reactive_prg_ldbg :
in
let enb = ctx.Event.nb in
let ctx = event_incr ctx it.arg_opt in
let ctx = Event.incr_event_depth ctx in
let ctx = Event.incr_event_depth ctx in (* inner events are one step deapper *)
{
Event.step = ctx.Event.step;
Event.nb = enb ;
Event.depth = d_ctx;
Event.depth = d;
Event.kind = Event.Call;
Event.lang = "lutin";
Event.name = rid;
......@@ -2467,6 +2492,7 @@ let (step_ldbg: ctx -> string -> t -> control_state -> data_state ->
(List.map (fun (n,v) ->
"pre_" ^ n, Value.to_data_val v) (Value.OfIdent.content data.mems))
in
let ctx_save = ctx in
let ctx = { ctx with
Event.name = node;
Event.depth = ctx.Event.depth+1;
......@@ -2475,7 +2501,7 @@ let (step_ldbg: ctx -> string -> t -> control_state -> data_state ->
Event.outputs = List.map to_event_var (out_var_list prog);
}
in
let cont2 = fun ctx bg ->
let cont2 = fun ctx2 bg ->
match bg with
| NoMoreBehavior i -> assert false
| SomeBehavior (b, bg') -> (
......@@ -2517,21 +2543,26 @@ let (step_ldbg: ctx -> string -> t -> control_state -> data_state ->
in
let edata = edata @ (get_sl (out_var_list prog) outs) in
let edata = edata @ (get_sl (loc_var_list prog) locs) in
let enb,d = ctx.Event.nb, ctx.Event.depth in
let ctx = event_incr ctx prog.arg_opt in
let ctx = Event.decr_event_depth ctx in
let ctx2 = event_incr ctx2 prog.arg_opt in
let ctx2 = { ctx_save with
(* once we exit, we return back to the previous ctx *)
Event.nb = ctx2.Event.nb;
Event.data = edata; (* used? *)
Event.depth = ctx.Event.depth -1
}
in
let si_atoms = List.map to_src_info zeguard.g_src in
let cstr = Exp.to_expr zeguard.g_form in
{
Event.step = ctx.Event.step;
Event.nb = enb;
Event.depth = d;
Event.nb = ctx2.Event.nb-1;
Event.depth = ctx.Event.depth;
Event.kind = Event.Exit;
Event.lang = "lutin";
Event.name = node;
Event.inputs = ctx.Event.inputs;
Event.inputs = ctx.Event.inputs;
Event.outputs = ctx.Event.outputs;
Event.data = ctx.Event.data @ edata;
Event.data = edata;
Event.sinfo = Some (fun () -> {
Event.expr = cstr;
......@@ -2541,16 +2572,16 @@ let (step_ldbg: ctx -> string -> t -> control_state -> data_state ->
});
(* Event.Exit (guard_to_string zeguard, cstr, lazy_si) *)
Event.next = (fun () -> cont ctx ctrl data);
Event.terminate = ctx.Event.terminate;
Event.next = (fun () -> cont ctx2 ctrl data);
Event.terminate = ctx2.Event.terminate;
}
)
)
in
let enb = ctx.Event.nb in
let ctx = event_incr ctx prog.arg_opt in
let ctx = event_incr ctx prog.arg_opt in
let d = ctx.Event.depth in
let ctx = Event.incr_event_depth ctx in
let ctx = { ctx with depth = ctx.Event.depth+1 } in
{ ctx with
Event.nb = enb;
Event.depth = d;
......
let str="2.13"
let sha="6a277ae"
let str="2.14"
let sha="050dc38"
Markdown is supported
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