Commit c9bcc18e authored by mnislaih's avatar mnislaih
Browse files

GHCi debugger: Added a -fprint-evld-with-show flag

    
    The flag enables the use of Show instances in :print.
    By default they are not used anymore
parent 966eddaa
...@@ -25,6 +25,7 @@ import Name ...@@ -25,6 +25,7 @@ import Name
import UniqSupply import UniqSupply
import TcType import TcType
import GHC import GHC
import DynFlags
import InteractiveEval import InteractiveEval
import Outputable import Outputable
import Pretty ( Mode(..), showDocWith ) import Pretty ( Mode(..), showDocWith )
...@@ -138,7 +139,11 @@ bindSuspensions cms@(Session ref) t = do ...@@ -138,7 +139,11 @@ bindSuspensions cms@(Session ref) t = do
-- A custom Term printer to enable the use of Show instances -- A custom Term printer to enable the use of Show instances
showTerm :: Session -> Term -> IO SDoc showTerm :: Session -> Term -> IO SDoc
showTerm cms@(Session ref) = cPprTerm (liftM2 (++) cPprShowable cPprTermBase) showTerm cms@(Session ref) term = do
dflags <- GHC.getSessionDynFlags cms
if dopt Opt_PrintEvldWithShow dflags
then cPprTerm (liftM2 (++) cPprShowable cPprTermBase) term
else cPprTerm cPprTermBase term
where where
cPprShowable _y = [\prec ty _ val tt -> cPprShowable _y = [\prec ty _ val tt ->
if not (all isFullyEvaluatedTerm tt) if not (all isFullyEvaluatedTerm tt)
......
...@@ -266,6 +266,7 @@ data DynFlag ...@@ -266,6 +266,7 @@ data DynFlag
| Opt_Hpc_No_Auto | Opt_Hpc_No_Auto
| Opt_BreakOnException | Opt_BreakOnException
| Opt_BreakOnError | Opt_BreakOnError
| Opt_PrintEvldWithShow
| Opt_GenManifest | Opt_GenManifest
| Opt_EmbedManifest | Opt_EmbedManifest
| Opt_RunCPSZ | Opt_RunCPSZ
...@@ -1192,6 +1193,7 @@ fFlags = [ ...@@ -1192,6 +1193,7 @@ fFlags = [
( "rewrite-rules", Opt_RewriteRules ), ( "rewrite-rules", Opt_RewriteRules ),
( "break-on-exception", Opt_BreakOnException ), ( "break-on-exception", Opt_BreakOnException ),
( "break-on-error", Opt_BreakOnError ), ( "break-on-error", Opt_BreakOnError ),
( "print-evld-with-show", Opt_PrintEvldWithShow ),
( "run-cps", Opt_RunCPSZ ), ( "run-cps", Opt_RunCPSZ ),
( "convert-to-zipper-and-back", Opt_ConvertToZipCfgAndBack), ( "convert-to-zipper-and-back", Opt_ConvertToZipCfgAndBack),
( "vectorise", Opt_Vectorise ), ( "vectorise", Opt_Vectorise ),
......
...@@ -514,6 +514,12 @@ ...@@ -514,6 +514,12 @@
<entry>dynamic</entry> <entry>dynamic</entry>
<entry><option>-fno-break-on-error</option></entry> <entry><option>-fno-break-on-error</option></entry>
</row> </row>
<row>
<entry><option>-fprint-evld-with-show</option></entry>
<entry><link linkend="breakpoints">Enable usage of Show instances in <literal>:print</literal></link></entry>
<entry>dynamic</entry>
<entry><option>-fno-print-evld-with-show</option></entry>
</row>
<row> <row>
<entry><option>-fno-print-bind-result</option></entry> <entry><option>-fno-print-bind-result</option></entry>
<entry><link linkend="ghci-stmts">Turn off printing of binding results in GHCi</link></entry> <entry><link linkend="ghci-stmts">Turn off printing of binding results in GHCi</link></entry>
......
...@@ -929,6 +929,7 @@ right :: [a] ...@@ -929,6 +929,7 @@ right :: [a]
<literal>left</literal>:</para> <literal>left</literal>:</para>
<screen> <screen>
[qsort.hs:2:15-46] *Main> :set -fprint-evld-with-show
[qsort.hs:2:15-46] *Main> :print left [qsort.hs:2:15-46] *Main> :print left
left = (_t1::[a]) left = (_t1::[a])
</screen> </screen>
...@@ -948,6 +949,13 @@ left = (_t1::[a]) ...@@ -948,6 +949,13 @@ left = (_t1::[a])
underscore, in this case underscore, in this case
<literal>_t1</literal>.</para> <literal>_t1</literal>.</para>
<para>The flag <literal>-fprint-evld-with-show</literal> instructs
<literal>:print</literal> to reuse
available <literal>Show</literal> instances when possible. This happens
only when the contents of the variable being inspected
are completely evaluated.</para>
<para>If we aren't concerned about preserving the evaluatedness of a <para>If we aren't concerned about preserving the evaluatedness of a
variable, we can use <literal>:force</literal> instead of variable, we can use <literal>:force</literal> instead of
<literal>:print</literal>. The <literal>:force</literal> command <literal>:print</literal>. The <literal>:force</literal> command
...@@ -1017,6 +1025,7 @@ right :: [a] ...@@ -1017,6 +1025,7 @@ right :: [a]
<para>The execution continued at the point it previously stopped, and has <para>The execution continued at the point it previously stopped, and has
now stopped at the breakpoint for a second time.</para> now stopped at the breakpoint for a second time.</para>
<sect3 id="setting-breakpoints"> <sect3 id="setting-breakpoints">
<title>Setting breakpoints</title> <title>Setting breakpoints</title>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment