[project @ 1999-07-06 15:23:17 by simonmar]
[ghc-hetmet.git] / ghc / docs / users_guide / debugging.vsgml
index 8931dd6..2d99076 100644 (file)
@@ -17,13 +17,13 @@ HACKER TERRITORY. HACKER TERRITORY.
 <nidx>GHC phases, changing</nidx>
 <nidx>phases, changing GHC</nidx>
 
-You may specify that a different program
-be used for one of the phases of the compilation system, in place of
-whatever the driver @ghc@ has wired into it.  For example, you
-might want to try a different assembler.  The
-@-pgm<phase-code><program-name>@<nidx>-pgm&lt;phase&gt;&lt;stuff&gt; option</nidx> option to
-@ghc@ will cause it to use @<program-name>@ for phase
-@<phase-code>@, where the codes to indicate the phases are:
+You may specify that a different program be used for one of the phases
+of the compilation system, in place of whatever the driver @ghc@ has
+wired into it.  For example, you might want to try a different
+assembler.  The
+@-pgm<phase-code><program-name>@<nidx>-pgm&lt;phase&gt;&lt;stuff&gt;
+option</nidx> option to @ghc@ will cause it to use @<program-name>@
+for phase @<phase-code>@, where the codes to indicate the phases are:
 
 <tabular ca="ll">
 <bf>code</bf> | <bf>phase</bf> @@
@@ -34,6 +34,7 @@ C    | Haskell compiler @@
 c    | C compiler@@
 a    | assembler @@
 l    | linker @@
+dep  | Makefile dependency generator @@
 </tabular>
 
 %----------------------------------------------------------------------
@@ -46,8 +47,9 @@ The preceding sections describe driver options that are mostly
 applicable to one particular phase.  You may also <em>force</em> a
 specific option @<option>@ to be passed to a particular phase
 @<phase-code>@ by feeding the driver the option
-@-opt<phase-code><option>@.<nidx>-opt&lt;phase&gt;&lt;stuff&gt; option</nidx> The
-codes to indicate the phases are the same as in the previous section.
+@-opt<phase-code><option>@.<nidx>-opt&lt;phase&gt;&lt;stuff&gt;
+option</nidx> The codes to indicate the phases are the same as in the
+previous section.
 
 So, for example, to force an @-Ewurble@ option to the assembler, you
 would tell the driver @-opta-Ewurble@ (the dash before the E is
@@ -97,31 +99,43 @@ happening.
 <tag>@-ddump-<pass>@:</tag>
 <nidx>-ddump-&lt;pass&gt; options</nidx>
 Make a debugging dump after pass @<pass>@ (may be common enough to
-need a short form...).  Some of the most useful ones are:
+need a short form...).  You can get all of these at once (<em/lots/ of
+output) by using @-ddump-all@, or most of them with @-ddump-most@.
+Some of the most useful ones are:
 
-<tabular ca="ll">
-@-ddump-rdr@ | reader output (earliest stuff in the compiler) @@
-@-ddump-rn@ | renamer output @@
-@-ddump-tc@ | typechecker output @@
-@-ddump-deriv@ | derived instances @@
-@-ddump-ds@ | desugarer output @@
-@-ddump-simpl@ | simplifer output (Core-to-Core passes) @@
-@-ddump-stranal@ | strictness analyser output @@
-@-ddump-occur-anal@ | `occurrence analysis' output @@
-@-ddump-spec@ | dump specialisation info @@
-@-ddump-stg@ | output of STG-to-STG passes @@
-@-ddump-absC@ | <em>un</em>flattened Abstract~C @@
-@-ddump-flatC@ | <em>flattened</em> Abstract~C @@
-@-ddump-realC@ | same as what goes to the C compiler @@
-@-ddump-asm@ | assembly language from the native-code generator @@
-</tabular>
+<descrip>
+<tag>@-ddump-parsed@:</tag> oarser output
+<tag>@-ddump-rn@:</tag>  renamer output
+<tag>@-ddump-tc@:</tag>  typechecker output
+<tag>@-ddump-deriv@:</tag>  derived instances
+<tag>@-ddump-ds@:</tag>  desugarer output
+<tag>@-ddump-spec@:</tag>  output of specialisation pass
+<tag>@-ddump-rules@:</tag>  dumps all rewrite rules (including those generated by the specialisation pass)
+<tag>@-ddump-simpl@:</tag>  simplifer output (Core-to-Core passes)
+<tag>@-ddump-usagesp@:</tag> UsageSP inference pre-inf and output
+<tag>@-ddump-cpranal@:</tag>  CPR analyser output
+<tag>@-ddump-stranal@:</tag>  strictness analyser output
+<tag>@-ddump-workwrap@:</tag>  worker/wrapper split output
+<tag>@-ddump-occur-anal@:</tag>  `occurrence analysis' output
+<tag>@-ddump-stg@:</tag>  output of STG-to-STG passes
+<tag>@-ddump-absC@:</tag>  <em>un</em>flattened Abstract~C
+<tag>@-ddump-flatC@:</tag>  <em>flattened</em> Abstract~C
+<tag>@-ddump-realC@:</tag>  same as what goes to the C compiler
+<tag>@-ddump-asm@:</tag>  assembly language from the native-code generator
+</descrip>
 
-<nidx>-ddump-rdr option</nidx>%
+<nidx>-ddump-all option</nidx>%
+<nidx>-ddump-most option</nidx>%
+<nidx>-ddump-parsed option</nidx>%
 <nidx>-ddump-rn option</nidx>%
 <nidx>-ddump-tc option</nidx>%
 <nidx>-ddump-deriv option</nidx>%
 <nidx>-ddump-ds option</nidx>%
 <nidx>-ddump-simpl option</nidx>%
+<nidx>-ddump-cpranal option</nidx>%
+<nidx>-ddump-workwrap option</nidx>%
+<nidx>-ddump-rules option</nidx>%
+<nidx>-ddump-usagesp option</nidx>%
 <nidx>-ddump-stranal option</nidx>%
 <nidx>-ddump-occur-anal option</nidx>%
 <nidx>-ddump-spec option</nidx>%
@@ -144,18 +158,27 @@ really desperate:
 % ghc -noC -O -ddump-simpl -dverbose-simpl -dcore-lint Foo.hs
 </verb></tscreen>
 
-<tag>@-dppr-{user,debug,all@}:</tag>
+<tag>@-ddump-simpl-iterations@:</tag>
+<nidx>-ddump-simpl-iterations option</nidx>
+Show the output of each <em/iteration/ of the simplifier (each run of
+the simplifier has a maximum number of iterations, normally 4).  Used
+when even @-dverbose-simpl@ doesn't cut it.
+
+<tag>@-dppr-{user,debug@}:</tag>
 <nidx>-dppr-user option</nidx>
 <nidx>-dppr-debug option</nidx>
-<nidx>-dppr-all option</nidx>
 Debugging output is in one of several ``styles.''  Take the printing
 of types, for example.  In the ``user'' style, the compiler's internal
 ideas about types are presented in Haskell source-level syntax,
 insofar as possible.  In the ``debug'' style (which is the default for
-debugging output), the types are printed in the most-often-desired
-form, with explicit foralls, etc.  In the ``show all'' style, very
-verbose information about the types (e.g., the Uniques on the
-individual type variables) is displayed.
+debugging output), the types are printed in with
+explicit foralls, and variables have their unique-id attached (so you
+can check for things that look the same but aren't).
+
+<tag>@-ddump-simpl-stats@:</tag>
+<nidx>-ddump-simpl-stats option</nidx>
+Dump statistics about how many of each kind
+of transformation too place.  If you add @-dppr-debug@ you get more detailed information.
 
 <tag>@-ddump-raw-asm@:</tag>
 <nidx>-ddump-raw-asm option</nidx>
@@ -183,6 +206,32 @@ Have the renamer report what imports does not contribute.
 %-ddump-asm-globals-info
 
 %----------------------------------------------------------------------
+<sect2>Checking for consistency
+<label id="checking-consistency">
+<p>
+<nidx>consistency checks</nidx>
+<nidx>lint</nidx>
+
+<descrip>
+<tag>@-dcore-lint@:</tag>
+<nidx>-dcore-lint option</nidx>
+Turn on heavyweight intra-pass sanity-checking within GHC, at Core
+level.  (It checks GHC's sanity, not yours.)
+
+<tag>@-dstg-lint@:</tag>
+<nidx>-dstg-lint option</nidx>
+Ditto for STG level.
+
+<tag>@-dusagesp-lint@:</tag>
+<nidx>-dstg-lint option</nidx>
+Turn on checks around UsageSP inference (@-fusagesp@).  This verifies
+various simple properties of the results of the inference, and also
+warns if any identifier with a used-once annotation before the
+inference has a used-many annotation afterwards; this could indicate a
+non-worksafe transformation is being applied.
+</descrip>
+
+%----------------------------------------------------------------------
 <sect2>How to read Core syntax (from some @-ddump-*@ flags)
 <p>
 <nidx>reading Core syntax</nidx>
@@ -322,51 +371,3 @@ flags in your module, the OPTIONS will get put into the generated .hc
 file).
 
 %----------------------------------------------------------------------
-<sect2>How to compile mutually recursive modules
-<p>
-<nidx>module system, recursion</nidx>
-
-Currently, the compiler does not have proper support for dealing with
-mutually recursive modules:
-
-<tscreen><verb>
-module A where
-
-import B
-
-newtype A = A Int
-
-f :: B -> A
-f (B x) = A x
---------
-module B where
-
-import A
-
-data B = B !Int
-
-g :: A -> B
-g (A x) = B x
-</verb></tscreen>
-
-When compiling either module A and B, the compiler will try (in vain)
-to look for the interface file of the other. So, to get mutually
-recursive modules off the ground, you need to hand write an interface
-file for A or B, so as to break the loop. For the example at hand, the
-boot interface file for A would like the following:
-
-<tscreen><verb>
-_interface_ A 1
-_exports_
-A A(A) f;
-_declarations_
-1 newtype A = A PrelBase.Int ;
-1 f _:_ B.B -> A.A ;;
-</verb></tscreen>
-
-To make sure you get the syntax right, tailoring an existing interface
-file is a Good Idea.
-
-<bf>Note:</bf> This is all a temporary solution, a version of the
-compiler that handles mutually recursive properly without the manual
-construction of interface file, is in the works.