<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/01/43de725e35b85d85eaf1871578a00bab"
  from="Jacques GARRIGUE &lt;garrigue@m...&gt;"
  author="Jacques GARRIGUE"
  date="2009-01-03T09:04:52"
  subject="Re: [Caml-list] Debugging the compiler"
  prev="2009/01/abfd0a6b817d919a6553dc0a6c90494d"
  next="2009/01/f0434180d03922ac0bb52d524aa79d6f"
  prev-in-thread="2008/12/dff93ca29f3add51c89622b5fc577398"
  prev-thread="2008/12/7878431a82364a1bcbfe20052682d612"
  next-thread="2009/01/abfd0a6b817d919a6553dc0a6c90494d"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Debugging the compiler">
<msg 
  url="2008/12/dff93ca29f3add51c89622b5fc577398"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2008-12-27T15:25:12"
  subject="Debugging the compiler">
<msg 
  url="2009/01/43de725e35b85d85eaf1871578a00bab"
  from="Jacques GARRIGUE &lt;garrigue@m...&gt;"
  author="Jacques GARRIGUE"
  date="2009-01-03T09:04:52"
  subject="Re: [Caml-list] Debugging the compiler">
</msg>
</msg>
</thread>

<contents>
From: Jacques Carette &lt;carette@mcmaster.ca&gt;
Subject: [Caml-list] Debugging the compiler
Date: Sat, 27 Dec 2008 10:24:52 -0500

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

</contents>

</message>

