Version française
Home     About     Download     Resources     Contact us    
Browse thread
Debugging the compiler
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques GARRIGUE <garrigue@m...>
Subject: Re: [Caml-list] Debugging the compiler
From: Jacques Carette <carette@mcmaster.ca>
Subject: [Caml-list] Debugging the compiler
Date: Sat, 27 Dec 2008 10:24:52 -0500

> Nothing like the holidays for a little playing around with some ideas by 
> modifying a compiler...  Having got the hang of bootstrapping the 
> compiler [with help from old caml-list postings], I managed to get quite 
> a few things working, but now I have a bug.  I dug around the configure 
> scripts and the Makefiles, and did not see any ready-made way to compile 
> the compiler with debugging enabled - is this possible?  I searched the 
> archives for help on this topic, but came up empty-handed.
> 
> Any and all advice on 'debugging the compiler' would be most appreciated.

The way I do it is

  make "CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot -g" ocamlc

That is, just add -g to the definition in the main Makefile.
(You can also add it there directly)

Then you can run ocamlc with ocamldebug:

ocamldebug -I util -I parsing -I typing -I bytecomp -I driver ocamlc -c test.ml

Adding all these paths is useful once you get inside the debugger.
For instance, if you want to debug the typechecker, you generally
want to put a checkpoint on Error.report (in driver), and you can
use Printtyp.raw_type_expr to print recursive types.

Jacques