Commit 458ee4fe authored by Simon Marlow's avatar Simon Marlow

Add -fghci-hist-size=N to set the number of previous steps stored by :trace

parent 3a6b1bfb
...@@ -670,6 +670,8 @@ data DynFlags = DynFlags { ...@@ -670,6 +670,8 @@ data DynFlags = DynFlags {
maxWorkerArgs :: Int, maxWorkerArgs :: Int,
ghciHistSize :: Int,
-- | MsgDoc output action: use "ErrUtils" instead of this if you can -- | MsgDoc output action: use "ErrUtils" instead of this if you can
log_action :: LogAction, log_action :: LogAction,
flushOut :: FlushOut, flushOut :: FlushOut,
...@@ -1227,6 +1229,8 @@ defaultDynFlags mySettings = ...@@ -1227,6 +1229,8 @@ defaultDynFlags mySettings =
maxWorkerArgs = 10, maxWorkerArgs = 10,
ghciHistSize = 50, -- keep a log of length 50 by default
log_action = defaultLogAction, log_action = defaultLogAction,
flushOut = defaultFlushOut, flushOut = defaultFlushOut,
flushErr = defaultFlushErr, flushErr = defaultFlushErr,
...@@ -2126,6 +2130,8 @@ dynamic_flags = [ ...@@ -2126,6 +2130,8 @@ dynamic_flags = [
, Flag "fmax-worker-args" (intSuffix (\n d -> d {maxWorkerArgs = n})) , Flag "fmax-worker-args" (intSuffix (\n d -> d {maxWorkerArgs = n}))
, Flag "fghci-hist-size" (intSuffix (\n d -> d {ghciHistSize = n}))
------ Profiling ---------------------------------------------------- ------ Profiling ----------------------------------------------------
-- OLD profiling flags -- OLD profiling flags
......
...@@ -220,13 +220,15 @@ runStmtWithLocation source linenumber expr step = ...@@ -220,13 +220,15 @@ runStmtWithLocation source linenumber expr step =
let ic = hsc_IC hsc_env let ic = hsc_IC hsc_env
bindings = (ic_tythings ic, ic_rn_gbl_env ic) bindings = (ic_tythings ic, ic_rn_gbl_env ic)
size = ghciHistSize idflags'
case step of case step of
RunAndLogSteps -> RunAndLogSteps ->
traceRunStatus expr bindings tyThings traceRunStatus expr bindings tyThings
breakMVar statusMVar status emptyHistory breakMVar statusMVar status (emptyHistory size)
_other -> _other ->
handleRunStatus expr bindings tyThings handleRunStatus expr bindings tyThings
breakMVar statusMVar status emptyHistory breakMVar statusMVar status (emptyHistory size)
runDecls :: GhcMonad m => String -> m [Name] runDecls :: GhcMonad m => String -> m [Name]
runDecls = runDeclsWithLocation "<interactive>" 1 runDecls = runDeclsWithLocation "<interactive>" 1
...@@ -268,8 +270,8 @@ withVirtualCWD m = do ...@@ -268,8 +270,8 @@ withVirtualCWD m = do
parseImportDecl :: GhcMonad m => String -> m (ImportDecl RdrName) parseImportDecl :: GhcMonad m => String -> m (ImportDecl RdrName)
parseImportDecl expr = withSession $ \hsc_env -> liftIO $ hscImport hsc_env expr parseImportDecl expr = withSession $ \hsc_env -> liftIO $ hscImport hsc_env expr
emptyHistory :: BoundedList History emptyHistory :: Int -> BoundedList History
emptyHistory = nilBL 50 -- keep a log of length 50 emptyHistory size = nilBL size
handleRunStatus :: GhcMonad m => handleRunStatus :: GhcMonad m =>
String-> ([TyThing],GlobalRdrEnv) -> [Id] String-> ([TyThing],GlobalRdrEnv) -> [Id]
......
...@@ -510,6 +510,12 @@ ...@@ -510,6 +510,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>-fghci-hist-size=<replaceable>n</replaceable></option></entry>
<entry><link linkend="ghci-debugger">Set the number of entries GHCi keeps for <literal>:history</literal></link></entry>
<entry>dynamic</entry>
<entry><option>(default is 50)</option></entry>
</row>
<row> <row>
<entry><option>-fprint-evld-with-show</option></entry> <entry><option>-fprint-evld-with-show</option></entry>
<entry><link linkend="breakpoints">Enable usage of Show instances in <literal>:print</literal></link></entry> <entry><link linkend="breakpoints">Enable usage of Show instances in <literal>:print</literal></link></entry>
......
...@@ -1715,8 +1715,7 @@ a :: a ...@@ -1715,8 +1715,7 @@ a :: a
<para>The history is only available when <para>The history is only available when
using <literal>:trace</literal>; the reason for this is we found that using <literal>:trace</literal>; the reason for this is we found that
logging each breakpoint in the history cuts performance by a factor of logging each breakpoint in the history cuts performance by a factor of
2 or more. GHCi remembers the last 50 steps in the history (perhaps in 2 or more. By default, GHCi remembers the last 50 steps in the history, but this can be changed with the <option>-fghci-hist-size=<replaceable>n</replaceable></option><indexterm><primary><option>&ndash;fghci-hist-size</option></primary></indexterm> option).</para>
the future we'll make this configurable).</para>
</sect2> </sect2>
<sect2 id="ghci-debugger-exceptions"> <sect2 id="ghci-debugger-exceptions">
...@@ -2381,10 +2380,12 @@ Prelude> :. cmds.ghci ...@@ -2381,10 +2380,12 @@ Prelude> :. cmds.ghci
<indexterm><primary><literal>:history</literal></primary></indexterm> <indexterm><primary><literal>:history</literal></primary></indexterm>
</term> </term>
<listitem> <listitem>
<para>Display the history of evaluation steps. With a number, <para>Display the history of evaluation steps. With a
displays that many steps (default: 20). For use with number, displays that many steps (default: 20). For use
<literal>:trace</literal>; see <xref with <literal>:trace</literal>; see <xref linkend="tracing"
linkend="tracing" />.</para> />. To set the number of history entries stored by GHCi,
use
<option>-fghci-hist-size=<replaceable>n</replaceable></option>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
Markdown is supported
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