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

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

A pass to remove performance penalty in lurettetop (now the panalty in less than 1%).
The idea was to compute source info lasily.

Add nonreg tests for ldbg + crazy-rabbit, as well as missing files (oops).

Add online help msgs for the Ldbg_utils modules.
parent 66583b32
......@@ -35,6 +35,7 @@ BIN_INSTALL_DIR=$(PRE_RELEASE_DIR)/bin
LIB_INSTALL_DIR=$(PRE_RELEASE_DIR)/lib
INC_INSTALL_DIR=$(PRE_RELEASE_DIR)/include
CPP=cpp
RANLIB=ranlib
GCC=gcc
GPP=g++
CFLAGS=-g -O2 -fpic -DPOLKA_NUM=3
......
......@@ -43,6 +43,8 @@ test-lutin:
cd lutin/luciole && make test ;
cd lutin/lustre && make test ;
cd lutin/C && make test;
cd lutin/crazy-rabbit && make test;
cd lutin/ldbg && make test;
echo "All lutin tests ran correctly."
# problem ~
......
......@@ -11,7 +11,7 @@ LIBS = -lluc4c_nc -llucky_nc -lgmp -lm -ldl -lstdc++
LUT2C=../../../bin/lutin$(EXE) --2c-4c -seed 42
LUT2CSOCK=../../../bin/lutin$(EXE) --2c-4c-socks 127.0.0.1 -seed 42
CALLVIASOCKET=../../../bin/call-via-socket -addr 127.0.0.1 -port 2002
LUTIN=../../../bin/lutin$(EXE) -seed 42 -only-outputs -exe
LUTIN=../../../bin/lutin$(EXE) -seed 42 -only-outputs
ifeq ($(HOSTTYPE),mac)
LINKER=g++ -g
......
......@@ -4,10 +4,13 @@ LIB=../../../lib
MAIN=rabbit
NEW_LURETTETOP=$(LTOP) --precision 2 \
--test-length 5000 --step-mode Inside --local-var --no-sim2chro \
LURETTETOP=$(LTOP) --precision 2 \
--test-length 500 --step-mode Inside --local-var --no-gnuplot --no-sim2chro \
--do-not-show-step -v 2
EXPDIR=`$(LTOP) --ocaml-version`
$(EXPDIR):
[ -d $(EXPDIR) ] || (mkdir -p $(EXPDIR) ; make utest)
%.cmxs: %.ml
......@@ -18,20 +21,24 @@ clean:
rm -rf *.ec *.cm* *.log *~ .*~ *.o *rif0 *rif Data *.pp_luc *.plot *.gp $(MAIN).opt
test: rabbit.cmxs
test.rif:$(EXPDIR) rabbit.cmxs
rm -f test.rif0 .lurette_rc
$(NEW_LURETTETOP) -go --output test.rif0 -seed 3306566 \
$(LURETTETOP) -go --output test.rif0 -seed 3306566 \
-rp "sut:ocaml:rabbit.cmxs:" \
-rp 'env:lutin:rabbit.lut:-main:rabbit:-L:libm.so:-loc' && \
grep -v "lurette chronogram" test.rif0 | \
grep -v "lurette Version" | \
grep -v "The execution lasted"| sed -e "s/^M//" > test.rif &&\
rm -f test.res && diff -u -i test.rif.exp test.rif > test.res
[ ! -s test.res ] && make clean
grep -v "The execution lasted"| sed -e "s/^M//" > test.rif
utest:
cp $(MAIN).out $(MAIN).out.exp
test: test.rif $(EXPDIR)
rm -f test1.res
diff -B -u -i $(EXPDIR)/test.rif.exp test.rif > test.res || true
cat test.res
[ ! -s test.res ] && make clean
utest:test.rif
cp test.rif $(EXPDIR)/test.rif.exp
......
let myloop(t:trace) : trace = loop try loop t
let t(x:int) :trace =
x=1 fby
x=2 fby
x=3 fby
loop x=4
node main () returns ( x,y : int) =
{ t(x)
&>
t(y) }
let within(min,v,max:int) : bool =
min <= v and v <= max
node within_node(min,max:int) returns (res:int) =
loop within(min,res,max)
node call_within_node(min,max:int) returns (res:int) =
run res := within_node(min,max)
node main2 () returns ( x,y : int) =
exist m1, m2 : int in
run m1 := call_within_node(0,42) in
run m2 := within_node(m1,42) in
run y := within_node(m1,m2) in
x=1 fby
within(2,x,10) fby
x=3 fby
loop within(0,x,10)
LTOP=/usr/local/tools/lustre-misc/lurette/i386-linux-gcc3/bin/lurettetop
LTOP=../../../../bin/lurettetop
LURETTETOP=$(LTOP) --precision 2 \
-rp "sut:lutin:trivial.lut:more" \
-rp "env:lutin:trivial.lut:less" \
--thick-draw 1 \
--draw-inside 0 --draw-edges 0 --draw-vertices 0 --draw-all-vertices \
--step-mode Inside --local-var --no-gnuplot --no-sim2chro --seed 3 \
--do-not-show-step
EXPDIR=`$(LTOP) --ocaml-version`
$(EXPDIR):
[ -d $(EXPDIR) ] || (mkdir -p $(EXPDIR) ; make utest)
# make test.rif 6.90s user 0.07s system 98% cpu 7.056 total
test.rif:
rm -f test.rif .lurette_rc
$(LURETTETOP) --test-length 10000 -go --output test.rif0 && \
grep -v "lurette chronogram" test.rif0 | \
grep -v "This is lurette Version" test.rif0 | \
grep -v "The execution lasted"| sed -e "s/^M//" > test.rif
test:test.rif $(EXPDIR)
rm -f test.res
diff -B -u -i $(EXPDIR)/test.rif.exp test.rif > test.res
cat test.res
[ ! -s test.res ] && make clean
make clean
utest:
cp test.rif $(EXPDIR)/test.rif.exp
clean:
rm -rf *.ec *.log *~ .*~ *.o *rif0 *rif Data *.pp_luc *.plot *.gp *.dro *_luciole.c test.res
dontgo:
rm -f test.rif0 .lurette_rc
$(LTOP) --precision 2 \
-rp "sut:v6:heater_control.lus:heater_control" \
-rp "env:lutin:env.lut:main" \
--thick-draw 1 \
--draw-inside 0 --draw-edges 0 --draw-vertices 0 --draw-all-vertices \
--step-mode Inside --local-var --no-sim2chro --seed 3 \
--do-not-show-step env.lut --output test.rif
node within(min,max:int) returns (res:int) =
loop min <= res and res <= max
node more(x:int) returns (y:int) =
exist delta : int in
run delta := within(0,10) in
loop y = x+delta
node less(y:int) returns (x:int) =
exist delta : int in
run delta := within(0,10) in
x = 0 fby loop x = y-delta
\ No newline at end of file
open Event;;
open Ldbg;;
open Ldbg_utils;;
set_sim2chro false;;
set_gnuplot false;;
show_trace := false;;
ltop "set_seed 1";;
add_rp "sut:lutin:trivial.lut:more" ;;
add_rp "env:lutin:trivial.lut:less" ;;
stl 2000;;
off();;
let e = run ();;
(* exit 0;; *)
let rec loop e =
let e = next e in
loop e
;;
try
loop e
with _ ->
exit 0;;
open Event;;
open Ldbg;;
open Ldbg_utils;;
set_sim2chro false;;
set_gnuplot false;;
ltop "set_seed 1";;
add_rp "env:lutin:ex1.lut:main2" ;;
stl 1000;;
let e = run ();;
let e = nexti e 50;;
exit 0;;
(*
break ""
*)
......@@ -575,6 +575,7 @@ LUS2LIC
MORE_LIB
MORE_INCLUDE
WIN32LIB
EXE
NOCYGWIN
LINKER
LDL
......@@ -2000,6 +2001,7 @@ esac
#-----------------------------------------------------------------------------#
# Ask user for path to more libs and headers
......@@ -3395,7 +3397,7 @@ done
#-----------------------------------------------------------------------------#
ac_config_files="$ac_config_files Makefile.lurette set_env_var xlurette.sh lurettetop.sh show_luc.sh gen_stubs.sh"
ac_config_files="$ac_config_files Makefile.lurette set_env_var lurettetop.sh ldbg gen_stubs.sh"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
......@@ -4105,9 +4107,8 @@ do
case $ac_config_target in
"Makefile.lurette") CONFIG_FILES="$CONFIG_FILES Makefile.lurette" ;;
"set_env_var") CONFIG_FILES="$CONFIG_FILES set_env_var" ;;
"xlurette.sh") CONFIG_FILES="$CONFIG_FILES xlurette.sh" ;;
"lurettetop.sh") CONFIG_FILES="$CONFIG_FILES lurettetop.sh" ;;
"show_luc.sh") CONFIG_FILES="$CONFIG_FILES show_luc.sh" ;;
"ldbg") CONFIG_FILES="$CONFIG_FILES ldbg" ;;
"gen_stubs.sh") CONFIG_FILES="$CONFIG_FILES gen_stubs.sh" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
......@@ -5284,9 +5285,8 @@ do
case $ac_config_target in
"Makefile.lurette") CONFIG_FILES="$CONFIG_FILES Makefile.lurette" ;;
"set_env_var") CONFIG_FILES="$CONFIG_FILES set_env_var" ;;
"xlurette.sh") CONFIG_FILES="$CONFIG_FILES xlurette.sh" ;;
"lurettetop.sh") CONFIG_FILES="$CONFIG_FILES lurettetop.sh" ;;
"show_luc.sh") CONFIG_FILES="$CONFIG_FILES show_luc.sh" ;;
"ldbg") CONFIG_FILES="$CONFIG_FILES ldbg" ;;
"gen_stubs.sh") CONFIG_FILES="$CONFIG_FILES gen_stubs.sh" ;;
"gen_stubs.bat") CONFIG_FILES="$CONFIG_FILES gen_stubs.bat" ;;
"lurettetop.bat") CONFIG_FILES="$CONFIG_FILES lurettetop.bat" ;;
......@@ -5751,6 +5751,7 @@ install ../utils/luckytolatex "$LURETTEPATH/bin/"
install ../utils/simec_trap "$LURETTEPATH/bin/"
install -m a+x,a+r,u+w ./lurettetop.sh "$LURETTEPATH/bin/lurettetop"
install -m a+x,a+r,u+w ./ldbg "$LURETTEPATH/bin/ldbg"
install -m a+x,a+r,u+w ./show_luc.sh "$LURETTEPATH/bin/show_luc"
install -m a+x,a+r,u+w ./xlurette.sh "$LURETTEPATH/bin/xlurette"
install -m a+x,a+r,u+w ./gen_stubs.sh "$LURETTEPATH/bin/gen_stubs"
......
......@@ -166,6 +166,7 @@ AC_SUBST(LIB_GC)
AC_SUBST(LDL)
AC_SUBST(LINKER)
AC_SUBST(NOCYGWIN)
AC_SUBST(EXE)
AC_SUBST(WIN32LIB)
#-----------------------------------------------------------------------------#
......@@ -255,7 +256,7 @@ AC_PROG_AWK
#-----------------------------------------------------------------------------#
AC_OUTPUT(Makefile.lurette set_env_var xlurette.sh lurettetop.sh show_luc.sh gen_stubs.sh)
AC_OUTPUT(Makefile.lurette set_env_var lurettetop.sh ldbg gen_stubs.sh)
# if the user ask to install files in a other place.
......@@ -289,6 +290,7 @@ install ../utils/luckytolatex "$LURETTEPATH/bin/"
install ../utils/simec_trap "$LURETTEPATH/bin/"
install -m a+x,a+r,u+w ./lurettetop.sh "$LURETTEPATH/bin/lurettetop"
install -m a+x,a+r,u+w ./ldbg "$LURETTEPATH/bin/ldbg"
install -m a+x,a+r,u+w ./show_luc.sh "$LURETTEPATH/bin/show_luc"
install -m a+x,a+r,u+w ./xlurette.sh "$LURETTEPATH/bin/xlurette"
install -m a+x,a+r,u+w ./gen_stubs.sh "$LURETTEPATH/bin/gen_stubs"
......
#!/bin/sh
# Set up environment variables needed by lucky, lurettetop, and xlurette
# (sh syntax)
# to put rif file in
[ -d Data ] || mkdir Data
arg=$@
. "@LURETTEPATH@/bin/set_env_var"
exec "@LURETTEPATH@/bin/ldbg_exe.top" $arg -I @LURETTEPATH@/lib/
#
# Makefile for lurettetop, a top-level loop/MUI to use lurette.
#
include $(LURETTE_PATH)/Makefile.common.source
include $(LURETTE_PATH)/source/Makefile.ln
OCAMLFLAGS += -I $(OBJDIR) -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
POLKA=polkag
ifdef STATIC
OCAMLLDFLAGS = -cclib -lstdc++ -cclib -lm -cclib -lc -ccopt -static\
-cclib -l$(POLKA)_caml -cclib -l$(POLKA) -cclib -lgmp $(OCAMLOPTFLAG)
else
OCAMLLDFLAGS= -cclib -lstdc++ -cclib -I/usr/lib/w32api \
-cclib -l$(POLKA)_caml \
-cclib -l$(POLKA) -cclib -lgmp $(OCAMLOPTFLAG)
endif
CC= $(GPP) $(DWIN32)
LIBS = unix dynlink str nums polka bdd
CLIBS = camlidl $(CLIBS_WIN32) bdd_stubs
#USE_CAMLP4 = yes
ZELANG=lut
USE_CAMLP4 = yes
SOURCES = \
$(LUTIN_SOURCES) \
$(OBJDIR)/ltopArg.ml \
$(OBJDIR)/lutinRun.mli \
$(OBJDIR)/lutinRun.ml \
$(OBJDIR)/ocamlRM.mli \
$(OBJDIR)/ocamlRM.ml \
$(OBJDIR)/lustreRun.mli \
$(OBJDIR)/lustreRun.ml \
$(OBJDIR)/ocaml.mli \
$(OBJDIR)/ocaml.ml \
$(OBJDIR)/extTools.mli \
$(OBJDIR)/extTools.ml \
$(OBJDIR)/build.mli \
$(OBJDIR)/build.ml \
$(OBJDIR)/runBin.mli \
$(OBJDIR)/runBin.ml \
$(OBJDIR)/runDirect.mli \
$(OBJDIR)/runDirect.ml \
$(OBJDIR)/runPipe.mli \
$(OBJDIR)/runPipe.ml \
$(OBJDIR)/run.mli \
$(OBJDIR)/run.ml \
$(OBJDIR)/cmd.mli \
$(OBJDIR)/cmd.ml \
$(OBJDIR)/ldbg.mli \
$(OBJDIR)/ldbg.ml \
$(OBJDIR)/ldbg_utils.mli \
$(OBJDIR)/ldbg_utils.ml
RESULT=ldbg_exe$(EXE)
ln: $(OBJDIR) $(SOURCES)
ddot :
ocamldoc -dot $(SOURCES) -dot-reduce -o ltop.dot
dot -Tpdf ltop.dot -o ltop.pdf
xpdf ltop.pdf
OCAMLMAKEFILE = $(LURETTE_PATH)/OcamlMakefile
include $(OCAMLMAKEFILE)
......@@ -26,7 +26,7 @@ type node_info = {
}
type kind =
| Node of node_info
| Node of (unit -> node_info)
| Ltop
| Noinfo
......
......@@ -35,8 +35,6 @@ let on () = LtopArg.args.LtopArg.ldbg <- true
let _ =
LtopArg.args.LtopArg.ldbg <- true
let (get_val_event : Event.t -> unit) =
fun e ->
let nl,vl = List.split e.data in
......@@ -64,23 +62,30 @@ where
*)
let ldbg_mli = Util.readfile (Filename.concat Util2.lurette_lib "ldbg.mli")
let ldbg_utils_mli = Util.readfile (Filename.concat Util2.lurette_lib "ldbg_utils.mli")
let (cmd_list: (string * (string * string)) list) =
let (get_cmd_list: string -> (string * (string * string)) list) = fun mli ->
let rec aux acc i0 =
try
let i1 = Str.search_forward (Str.regexp ("(\*\*")) ldbg_mli i0 in
let i2 = Str.search_forward (Str.regexp ("\*)")) ldbg_mli i1 in
let i3 = Str.search_forward (Str.regexp ("^val ")) ldbg_mli i2 in
let i4 = Str.search_forward (Str.regexp " :") ldbg_mli i3 in
let i5 = Str.search_forward (Str.regexp "\n") ldbg_mli i4 in
let help = String.sub ldbg_mli (i1+4) (i2-i1-5) in
let cmd = String.sub ldbg_mli (i3+4) (i4-i3-4) in
let profile = String.sub ldbg_mli (i4+3) (i5-i4-3) in
let i1 = Str.search_forward (Str.regexp ("(\*\*")) mli i0 in
let i2 = Str.search_forward (Str.regexp ("\*)")) mli i1 in
let i3 = Str.search_forward (Str.regexp ("^val ")) mli i2 in
let i4 = Str.search_forward (Str.regexp " :") mli i3 in
let i5 = Str.search_forward (Str.regexp "\n") mli i4 in
let help = String.sub mli (i1+4) (i2-i1-5) in
let cmd = String.sub mli (i3+4) (i4-i3-4) in
let profile = String.sub mli (i4+3) (i5-i4-3) in
aux ((cmd,(profile,help))::acc) i5
with Not_found -> acc
in
List.rev(aux [] 0)
let (cmd_list: (string * (string * string)) list) =
get_cmd_list ldbg_mli
let cmd_list_utils = get_cmd_list ldbg_utils_mli
let all_cmds = cmd_list @ cmd_list_utils
let get_profile str =
try
......@@ -97,16 +102,21 @@ let print_cmd_list =
let (apropos : string -> unit) =
fun str ->
let l = List.filter
(fun (cmd,_) -> Str.string_match (Str.regexp_string str) cmd 0) cmd_list
(fun (cmd,_) -> Str.string_match (Str.regexp_string str) cmd 0) all_cmds
in
print_cmd_list l
let (help:string -> unit) =
fun cmd ->
if cmd="all" then (
print_string "Type 'help \"command\";;' to obtain more help on the following commands: \n";
print_cmd_list cmd_list
if cmd="base" then (
print_string "Type
help \"command\";;
to obtain more help on the following commands: \n";
print_cmd_list cmd_list
)
else if cmd="utils" then (
print_cmd_list cmd_list_utils
)
else if List.mem_assoc cmd cmd_list then (
let prof,help = List.assoc cmd cmd_list in
......@@ -120,3 +130,36 @@ let (help:string -> unit) =
let h = help
let a = apropos
let _ =
output_string stdout (" This is ldbg Version "^(Version.str)^" ("^Version.sha^") \n");
output_string stdout "type
Ldbg.man ();;
for a small on-line manual\n";
flush stdout
let (man:unit -> unit) =
fun () ->
output_string stdout "
ldbg is a lutin debugger. It is also an ocaml top-level with several
Modules loaded: Event, Ldbg, and Ldbg_utils.
In order to avoid the need of prefixing of every command by its module
name, we advice you to type the following ocaml expressions :
open Event;;
open Ldbg;;
open Ldbg_utils;;
You can put those 2 lines in an ocaml file (say init.ml) that you can
automatically evaluate when invoking ldbg using the -init option
(ldbg -init init.ml).
For more information on available commands, type:
Ldbg.help \"base\";;
for basic commands
Ldbg.help \"utils\";;
for Ldbg_utils commands
Ldbg.apropos \"\";;
for all commands
";
flush stdout
open RunDirect
(** Runs the test and returns the first event. *)
val run : unit -> Event.t
val off : unit -> unit
val add_rp : string -> unit
val set_rp : string -> unit
(** Display info about the test parameters *)
val info : unit -> unit
(** Shortcut for info *)
val i : unit -> unit
(* Display a caml expr that, once evaluated, binds variable values
in the current toplevel. XXX How can it be automated?
*)
val get_val_event : Event.t -> unit
(** Set the maximum number of steps to perform *)
val stl : int -> unit
(** Launch gnuplot-rif to display variable values*)
val set_gnuplot : bool -> unit
(** Launch gnuplot-rif to display variable values*)
val set_sim2chro : bool -> unit
(** To search for commands related to a string *)
val apropos : string -> unit
(** Shortcut for apropos *)
val a : string -> unit
(** Display help about ldbg commands
- Type help "base" for the list of basic commands.
- Type help "utils" for the list of Ldbg_utils commands.
- Type "help" followed by command name for the full documentation of the command.
*)
val help : string -> unit
(** Shortcut for help *)
val h : string -> unit
(** XXX En attendant mieux
Appel à l'interpréteur de commandes de lurettettop.
ltop "help" ;;
permet d'afficher la liste des commandes acceptées.
*)
val ltop : string -> unit
(** Display a small online manual *)
val man : unit -> unit
open Ldbg
open Event
let rec (goto_i : Event.t -> int -> Event.t) =
fun e i ->
if e.nb < i then goto_i (next e) i else e
let rec (goto_s : Event.t -> int -> Event.t) =
fun e i ->
if e.step < i then goto_s (next e) i else e
(******************************************************************)
(* print_event stuff *)
let show_trace = ref true
let show_data = ref true
let show_src = ref false
......@@ -34,13 +30,13 @@ 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 node -> List.iter print_src_info (node()).src
|_ -> ();;
let (print_cstr : Event.t -> unit) =
fun e ->
match e.kind with