diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /libraries/ghci | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'libraries/ghci')
-rw-r--r-- | libraries/ghci/GHCi/BinaryArray.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/BreakArray.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/CreateBCO.hs | 7 | ||||
-rw-r--r-- | libraries/ghci/GHCi/FFI.hsc | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/InfoTable.hsc | 138 | ||||
-rw-r--r-- | libraries/ghci/GHCi/Message.hs | 100 | ||||
-rw-r--r-- | libraries/ghci/GHCi/ObjLink.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/RemoteTypes.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/ResolvedBCO.hs | 7 | ||||
-rw-r--r-- | libraries/ghci/GHCi/Run.hs | 15 | ||||
-rw-r--r-- | libraries/ghci/GHCi/Signals.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/StaticPtrTable.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/GHCi/TH.hs | 10 | ||||
-rw-r--r-- | libraries/ghci/GHCi/TH/Binary.hs | 19 | ||||
-rw-r--r-- | libraries/ghci/SizedSeq.hs | 1 | ||||
-rw-r--r-- | libraries/ghci/changelog.md | 4 | ||||
-rw-r--r-- | libraries/ghci/ghci.cabal.in | 10 |
17 files changed, 142 insertions, 176 deletions
diff --git a/libraries/ghci/GHCi/BinaryArray.hs b/libraries/ghci/GHCi/BinaryArray.hs index 9529744b33..5431d6aa96 100644 --- a/libraries/ghci/GHCi/BinaryArray.hs +++ b/libraries/ghci/GHCi/BinaryArray.hs @@ -5,6 +5,7 @@ -- module GHCi.BinaryArray(putArray, getArray) where +import Prelude import Foreign.Ptr import Data.Binary import Data.Binary.Put (putBuilder) diff --git a/libraries/ghci/GHCi/BreakArray.hs b/libraries/ghci/GHCi/BreakArray.hs index bece43bdb9..8d0e7495ba 100644 --- a/libraries/ghci/GHCi/BreakArray.hs +++ b/libraries/ghci/GHCi/BreakArray.hs @@ -30,6 +30,7 @@ module GHCi.BreakArray ) where #ifdef GHCI +import Prelude -- See note [Why do we import Prelude here?] import Control.Monad import Data.Word import GHC.Word diff --git a/libraries/ghci/GHCi/CreateBCO.hs b/libraries/ghci/GHCi/CreateBCO.hs index aae4b686fa..3ebcf0ea22 100644 --- a/libraries/ghci/GHCi/CreateBCO.hs +++ b/libraries/ghci/GHCi/CreateBCO.hs @@ -13,6 +13,7 @@ -- | Create real byte-code objects from 'ResolvedBCO's. module GHCi.CreateBCO (createBCOs) where +import Prelude -- See note [Why do we import Prelude here?] import GHCi.ResolvedBCO import GHCi.RemoteTypes import GHCi.BreakArray @@ -38,9 +39,9 @@ createBCOs bcos = do createBCO :: Array Int HValue -> ResolvedBCO -> IO HValue createBCO _ ResolvedBCO{..} | resolvedBCOIsLE /= isLittleEndian = throwIO (ErrorCall $ - unlines [ "The endianess of the ResolvedBCO does not match" - , "the systems endianess. Using ghc and iserv in a" - , "mixed endianess setup is not supported!" + unlines [ "The endianness of the ResolvedBCO does not match" + , "the systems endianness. Using ghc and iserv in a" + , "mixed endianness setup is not supported!" ]) createBCO arr bco = do BCO bco# <- linkBCO' arr bco diff --git a/libraries/ghci/GHCi/FFI.hsc b/libraries/ghci/GHCi/FFI.hsc index 7fd75bb8e4..f88e9e8bd8 100644 --- a/libraries/ghci/GHCi/FFI.hsc +++ b/libraries/ghci/GHCi/FFI.hsc @@ -17,6 +17,7 @@ module GHCi.FFI , freeForeignCallInfo ) where +import Prelude -- See note [Why do we import Prelude here?] import Control.Exception import Data.Binary import GHC.Generics diff --git a/libraries/ghci/GHCi/InfoTable.hsc b/libraries/ghci/GHCi/InfoTable.hsc index c553897b68..ec3c18ae06 100644 --- a/libraries/ghci/GHCi/InfoTable.hsc +++ b/libraries/ghci/GHCi/InfoTable.hsc @@ -1,78 +1,28 @@ {-# LANGUAGE CPP, MagicHash, ScopedTypeVariables #-} +-- Get definitions for the structs, constants & config etc. +#include "Rts.h" + -- | -- Run-time info table support. This module provides support for -- creating and reading info tables /in the running program/. -- We use the RTS data structures directly via hsc2hs. -- module GHCi.InfoTable - ( peekItbl, StgInfoTable(..) - , conInfoPtr + ( #ifdef GHCI - , mkConInfoTable + mkConInfoTable #endif ) where -#if !defined(TABLES_NEXT_TO_CODE) -import Data.Maybe (fromJust) -#endif +import Prelude -- See note [Why do we import Prelude here?] +#ifdef GHCI import Foreign -import Foreign.C -- needed for 2nd stage -import GHC.Ptr -- needed for 2nd stage -import GHC.Exts -- needed for 2nd stage -import System.IO.Unsafe -- needed for 2nd stage - -type ItblCodes = Either [Word8] [Word32] - --- Get definitions for the structs, constants & config etc. -#include "Rts.h" - --- Ultra-minimalist version specially for constructors -#if SIZEOF_VOID_P == 8 -type HalfWord = Word32 -#elif SIZEOF_VOID_P == 4 -type HalfWord = Word16 -#else -#error Unknown SIZEOF_VOID_P -#endif - -type EntryFunPtr = FunPtr (Ptr () -> IO (Ptr ())) - -data StgInfoTable = StgInfoTable { - entry :: Maybe EntryFunPtr, -- Just <=> not ghciTablesNextToCode - ptrs :: HalfWord, - nptrs :: HalfWord, - tipe :: HalfWord, - srtlen :: HalfWord, - code :: Maybe ItblCodes -- Just <=> ghciTablesNextToCode - } - -peekItbl :: Ptr StgInfoTable -> IO StgInfoTable -peekItbl a0 = do -#if defined(TABLES_NEXT_TO_CODE) - let entry' = Nothing -#else - entry' <- Just <$> (#peek StgInfoTable, entry) a0 +import Foreign.C +import GHC.Ptr +import GHC.Exts +import GHC.Exts.Heap #endif - ptrs' <- (#peek StgInfoTable, layout.payload.ptrs) a0 - nptrs' <- (#peek StgInfoTable, layout.payload.nptrs) a0 - tipe' <- (#peek StgInfoTable, type) a0 - srtlen' <- (#peek StgInfoTable, srt_bitmap) a0 - return StgInfoTable - { entry = entry' - , ptrs = ptrs' - , nptrs = nptrs' - , tipe = tipe' - , srtlen = srtlen' - , code = Nothing - } - --- | Convert a pointer to an StgConInfo into an info pointer that can be --- used in the header of a closure. -conInfoPtr :: Ptr () -> Ptr () -conInfoPtr ptr - | ghciTablesNextToCode = ptr `plusPtr` (#size StgConInfoTable) - | otherwise = ptr ghciTablesNextToCode :: Bool #ifdef TABLES_NEXT_TO_CODE @@ -82,6 +32,9 @@ ghciTablesNextToCode = False #endif #ifdef GHCI /* To end */ +-- NOTE: Must return a pointer acceptable for use in the header of a closure. +-- If tables_next_to_code is enabled, then it must point the the 'code' field. +-- Otherwise, it should point to the start of the StgInfoTable. mkConInfoTable :: Int -- ptr words -> Int -- non-ptr words @@ -103,7 +56,7 @@ mkConInfoTable ptr_words nonptr_words tag ptrtag con_desc = else Just entry_addr, ptrs = fromIntegral ptr_words, nptrs = fromIntegral nonptr_words, - tipe = fromIntegral cONSTR, + tipe = CONSTR, srtlen = fromIntegral tag, code = if ghciTablesNextToCode then Just code' @@ -368,12 +321,17 @@ data StgConInfoTable = StgConInfoTable { pokeConItbl :: Ptr StgConInfoTable -> Ptr StgConInfoTable -> StgConInfoTable -> IO () -pokeConItbl wr_ptr ex_ptr itbl = do - let _con_desc = conDesc itbl `minusPtr` (ex_ptr `plusPtr` conInfoTableSizeB) +pokeConItbl wr_ptr _ex_ptr itbl = do #if defined(TABLES_NEXT_TO_CODE) - (#poke StgConInfoTable, con_desc) wr_ptr _con_desc + -- Write the offset to the con_desc from the end of the standard InfoTable + -- at the first byte. + let con_desc_offset = conDesc itbl `minusPtr` (_ex_ptr `plusPtr` conInfoTableSizeB) + (#poke StgConInfoTable, con_desc) wr_ptr con_desc_offset #else - (#poke StgConInfoTable, con_desc) wr_ptr (conDesc itbl) + -- Write the con_desc address after the end of the info table. + -- Use itblSize because CPP will not pick up PROFILING when calculating + -- the offset. + pokeByteOff wr_ptr itblSize (conDesc itbl) #endif pokeItbl (wr_ptr `plusPtr` (#offset StgConInfoTable, i)) (infoTable itbl) @@ -385,28 +343,14 @@ sizeOfEntryCode Left xs -> sizeOf (head xs) * length xs Right xs -> sizeOf (head xs) * length xs -pokeItbl :: Ptr StgInfoTable -> StgInfoTable -> IO () -pokeItbl a0 itbl = do -#if !defined(TABLES_NEXT_TO_CODE) - (#poke StgInfoTable, entry) a0 (fromJust (entry itbl)) -#endif - (#poke StgInfoTable, layout.payload.ptrs) a0 (ptrs itbl) - (#poke StgInfoTable, layout.payload.nptrs) a0 (nptrs itbl) - (#poke StgInfoTable, type) a0 (tipe itbl) - (#poke StgInfoTable, srt_bitmap) a0 (srtlen itbl) -#if defined(TABLES_NEXT_TO_CODE) - let code_offset = (a0 `plusPtr` (#offset StgInfoTable, code)) - case code itbl of - Nothing -> return () - Just (Left xs) -> pokeArray code_offset xs - Just (Right xs) -> pokeArray code_offset xs -#endif - +-- Note: Must return proper pointer for use in a closure newExecConItbl :: StgInfoTable -> [Word8] -> IO (FunPtr ()) newExecConItbl obj con_desc = alloca $ \pcode -> do let lcon_desc = length con_desc + 1{- null terminator -} - sz = fromIntegral ((#size StgConInfoTable) + sizeOfEntryCode) + -- SCARY + -- This size represents the number of bytes in an StgConInfoTable. + sz = fromIntegral (conInfoTableSizeB + sizeOfEntryCode) -- Note: we need to allocate the conDesc string next to the info -- table, because on a 64-bit platform we reference this string -- with a 32-bit offset relative to the info table, so if we @@ -418,7 +362,11 @@ newExecConItbl obj con_desc pokeConItbl wr_ptr ex_ptr cinfo pokeArray0 0 (castPtr wr_ptr `plusPtr` fromIntegral sz) con_desc _flushExec sz ex_ptr -- Cache flush (if needed) +#if defined(TABLES_NEXT_TO_CODE) + return (castPtrToFunPtr (ex_ptr `plusPtr` conInfoTableSizeB)) +#else return (castPtrToFunPtr ex_ptr) +#endif foreign import ccall unsafe "allocateExec" _allocateExec :: CUInt -> Ptr (Ptr a) -> IO (Ptr a) @@ -432,26 +380,6 @@ foreign import ccall unsafe "flushExec" wORD_SIZE :: Int wORD_SIZE = (#const SIZEOF_HSINT) -fixedInfoTableSizeB :: Int -fixedInfoTableSizeB = 2 * wORD_SIZE - -profInfoTableSizeB :: Int -profInfoTableSizeB = (#size StgProfInfo) - -stdInfoTableSizeB :: Int -stdInfoTableSizeB - = (if ghciTablesNextToCode then 0 else wORD_SIZE) - + (if rtsIsProfiled then profInfoTableSizeB else 0) - + fixedInfoTableSizeB - conInfoTableSizeB :: Int -conInfoTableSizeB = stdInfoTableSizeB + wORD_SIZE - -foreign import ccall unsafe "rts_isProfiled" rtsIsProfiledIO :: IO CInt - -rtsIsProfiled :: Bool -rtsIsProfiled = unsafeDupablePerformIO rtsIsProfiledIO /= 0 - -cONSTR :: Int -- Defined in ClosureTypes.h -cONSTR = (#const CONSTR) +conInfoTableSizeB = wORD_SIZE + itblSize #endif /* GHCI */ diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index 81de2fbd21..012dd884ba 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -1,6 +1,5 @@ {-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables, - GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, - CPP #-} + GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-} -- | @@ -23,13 +22,14 @@ module GHCi.Message , Pipe(..), remoteCall, remoteTHCall, readPipe, writePipe ) where +import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes -import GHCi.InfoTable (StgInfoTable) import GHCi.FFI import GHCi.TH.Binary () import GHCi.BreakArray import GHC.LanguageExtensions +import GHC.Exts.Heap import GHC.ForeignSrcLang import GHC.Fingerprint import Control.Concurrent @@ -41,18 +41,12 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as LB import Data.Dynamic -#if MIN_VERSION_base(4,10,0) --- Previously this was re-exported by Data.Dynamic import Data.Typeable (TypeRep) -#endif import Data.IORef import Data.Map (Map) +import Foreign import GHC.Generics -#if MIN_VERSION_base(4,9,0) import GHC.Stack.CCS -#else -import GHC.Stack as GHC.Stack.CCS -#endif import qualified Language.Haskell.TH as TH import qualified Language.Haskell.TH.Syntax as TH import System.Exit @@ -210,6 +204,18 @@ data Message a where -> [RemoteRef (TH.Q ())] -> Message (QResult ()) + -- | Remote interface to GHC.Exts.Heap.getClosureData. This is used by + -- the GHCi debugger to inspect values in the heap for :print and + -- type reconstruction. + GetClosure + :: HValueRef + -> Message (GenClosure HValueRef) + + -- | Evaluate something. This is used to support :force in GHCi. + Seq + :: HValueRef + -> Message (EvalResult ()) + deriving instance Show (Message a) @@ -243,9 +249,11 @@ data THMessage a where ReifyConStrictness :: TH.Name -> THMessage (THResult [TH.DecidedStrictness]) AddDependentFile :: FilePath -> THMessage (THResult ()) + AddTempFile :: String -> THMessage (THResult FilePath) AddModFinalizer :: RemoteRef (TH.Q ()) -> THMessage (THResult ()) + AddCorePlugin :: String -> THMessage (THResult ()) AddTopDecls :: [TH.Dec] -> THMessage (THResult ()) - AddForeignFile :: ForeignSrcLang -> String -> THMessage (THResult ()) + AddForeignFilePath :: ForeignSrcLang -> FilePath -> THMessage (THResult ()) IsExtEnabled :: Extension -> THMessage (THResult Bool) ExtsEnabled :: THMessage (THResult [Extension]) @@ -275,14 +283,16 @@ getTHMessage = do 8 -> THMsg <$> ReifyModule <$> get 9 -> THMsg <$> ReifyConStrictness <$> get 10 -> THMsg <$> AddDependentFile <$> get - 11 -> THMsg <$> AddTopDecls <$> get - 12 -> THMsg <$> (IsExtEnabled <$> get) - 13 -> THMsg <$> return ExtsEnabled - 14 -> THMsg <$> return StartRecover - 15 -> THMsg <$> EndRecover <$> get - 16 -> return (THMsg RunTHDone) - 17 -> THMsg <$> AddModFinalizer <$> get - _ -> THMsg <$> (AddForeignFile <$> get <*> get) + 11 -> THMsg <$> AddTempFile <$> get + 12 -> THMsg <$> AddTopDecls <$> get + 13 -> THMsg <$> (IsExtEnabled <$> get) + 14 -> THMsg <$> return ExtsEnabled + 15 -> THMsg <$> return StartRecover + 16 -> THMsg <$> EndRecover <$> get + 17 -> return (THMsg RunTHDone) + 18 -> THMsg <$> AddModFinalizer <$> get + 19 -> THMsg <$> (AddForeignFilePath <$> get <*> get) + _ -> THMsg <$> AddCorePlugin <$> get putTHMessage :: THMessage a -> Put putTHMessage m = case m of @@ -297,14 +307,16 @@ putTHMessage m = case m of ReifyModule a -> putWord8 8 >> put a ReifyConStrictness a -> putWord8 9 >> put a AddDependentFile a -> putWord8 10 >> put a - AddTopDecls a -> putWord8 11 >> put a - IsExtEnabled a -> putWord8 12 >> put a - ExtsEnabled -> putWord8 13 - StartRecover -> putWord8 14 - EndRecover a -> putWord8 15 >> put a - RunTHDone -> putWord8 16 - AddModFinalizer a -> putWord8 17 >> put a - AddForeignFile lang a -> putWord8 18 >> put lang >> put a + AddTempFile a -> putWord8 11 >> put a + AddTopDecls a -> putWord8 12 >> put a + IsExtEnabled a -> putWord8 13 >> put a + ExtsEnabled -> putWord8 14 + StartRecover -> putWord8 15 + EndRecover a -> putWord8 16 >> put a + RunTHDone -> putWord8 17 + AddModFinalizer a -> putWord8 18 >> put a + AddForeignFilePath lang a -> putWord8 19 >> put lang >> put a + AddCorePlugin a -> putWord8 20 >> put a data EvalOpts = EvalOpts @@ -384,17 +396,7 @@ fromSerializableException EUserInterrupt = toException UserInterrupt fromSerializableException (EExitCode c) = toException c fromSerializableException (EOtherException str) = toException (ErrorCall str) --- NB: Replace this with a derived instance once we depend on GHC 8.0 --- as the minimum -instance Binary ExitCode where - put ExitSuccess = putWord8 0 - put (ExitFailure ec) = putWord8 1 >> put ec - get = do - w <- getWord8 - case w of - 0 -> pure ExitSuccess - _ -> ExitFailure <$> get - +instance Binary ExitCode instance Binary SerializableException data THResult a @@ -422,6 +424,22 @@ data QState = QState } instance Show QState where show _ = "<QState>" +-- Orphan instances of Binary for Ptr / FunPtr by conversion to Word64. +-- This is to support Binary StgInfoTable which includes these. +instance Binary (Ptr a) where + put p = put (fromIntegral (ptrToWordPtr p) :: Word64) + get = (wordPtrToPtr . fromIntegral) <$> (get :: Get Word64) + +instance Binary (FunPtr a) where + put = put . castFunPtrToPtr + get = castPtrToFunPtr <$> get + +-- Binary instances to support the GetClosure message +instance Binary StgInfoTable +instance Binary ClosureType +instance Binary PrimType +instance Binary a => Binary (GenClosure a) + data Msg = forall a . (Binary a, Show a) => Msg (Message a) getMessage :: Get Msg @@ -462,7 +480,9 @@ getMessage = do 31 -> Msg <$> return StartTH 32 -> Msg <$> (RunModFinalizers <$> get <*> get) 33 -> Msg <$> (AddSptEntry <$> get <*> get) - _ -> Msg <$> (RunTH <$> get <*> get <*> get <*> get) + 34 -> Msg <$> (RunTH <$> get <*> get <*> get <*> get) + 35 -> Msg <$> (GetClosure <$> get) + _ -> Msg <$> (Seq <$> get) putMessage :: Message a -> Put putMessage m = case m of @@ -501,6 +521,8 @@ putMessage m = case m of RunModFinalizers a b -> putWord8 32 >> put a >> put b AddSptEntry a b -> putWord8 33 >> put a >> put b RunTH st q loc ty -> putWord8 34 >> put st >> put q >> put loc >> put ty + GetClosure a -> putWord8 35 >> put a + Seq a -> putWord8 36 >> put a -- ----------------------------------------------------------------------------- -- Reading/writing messages diff --git a/libraries/ghci/GHCi/ObjLink.hs b/libraries/ghci/GHCi/ObjLink.hs index 0d7b2aeff8..8c9f75b9f9 100644 --- a/libraries/ghci/GHCi/ObjLink.hs +++ b/libraries/ghci/GHCi/ObjLink.hs @@ -25,6 +25,7 @@ module GHCi.ObjLink , findSystemLibrary ) where +import Prelude -- See note [Why do we import Prelude here?] import GHCi.RemoteTypes import Control.Exception (throwIO, ErrorCall(..)) import Control.Monad ( when ) diff --git a/libraries/ghci/GHCi/RemoteTypes.hs b/libraries/ghci/GHCi/RemoteTypes.hs index 12ae529b16..c024ae9fff 100644 --- a/libraries/ghci/GHCi/RemoteTypes.hs +++ b/libraries/ghci/GHCi/RemoteTypes.hs @@ -17,6 +17,7 @@ module GHCi.RemoteTypes , unsafeForeignRefToRemoteRef, finalizeForeignRef ) where +import Prelude -- See note [Why do we import Prelude here?] import Control.DeepSeq import Data.Word import Foreign hiding (newForeignPtr) diff --git a/libraries/ghci/GHCi/ResolvedBCO.hs b/libraries/ghci/GHCi/ResolvedBCO.hs index 37836a4e62..5942d37b10 100644 --- a/libraries/ghci/GHCi/ResolvedBCO.hs +++ b/libraries/ghci/GHCi/ResolvedBCO.hs @@ -6,6 +6,7 @@ module GHCi.ResolvedBCO , isLittleEndian ) where +import Prelude -- See note [Why do we import Prelude here?] import SizedSeq import GHCi.RemoteTypes import GHCi.BreakArray @@ -46,9 +47,9 @@ data ResolvedBCO -- | The Binary instance for ResolvedBCOs. -- --- Note, that we do encode the endianess, however there is no support for mixed --- endianess setups. This is primarily to ensure that ghc and iserv share the --- same endianess. +-- Note, that we do encode the endianness, however there is no support for mixed +-- endianness setups. This is primarily to ensure that ghc and iserv share the +-- same endianness. instance Binary ResolvedBCO where put ResolvedBCO{..} = do put resolvedBCOIsLE diff --git a/libraries/ghci/GHCi/Run.hs b/libraries/ghci/GHCi/Run.hs index d05877579a..72099b205f 100644 --- a/libraries/ghci/GHCi/Run.hs +++ b/libraries/ghci/GHCi/Run.hs @@ -12,6 +12,7 @@ module GHCi.Run ( run, redirectInterrupts ) where +import Prelude -- See note [Why do we import Prelude here?] import GHCi.CreateBCO import GHCi.InfoTable import GHCi.FFI @@ -31,8 +32,9 @@ import Data.Binary.Get import Data.ByteString (ByteString) import qualified Data.ByteString.Unsafe as B import GHC.Exts +import GHC.Exts.Heap import GHC.Stack -import Foreign +import Foreign hiding (void) import Foreign.C import GHC.Conc.Sync import GHC.IO hiding ( bracket ) @@ -86,6 +88,10 @@ run m = case m of MkConInfoTable ptrs nptrs tag ptrtag desc -> toRemotePtr <$> mkConInfoTable ptrs nptrs tag ptrtag desc StartTH -> startTH + GetClosure ref -> do + clos <- getClosureData =<< localRef ref + mapM (\(Box x) -> mkRemoteRef (HValue x)) clos + Seq ref -> tryEval (void $ evaluate =<< localRef ref) _other -> error "GHCi.Run.run" evalStmt :: EvalOpts -> EvalExpr HValueRef -> IO (EvalStatus [HValueRef]) @@ -298,7 +304,12 @@ setStepFlag = poke stepFlag 1 resetStepFlag :: IO () resetStepFlag = poke stepFlag 0 -type BreakpointCallback = Int# -> Int# -> Bool -> HValue -> IO () +type BreakpointCallback + = Int# -- the breakpoint index + -> Int# -- the module uniq + -> Bool -- exception? + -> HValue -- the AP_STACK, or exception + -> IO () foreign import ccall "&rts_breakpoint_io_action" breakPointIOAction :: Ptr (StablePtr BreakpointCallback) diff --git a/libraries/ghci/GHCi/Signals.hs b/libraries/ghci/GHCi/Signals.hs index 629f116a0e..dc3b297dc5 100644 --- a/libraries/ghci/GHCi/Signals.hs +++ b/libraries/ghci/GHCi/Signals.hs @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} module GHCi.Signals (installSignalHandlers) where +import Prelude -- See note [Why do we import Prelude here?] import Control.Concurrent import Control.Exception import System.Mem.Weak ( deRefWeak ) diff --git a/libraries/ghci/GHCi/StaticPtrTable.hs b/libraries/ghci/GHCi/StaticPtrTable.hs index d23e810f8a..623e8ef307 100644 --- a/libraries/ghci/GHCi/StaticPtrTable.hs +++ b/libraries/ghci/GHCi/StaticPtrTable.hs @@ -3,6 +3,7 @@ module GHCi.StaticPtrTable ( sptAddEntry ) where +import Prelude -- See note [Why do we import Prelude here?] import Data.Word import Foreign import GHC.Fingerprint diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs index 1b08501580..5779b5073e 100644 --- a/libraries/ghci/GHCi/TH.hs +++ b/libraries/ghci/GHCi/TH.hs @@ -91,12 +91,14 @@ Other Notes on TH / Remote GHCi compiler/typecheck/TcSplice.hs -} +import Prelude -- See note [Why do we import Prelude here?] import GHCi.Message import GHCi.RemoteTypes import GHC.Serialized import Control.Exception import qualified Control.Monad.Fail as Fail +import Control.Monad.IO.Class (MonadIO (..)) import Data.Binary import Data.Binary.Put import Data.ByteString (ByteString) @@ -160,6 +162,9 @@ ghcCmd m = GHCiQ $ \s -> do THException str -> throwIO (GHCiQException s str) THComplete res -> return (res, s) +instance MonadIO GHCiQ where + liftIO m = GHCiQ $ \s -> fmap (,s) m + instance TH.Quasi GHCiQ where qNewName str = ghcCmd (NewName str) qReport isError msg = ghcCmd (Report isError msg) @@ -190,12 +195,13 @@ instance TH.Quasi GHCiQ where qReifyModule m = ghcCmd (ReifyModule m) qReifyConStrictness name = ghcCmd (ReifyConStrictness name) qLocation = fromMaybe noLoc . qsLocation <$> getState - qRunIO m = GHCiQ $ \s -> fmap (,s) m qAddDependentFile file = ghcCmd (AddDependentFile file) + qAddTempFile suffix = ghcCmd (AddTempFile suffix) qAddTopDecls decls = ghcCmd (AddTopDecls decls) - qAddForeignFile str lang = ghcCmd (AddForeignFile str lang) + qAddForeignFilePath lang fp = ghcCmd (AddForeignFilePath lang fp) qAddModFinalizer fin = GHCiQ (\s -> mkRemoteRef fin >>= return . (, s)) >>= ghcCmd . AddModFinalizer + qAddCorePlugin str = ghcCmd (AddCorePlugin str) qGetQ = GHCiQ $ \s -> let lookup :: forall a. Typeable a => Map TypeRep Dynamic -> Maybe a lookup m = fromDynamic =<< M.lookup (typeOf (undefined::a)) m diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index ae6bc9f9ce..22a2847660 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -1,5 +1,4 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -8,14 +7,12 @@ -- This module is full of orphans, unfortunately module GHCi.TH.Binary () where +import Prelude -- See note [Why do we import Prelude here?] import Data.Binary import qualified Data.ByteString as B import GHC.Serialized import qualified Language.Haskell.TH as TH import qualified Language.Haskell.TH.Syntax as TH -#if !MIN_VERSION_base(4,10,0) -import Data.Typeable -#endif -- Put these in a separate module because they take ages to compile instance Binary TH.Loc @@ -44,7 +41,6 @@ instance Binary TH.Body instance Binary TH.Match instance Binary TH.Fixity instance Binary TH.TySynEqn -instance Binary TH.FamFlavour instance Binary TH.FunDep instance Binary TH.AnnTarget instance Binary TH.RuleBndr @@ -76,16 +72,3 @@ instance Binary TH.PatSynArgs instance Binary Serialized where put (Serialized tyrep wds) = put tyrep >> put (B.pack wds) get = Serialized <$> get <*> (B.unpack <$> get) - --- Typeable and related instances live in binary since GHC 8.2 -#if !MIN_VERSION_base(4,10,0) -instance Binary TyCon where - put tc = put (tyConPackage tc) >> put (tyConModule tc) >> put (tyConName tc) - get = mkTyCon3 <$> get <*> get <*> get - -instance Binary TypeRep where - put type_rep = put (splitTyConApp type_rep) - get = do - (ty_con, child_type_reps) <- get - return (mkTyConApp ty_con child_type_reps) -#endif diff --git a/libraries/ghci/SizedSeq.hs b/libraries/ghci/SizedSeq.hs index 55433c2fbd..f83e14081f 100644 --- a/libraries/ghci/SizedSeq.hs +++ b/libraries/ghci/SizedSeq.hs @@ -8,6 +8,7 @@ module SizedSeq , sizeSS ) where +import Prelude -- See note [Why do we import Prelude here?] import Control.DeepSeq import Data.Binary import Data.List diff --git a/libraries/ghci/changelog.md b/libraries/ghci/changelog.md index 3775edaf30..9ced82961c 100644 --- a/libraries/ghci/changelog.md +++ b/libraries/ghci/changelog.md @@ -1,3 +1,7 @@ +## 8.2.2 Nov 2017 + + * Bundled with GHC 8.2.2 + ## 8.0.1 *Feb 2016* * Bundled with GHC 8.0.1 diff --git a/libraries/ghci/ghci.cabal.in b/libraries/ghci/ghci.cabal.in index da25507b08..f49acf5665 100644 --- a/libraries/ghci/ghci.cabal.in +++ b/libraries/ghci/ghci.cabal.in @@ -29,6 +29,7 @@ source-repository head library default-language: Haskell2010 + default-extensions: NoImplicitPrelude other-extensions: BangPatterns CPP @@ -69,16 +70,17 @@ library Build-Depends: array == 0.5.*, - base >= 4.8 && < 4.11, + base >= 4.8 && < 4.13, binary == 0.8.*, bytestring == 0.10.*, - containers == 0.5.*, + containers >= 0.5 && < 0.7, deepseq == 1.4.*, filepath == 1.4.*, ghc-boot == @ProjectVersionMunged@, ghc-boot-th == @ProjectVersionMunged@, - template-haskell == 2.12.*, + ghc-heap == @ProjectVersionMunged@, + template-haskell == 2.14.*, transformers == 0.5.* if !os(windows) - Build-Depends: unix == 2.7.* + Build-Depends: unix >= 2.7 && < 2.9 |