Permalink
Browse files

[debug] add a MIR-TRACE environment variable that will recompile the …

…stdlib with a p4 extension that does a debug print on every module entry. Extremely useful to see control-flow through the entire system.

Original extension from Jeremie Dimino <jeremie@dimino.org> and
adapted to Mirage by Anil Madhavapeddy <anil@recoil.org>
  • Loading branch information...
1 parent 262c582 commit aa2c579db3bca6463ce6deba8b7da79601bb5c1c @avsm committed Jun 6, 2012
Showing with 20 additions and 5 deletions.
  1. +4 −1 Makefile
  2. +13 −4 lib/myocamlbuild.ml
  3. +1 −0 syntax/_tags
  4. +2 −0 syntax/all.itarget
View
@@ -14,9 +14,12 @@ export PREFIX
JOBS ?= -j 6
export JOBS
-MIR-DEBUG ?= 0
+MIR-DEBUG ?= 1
export MIR-DEBUG
+MIR-TRACE ?= 0
+export MIR-TRACE
+
all:
@cd tools && $(MAKE)
@cd syntax && $(MAKE)
View
@@ -28,6 +28,10 @@ let debug =
let e = getenv "MIR-DEBUG" ~default:"0" in
match e with "0" -> false | _ -> true
+let trace =
+ let e = getenv "MIR-TRACE" ~default:"0" in
+ match e with "0" -> false | _ -> true
+
let profiling = false
(* In case you have problems with natdynlink, set this to false *)
let native_p4 = true
@@ -283,13 +287,18 @@ let _ = dispatch begin function
let p4_build = "../../../syntax/_build" in
let camlp4_bc =
S[A"-pp";
- A (ps "camlp4o -I %s str.cma pa_mirage.cma -cow-no-open %s"
- p4_build (if debug then "-lwt-debug" else ""))]
+ A (ps "camlp4o -I %s str.cma pa_mirage.cma -cow-no-open %s %s"
+ p4_build (if debug then "-lwt-debug" else "")
+ (if trace then "pa_trace.cma" else "")
+ )
+ ]
in
let camlp4_nc =
S[A"-pp";
- A (ps "camlp4o.opt -I %s str.cmxs pa_mirage.cmxs -cow-no-open %s"
- p4_build (if debug then "-lwt-debug" else ""))]
+ A (ps "camlp4o.opt -I %s str.cmxs pa_mirage.cmxs -cow-no-open %s %s"
+ p4_build (if debug then "-lwt-debug" else "")
+ (if trace then "pa_trace.cmxs" else "")
+ )]
in
let camlp4_cmd = if native_p4 then camlp4_nc else camlp4_bc in
flag ["ocaml"; "compile" ; "pa_mirage"] & camlp4_cmd;
View
@@ -1,4 +1,5 @@
<pa_type_conv.*>: for-pack(Pa_mirage), use_camlp4_r
+<pa_trace.*>: use_camlp4_o
"pa_cow.ml": for-pack(Pa_mirage), use_camlp4_o
"pa_cstruct.cmx" or "pa_js.cmx" or "pa_bitstring.cmx" or "pa_dyntype.cmx" or "pa_json.cmx" or "pa_xml.cmx" or "pa_css.cmx" or "pa_html.cmx" or "pa_lwt.cmx" or "pa_ulex.cmx" or "pa_cow.cmx": for-repack(Pa_mirage)
true: linkall
View
@@ -1,3 +1,5 @@
str.cmxs
pa_mirage.cmxs
pa_mirage.cma
+pa_trace.cmxs
+pa_trace.cma

0 comments on commit aa2c579

Please sign in to comment.