diff options
author | Simon Marlow <marlowsd@gmail.com> | 2018-07-16 19:58:31 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-07-16 19:59:08 -0400 |
commit | 3bdf0d01ff47977830ada30ce85f174098486e23 (patch) | |
tree | a7bcd3a6842b1cc793ce990e924d157a408f93f0 /compiler/ghci/GHCi.hs | |
parent | c4b8e719effe9b420b1c5cec0194134a44b26823 (diff) | |
download | haskell-3bdf0d01ff47977830ada30ce85f174098486e23.tar.gz |
Support the GHCi debugger with -fexternal-interpreter
* All the tests in tests/ghci.debugger now pass with
-fexternal-interpreter. These tests are now run with the ghci-ext way
in addition to the normal way so we won't break it in the future.
* I removed all the unsafeCoerce# calls from RtClosureInspect. Yay!
The main changes are:
* New messages: GetClosure and Seq. GetClosure is a remote interface to
GHC.Exts.Heap.getClosureData, which required Binary instances for
various datatypes. Fortunately this wasn't too painful thanks to
DeriveGeneric.
* No cheating by unsafeCoercing values when printing them. Now we have
to turn the Closure representation back into the native representation
when printing Int, Float, Double, Integer and Char. Of these, Integer
was the most painful - we now have a dependency on integer-gmp due to
needing access to the representation.
* Fixed a bug in rts/Heap.c - it was bogusly returning stack content as
pointers for an AP_STACK closure.
Test Plan:
* `cd testsuite/tests/ghci.debugger && make`
* validate
Reviewers: bgamari, patrickdoc, nomeata, angerman, hvr, erikd, goldfire
Subscribers: alpmestan, snowleopard, rwbarton, thomie, carter
GHC Trac Issues: #13184
Differential Revision: https://phabricator.haskell.org/D4955
Diffstat (limited to 'compiler/ghci/GHCi.hs')
-rw-r--r-- | compiler/ghci/GHCi.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/ghci/GHCi.hs b/compiler/ghci/GHCi.hs index 472f0857cb..579053999f 100644 --- a/compiler/ghci/GHCi.hs +++ b/compiler/ghci/GHCi.hs @@ -21,6 +21,8 @@ module GHCi , enableBreakpoint , breakpointStatus , getBreakpointVar + , getClosure + , seqHValue -- * The object-code linker , initObjLinker @@ -77,6 +79,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as LB import Data.IORef import Foreign hiding (void) +import GHC.Exts.Heap import GHC.Stack.CCS (CostCentre,CostCentreStack) import System.Exit import Data.Maybe @@ -350,6 +353,17 @@ getBreakpointVar hsc_env ref ix = mb <- iservCmd hsc_env (GetBreakpointVar apStack ix) mapM (mkFinalizedHValue hsc_env) mb +getClosure :: HscEnv -> ForeignHValue -> IO (GenClosure ForeignHValue) +getClosure hsc_env ref = + withForeignRef ref $ \hval -> do + mb <- iservCmd hsc_env (GetClosure hval) + mapM (mkFinalizedHValue hsc_env) mb + +seqHValue :: HscEnv -> ForeignHValue -> IO () +seqHValue hsc_env ref = + withForeignRef ref $ \hval -> + iservCmd hsc_env (Seq hval) >>= fromEvalResult + -- ----------------------------------------------------------------------------- -- Interface to the object-code linker |