Rodrigo Mesquita pushed to branch wip/romes/multi-threaded-debugger at Glasgow Haskell Compiler / GHC
Commits:
-
94dd257d
by Rodrigo Mesquita at 2026-10-21T12:01:14+01:00
-
a64e1dbd
by Rodrigo Mesquita at 2026-10-21T14:42:21+01:00
-
e5af56d6
by Rodrigo Mesquita at 2026-10-21T14:56:07+01:00
-
6e60751b
by Rodrigo Mesquita at 2026-10-21T14:57:04+01:00
-
ad9b4a5b
by Rodrigo Mesquita at 2026-10-21T17:19:46+01:00
-
564c6478
by Rodrigo Mesquita at 2026-10-21T17:33:49+01:00
-
b72f637f
by Rodrigo Mesquita at 2026-10-21T17:35:27+01:00
-
d2f9d0c4
by Rodrigo Mesquita at 2026-10-21T17:36:45+01:00
-
1ea6bdc4
by Rodrigo Mesquita at 2026-10-21T17:37:52+01:00
-
5eb82a91
by Rodrigo Mesquita at 2026-10-21T17:50:26+01:00
-
978769c6
by Rodrigo Mesquita at 2026-10-21T18:00:13+01:00
-
61f3a6fa
by Rodrigo Mesquita at 2026-10-22T10:45:42+01:00
17 changed files:
- compiler/GHC/Runtime/Interpreter.hs
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc
- libraries/ghc-heap/tests/parse_tso_flags.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghci/GHCi/Debugger.hs
- libraries/ghci/GHCi/Run.hs
- libraries/ghci/GHCi/Signals.hs
- rts/Exception.cmm
- rts/Interpreter.c
- rts/RtsSymbols.c
- rts/include/rts/Constants.h
- testsuite/tests/ghc-api/T8628.hs
- testsuite/tests/ghc-api/T8639_api.hs
- testsuite/tests/ghc-api/apirecomp001/myghc.hs
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/ghci/should_run/all.T
Changes:
| ... | ... | @@ -494,11 +494,9 @@ lookupSymbol interp str = withSymbolCache interp str $ |
| 494 | 494 | #endif
|
| 495 | 495 | ExternalInterp ext -> case ext of
|
| 496 | 496 | ExtIServ i -> withIServ i $ \inst -> do
|
| 497 | - uninterruptibleMask_ $
|
|
| 498 | 497 | sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
|
| 499 | 498 | ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
|
| 500 | 499 | ExtWasm i -> withWasmInterp i $ \inst -> do
|
| 501 | - uninterruptibleMask_ $
|
|
| 502 | 500 | sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
|
| 503 | 501 | |
| 504 | 502 | lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> InterpSymbol s -> IO (Maybe (RemotePtr ()))
|
| ... | ... | @@ -509,8 +507,7 @@ lookupSymbolInDLL interp dll str = withSymbolCache interp str $ |
| 509 | 507 | #endif
|
| 510 | 508 | ExternalInterp ext -> case ext of
|
| 511 | 509 | ExtIServ i -> withIServ i $ \inst -> do
|
| 512 | - uninterruptibleMask_ $
|
|
| 513 | - sendMessage inst (LookupSymbolInDLL dll (fastStringToShortByteString (interpSymbolToCLabel str)))
|
|
| 510 | + sendMessage inst (LookupSymbolInDLL dll (fastStringToShortByteString (interpSymbolToCLabel str)))
|
|
| 514 | 511 | ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
|
| 515 | 512 | -- wasm dyld doesn't track which symbol comes from which .so
|
| 516 | 513 | ExtWasm {} -> lookupSymbol interp str
|
| ... | ... | @@ -93,6 +93,7 @@ parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset |
| 93 | 93 | #if __GLASGOW_HASKELL__ >= 913
|
| 94 | 94 | | isSet (#const TSO_STOP_NEXT_BREAKPOINT) w = TsoStopNextBreakpoint : parseTsoFlags (unset (#const TSO_STOP_NEXT_BREAKPOINT) w)
|
| 95 | 95 | | isSet (#const TSO_STOP_AFTER_RETURN) w = TsoStopAfterReturn : parseTsoFlags (unset (#const TSO_STOP_AFTER_RETURN) w)
|
| 96 | + | isSet (#const TSO_STOP_ON_EXCEPTION) w = TsoStopOnException : parseTsoFlags (unset (#const TSO_STOP_ON_EXCEPTION) w)
|
|
| 96 | 97 | #endif
|
| 97 | 98 | parseTsoFlags 0 = []
|
| 98 | 99 | parseTsoFlags w = [TsoFlagsUnknownValue w]
|
| ... | ... | @@ -93,6 +93,7 @@ parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset |
| 93 | 93 | #if __GLASGOW_HASKELL__ >= 913
|
| 94 | 94 | | isSet (#const TSO_STOP_NEXT_BREAKPOINT) w = TsoStopNextBreakpoint : parseTsoFlags (unset (#const TSO_STOP_NEXT_BREAKPOINT) w)
|
| 95 | 95 | | isSet (#const TSO_STOP_AFTER_RETURN) w = TsoStopAfterReturn : parseTsoFlags (unset (#const TSO_STOP_AFTER_RETURN) w)
|
| 96 | + | isSet (#const TSO_STOP_ON_EXCEPTION) w = TsoStopOnException : parseTsoFlags (unset (#const TSO_STOP_ON_EXCEPTION) w)
|
|
| 96 | 97 | #endif
|
| 97 | 98 | parseTsoFlags 0 = []
|
| 98 | 99 | parseTsoFlags w = [TsoFlagsUnknownValue w]
|
| ... | ... | @@ -15,5 +15,6 @@ main = do |
| 15 | 15 | assertEqual (parseTsoFlags 256) [TsoAllocLimit]
|
| 16 | 16 | assertEqual (parseTsoFlags 512) [TsoStopNextBreakpoint]
|
| 17 | 17 | assertEqual (parseTsoFlags 1024) [TsoStopAfterReturn]
|
| 18 | + assertEqual (parseTsoFlags 2048) [TsoStopOnException]
|
|
| 18 | 19 | |
| 19 | 20 | assertEqual (parseTsoFlags 6) [TsoLocked, TsoBlockx] |
| ... | ... | @@ -632,6 +632,7 @@ data TsoFlags |
| 632 | 632 | | TsoAllocLimit
|
| 633 | 633 | | TsoStopNextBreakpoint
|
| 634 | 634 | | TsoStopAfterReturn
|
| 635 | + | TsoStopOnException
|
|
| 635 | 636 | | TsoFlagsUnknownValue Word32 -- ^ Please report this as a bug
|
| 636 | 637 | deriving (Eq, Show, Generic, Ord)
|
| 637 | 638 |
| ... | ... | @@ -13,7 +13,10 @@ module GHCi.Debugger |
| 13 | 13 | , rts_disableStopAfterReturn
|
| 14 | 14 | |
| 15 | 15 | -- * Stop on exception
|
| 16 | - , exceptionFlag
|
|
| 16 | + , rts_enableStopOnException
|
|
| 17 | + , rts_disableStopOnException
|
|
| 18 | + , rts_enableStopOnExceptionAll
|
|
| 19 | + , rts_disableStopOnExceptionAll
|
|
| 17 | 20 | |
| 18 | 21 | -- * Breakpoint Callback
|
| 19 | 22 | , BreakpointCallback
|
| ... | ... | @@ -23,7 +26,6 @@ module GHCi.Debugger |
| 23 | 26 | import Prelude -- See note [Why do we import Prelude here?]
|
| 24 | 27 | |
| 25 | 28 | import GHC.Base (ThreadId#, Addr#, Int#)
|
| 26 | -import Foreign.C (CInt)
|
|
| 27 | 29 | import Foreign (StablePtr, Ptr)
|
| 28 | 30 | import GHCi.RemoteTypes (HValue)
|
| 29 | 31 | |
| ... | ... | @@ -60,7 +62,19 @@ foreign import ccall unsafe "rts_disableStopAfterReturn" |
| 60 | 62 | |
| 61 | 63 | --------------------------------------------------------------------------------
|
| 62 | 64 | |
| 63 | -foreign import ccall "&rts_stop_on_exception" exceptionFlag :: Ptr CInt
|
|
| 65 | +-- | Make this thread break when an exception is hit
|
|
| 66 | +foreign import ccall unsafe "rts_enableStopOnException" rts_enableStopOnException :: ThreadId# -> IO ()
|
|
| 67 | + |
|
| 68 | +-- | No longer have this thread break when an exception is hit
|
|
| 69 | +foreign import ccall unsafe "rts_disableStopOnException" rts_disableStopOnException :: ThreadId# -> IO ()
|
|
| 70 | + |
|
| 71 | +-- | Enables global break-on-exception for all threads
|
|
| 72 | +foreign import ccall unsafe "rts_enableStopOnExceptionAll" rts_enableStopOnExceptionAll :: IO ()
|
|
| 73 | + |
|
| 74 | +-- | Disables the global break-on-exception for all threads. Individual threads
|
|
| 75 | +-- with break-on-exception will still break on exception if the global flag is
|
|
| 76 | +-- disabled.
|
|
| 77 | +foreign import ccall unsafe "rts_disableStopOnExceptionAll" rts_disableStopOnExceptionAll :: IO ()
|
|
| 64 | 78 | |
| 65 | 79 | --------------------------------------------------------------------------------
|
| 66 | 80 |
| ... | ... | @@ -338,9 +338,12 @@ sandboxIO opts io |
| 338 | 338 | -- A solution would be to have an "initialize interpreter" command
|
| 339 | 339 | -- which sets this at the start. A different solution is to have a
|
| 340 | 340 | -- global lock and only write this once here, then lock.
|
| 341 | + --
|
|
| 341 | 342 | poke breakPointIOAction globalBreakStablePtr
|
| 343 | + -- freeStablePtr stablePtr TODO: we never free the global stablePtr for
|
|
| 344 | + -- global action. Maybe we should have a de-init for clean up.
|
|
| 342 | 345 | |
| 343 | - tid <- forkIO $ do
|
|
| 346 | + tid <- mask_ $ forkIOWithUnmask $ \unmask -> do
|
|
| 344 | 347 | |
| 345 | 348 | takeMVar wait -- don't run anything in this thread before
|
| 346 | 349 | -- `setBreakAction` has a chance to set up.
|
| ... | ... | @@ -351,7 +354,7 @@ sandboxIO opts io |
| 351 | 354 | -- We only write the thread status map in two places:
|
| 352 | 355 | -- * When the "main" thread finishes (here)
|
| 353 | 356 | -- * When any thread hits a breakpoint (global break action)
|
| 354 | - runIt >>= writeThreadEvalStatus tid
|
|
| 357 | + unmask runIt >>= writeThreadEvalStatus tid
|
|
| 355 | 358 | |
| 356 | 359 | setBreakAction opts tid
|
| 357 | 360 | putMVar wait ()
|
| ... | ... | @@ -393,14 +396,15 @@ sandboxIO opts io |
| 393 | 396 | catchNoPropagate io $ \(ExceptionWithContext cx se) -> do
|
| 394 | 397 | -- If -fbreak-on-error, we break unconditionally,
|
| 395 | 398 | -- but with care of not breaking twice
|
| 399 | + ThreadId mytid <- myThreadId
|
|
| 396 | 400 | if breakOnError && not breakOnException
|
| 397 | - then poke exceptionFlag 1
|
|
| 401 | + then rts_enableStopOnException mytid
|
|
| 398 | 402 | else case fromException se of
|
| 399 | 403 | -- If it is a "UserInterrupt" exception, we allow
|
| 400 | 404 | -- a possible break by way of -fbreak-on-exception
|
| 401 | 405 | Just UserInterrupt -> return ()
|
| 402 | 406 | -- In any other case, we don't want to break
|
| 403 | - _ -> poke exceptionFlag 0
|
|
| 407 | + _ -> rts_disableStopOnException mytid
|
|
| 404 | 408 | rethrowIO (ExceptionWithContext cx se)
|
| 405 | 409 | |
| 406 | 410 | measureAlloc :: IO (EvalResult a) -> IO (EvalStatus a)
|
| ... | ... | @@ -420,25 +424,18 @@ setBreakAction opts tid@(ThreadId tid#) = do |
| 420 | 424 | setBreakAction' ctx
|
| 421 | 425 | where
|
| 422 | 426 | setBreakAction' ctx = do
|
| 423 | - -- TODO: TERRIBLY NOT MULTI-THREAD FRIENDLY. Each thread needs its own RTS flag exceptionFlag, like we have for step-in or step-out.
|
|
| 424 | - runIf breakOnException $ \_ -> poke exceptionFlag 1
|
|
| 425 | - -- Breaking on exceptions is not enabled by default, since it
|
|
| 426 | - -- might be a bit surprising. The exception flag is turned off
|
|
| 427 | - -- as soon as it is hit, or in resetBreakAction below.
|
|
| 428 | 427 | |
| 429 | 428 | runIf# singleStep rts_enableStopNextBreakpoint
|
| 430 | 429 | runIf# stepOut rts_enableStopAfterReturn
|
| 431 | 430 | |
| 431 | + -- Breaking on exceptions is not enabled by default, since it might be a
|
|
| 432 | + -- bit surprising. The exception flag is turned off as soon as it is hit.
|
|
| 433 | + runIf# breakOnException rts_enableStopOnException
|
|
| 434 | + |
|
| 432 | 435 | if isolateThreadBreaks opts
|
| 433 | 436 | then setIsolatedCtx ctx
|
| 434 | 437 | else unsetIsolatedCtx ctx
|
| 435 | 438 | |
| 436 | - -- freeStablePtr stablePtr TODO: we never free the global stablePtr for
|
|
| 437 | - -- global action. Maybe we should have a de-init for clean up.
|
|
| 438 | - -- TODO: don't set it in `setBreakAction` either. Should be on
|
|
| 439 | - -- interpreter initialization.
|
|
| 440 | - |
|
| 441 | - runIf pred what = when (pred opts) (what tid)
|
|
| 442 | 439 | runIf# pred what = when (pred opts) (what tid#)
|
| 443 | 440 | |
| 444 | 441 | -- While we're waiting for the sandbox thread to return a result, if
|
| ... | ... | @@ -17,9 +17,7 @@ import GHC.ConsoleHandler |
| 17 | 17 | #endif
|
| 18 | 18 | |
| 19 | 19 | -- | Install standard signal handlers for catching ^C, which just throw an
|
| 20 | --- exception in the target thread. The current target thread is the
|
|
| 21 | --- thread at the head of the list in the MVar passed to
|
|
| 22 | --- installSignalHandlers.
|
|
| 20 | +-- exception in the target thread.
|
|
| 23 | 21 | #if defined(wasm32_HOST_ARCH)
|
| 24 | 22 | installSignalHandlers :: (JSVal -> IO ()) -> IO ()
|
| 25 | 23 | installSignalHandlers cb_sig = do
|
| ... | ... | @@ -62,9 +60,7 @@ installSignalHandlers = do |
| 62 | 60 | --
|
| 63 | 61 | -- For native ghc with -fexternal-interpreter, when you press ^C,
|
| 64 | 62 | -- SIGINT is delivered to both ghc/iserv. iserv SIGINT handler raises
|
| 65 | --- an async UserInterrupt exception in the main thread, which might
|
|
| 66 | --- handle it right away, or later since it's doing I/O under
|
|
| 63 | +-- an async UserInterrupt exception in the main thread
|
|
| 67 | 64 | --
|
| 68 | 65 | -- wasm is no different here. The node process needs to catch the same
|
| 69 | 66 | -- signals. Instead of calling process.on('SIGINT', handler) in
|
| ... | ... | @@ -523,14 +523,16 @@ retry_pop_stack: |
| 523 | 523 | if (W_[no_break_on_exception] != 0) {
|
| 524 | 524 | W_[no_break_on_exception] = 0;
|
| 525 | 525 | } else {
|
| 526 | - if (TO_W_(CInt[rts_stop_on_exception]) != 0) {
|
|
| 526 | + if (TO_W_(CInt[rts_stop_on_exception]) != 0 ||
|
|
| 527 | + (TO_W_(StgTSO_flags(CurrentTSO)) & TSO_STOP_ON_EXCEPTION) != 0) {
|
|
| 527 | 528 | W_ ioAction;
|
| 528 | 529 | // we don't want any further exceptions to be caught,
|
| 529 | 530 | // until GHCi is ready to handle them. This prevents
|
| 530 | 531 | // deadlock if an exception is raised in InteractiveUI,
|
| 531 | - // for example. Perhaps the stop_on_exception flag should
|
|
| 532 | - // be per-thread.
|
|
| 532 | + // for example.
|
|
| 533 | 533 | CInt[rts_stop_on_exception] = 0;
|
| 534 | + StgTSO_flags(CurrentTSO) = %lobits32(
|
|
| 535 | + TO_W_(StgTSO_flags(CurrentTSO)) & ~TSO_STOP_ON_EXCEPTION);
|
|
| 534 | 536 | ("ptr" ioAction) = ccall deRefStablePtr (W_[rts_breakpoint_io_action] "ptr");
|
| 535 | 537 | Sp = Sp - WDS(11);
|
| 536 | 538 | Sp(10) = exception;
|
| ... | ... | @@ -388,8 +388,6 @@ is_ret_bco_frame(const StgPtr frame_head) { |
| 388 | 388 | );
|
| 389 | 389 | }
|
| 390 | 390 | |
| 391 | -int rts_stop_on_exception = 0;
|
|
| 392 | - |
|
| 393 | 391 | /* ---------------------------------------------------------------------------
|
| 394 | 392 | * Enabling and disabling global single step mode
|
| 395 | 393 | * ------------------------------------------------------------------------ */
|
| ... | ... | @@ -473,7 +471,40 @@ A limitation of this approach is that stepping-out of a function that was |
| 473 | 471 | tail-called will skip its caller since no stack frame is pushed for a tail
|
| 474 | 472 | call (i.e. a tail call returns directly to its caller's first non-tail caller).
|
| 475 | 473 | */
|
| 476 | -/* -------------------------------------------------------------------------- */
|
|
| 474 | + |
|
| 475 | +/* ---------------------------------------------------------------------------
|
|
| 476 | + * Enabling and disabling global break-on-exception
|
|
| 477 | + * ------------------------------------------------------------------------ */
|
|
| 478 | + |
|
| 479 | +int rts_stop_on_exception = 0;
|
|
| 480 | + |
|
| 481 | +void rts_enableStopOnExceptionAll(void)
|
|
| 482 | +{
|
|
| 483 | + rts_stop_on_exception = 1;
|
|
| 484 | +}
|
|
| 485 | + |
|
| 486 | +void rts_disableStopOnExceptionAll(void)
|
|
| 487 | +{
|
|
| 488 | + rts_stop_on_exception = 0;
|
|
| 489 | +}
|
|
| 490 | + |
|
| 491 | +/* ---------------------------------------------------------------------------
|
|
| 492 | + * Enabling and disabling per-thread break-on-exception
|
|
| 493 | + * ------------------------------------------------------------------------ */
|
|
| 494 | + |
|
| 495 | +void rts_enableStopOnException(StgTSO* tso)
|
|
| 496 | +{
|
|
| 497 | + Capability* cap = rts_unsafeGetMyCapability();
|
|
| 498 | + setThreadFlag(cap, tso, TSO_STOP_ON_EXCEPTION);
|
|
| 499 | +}
|
|
| 500 | + |
|
| 501 | +void rts_disableStopOnException(StgTSO* tso)
|
|
| 502 | +{
|
|
| 503 | + Capability* cap = rts_unsafeGetMyCapability();
|
|
| 504 | + unsetThreadFlag(cap, tso, TSO_STOP_ON_EXCEPTION);
|
|
| 505 | +}
|
|
| 506 | + |
|
| 507 | +/* ------------------------------------------------------------------------ */
|
|
| 477 | 508 | |
| 478 | 509 | #if defined(INTERP_STATS)
|
| 479 | 510 |
| ... | ... | @@ -944,6 +944,10 @@ extern char **environ; |
| 944 | 944 | SymI_NeedsProto(rts_disableStopNextBreakpoint) \
|
| 945 | 945 | SymI_NeedsProto(rts_enableStopAfterReturn) \
|
| 946 | 946 | SymI_NeedsProto(rts_disableStopAfterReturn) \
|
| 947 | + SymI_NeedsProto(rts_enableStopOnException) \
|
|
| 948 | + SymI_NeedsProto(rts_disableStopOnException) \
|
|
| 949 | + SymI_NeedsProto(rts_enableStopOnExceptionAll) \
|
|
| 950 | + SymI_NeedsProto(rts_disableStopOnExceptionAll) \
|
|
| 947 | 951 | SymI_HasProto(stopTimer) \
|
| 948 | 952 | SymI_HasDataProto(n_capabilities) \
|
| 949 | 953 | SymI_HasDataProto(max_n_capabilities) \
|
| ... | ... | @@ -394,6 +394,11 @@ |
| 394 | 394 | */
|
| 395 | 395 | #define TSO_STOP_AFTER_RETURN 1024
|
| 396 | 396 | |
| 397 | +/*
|
|
| 398 | + * Enables break-on-exception mode for this thread
|
|
| 399 | + */
|
|
| 400 | +#define TSO_STOP_ON_EXCEPTION 2048
|
|
| 401 | + |
|
| 397 | 402 | /*
|
| 398 | 403 | * The number of times we spin in a spin lock before yielding (see
|
| 399 | 404 | * #3758). To tune this value, use the benchmark in #3758: run the
|
| 1 | 1 | module Main where
|
| 2 | 2 | |
| 3 | +import Control.Monad (join)
|
|
| 3 | 4 | import System.IO
|
| 4 | 5 | import GHC.Driver.Session
|
| 5 | 6 | import GHC
|
| ... | ... | @@ -25,10 +26,10 @@ main |
| 25 | 26 | setContext [ IIDecl (simpleImportDecl pRELUDE_NAME)
|
| 26 | 27 | , IIDecl (simpleImportDecl (mkModuleNameFS (fsLit "System.IO")))]
|
| 27 | 28 | runDecls "data X = Y ()"
|
| 28 | - execStmt "print True" execOptions
|
|
| 29 | - MC.try $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeException ExecResult)
|
|
| 29 | + join $ execStmt "print True" execOptions
|
|
| 30 | + MC.try $ join $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeException ExecResult)
|
|
| 30 | 31 | runDecls "data X = Y () deriving Show"
|
| 31 | 32 | _ <- dynCompileExpr "'x'"
|
| 32 | - execStmt "print (Y ())" execOptions
|
|
| 33 | - execStmt "System.IO.hFlush System.IO.stdout" execOptions
|
|
| 33 | + join $ execStmt "print (Y ())" execOptions
|
|
| 34 | + join $ execStmt "System.IO.hFlush System.IO.stdout" execOptions
|
|
| 34 | 35 | print "done" |
| 1 | 1 | module Main where
|
| 2 | 2 | |
| 3 | +import Control.Monad (join)
|
|
| 3 | 4 | import GHC
|
| 4 | 5 | import GHC.Driver.Monad
|
| 5 | 6 | import GHC.Driver.Ppr
|
| ... | ... | @@ -20,8 +21,8 @@ main |
| 20 | 21 | |
| 21 | 22 | -- With the next line, you get an "Not in scope" exception.
|
| 22 | 23 | -- If you comment out this runStmt, it runs without error and prints the type.
|
| 23 | - execStmt "putStrLn (show 3)" execOptions
|
|
| 24 | - execStmt "hFlush stdout" execOptions
|
|
| 24 | + join $ execStmt "putStrLn (show 3)" execOptions
|
|
| 25 | + join $ execStmt "hFlush stdout" execOptions
|
|
| 25 | 26 | |
| 26 | 27 | ty <- exprType TM_Inst "T8639_api_a.it"
|
| 27 | 28 | liftIO (putStrLn (showPpr flags ty))
|
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | -- argument.
|
| 10 | 10 | module Main where
|
| 11 | 11 | |
| 12 | +import Control.Monad (join)
|
|
| 12 | 13 | import GHC
|
| 13 | 14 | import GHC.Driver.Session
|
| 14 | 15 | import GHC.Driver.Backend
|
| ... | ... | @@ -50,7 +51,7 @@ main = do |
| 50 | 51 | setContext [IIModule mod]
|
| 51 | 52 | liftIO $ hFlush stdout -- make sure things above are printed before
|
| 52 | 53 | -- interactive output
|
| 53 | - r <- execStmt "main" execOptions
|
|
| 54 | + r <- join $ execStmt "main" execOptions
|
|
| 54 | 55 | case r of
|
| 55 | 56 | ExecComplete { execResult = Right _ } -> prn "ok"
|
| 56 | 57 | ExecComplete { execResult = Left _ } -> prn "exception"
|
| ... | ... | @@ -3,10 +3,15 @@ include $(TOP)/mk/boilerplate.mk |
| 3 | 3 | include $(TOP)/mk/test.mk
|
| 4 | 4 | |
| 5 | 5 | # Test that threadDelay can be interrupted by ^C.
|
| 6 | -T3171:
|
|
| 7 | - echo "do Control.Concurrent.threadDelay 3000000; putStrLn \"threadDelay was not interrupted\"" | \
|
|
| 8 | - "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) & \
|
|
| 9 | - sleep 2; kill -INT $$!; wait
|
|
| 6 | +# Wait for the statement to start before interrupting (#15383), and signal
|
|
| 7 | +# the external interpreter too (the `pgrep -P $!`), as ^C in a terminal would.
|
|
| 8 | +T3171ext: T3171_OPTS = -fexternal-interpreter
|
|
| 9 | +T3171 T3171ext:
|
|
| 10 | + rm -f $@.started
|
|
| 11 | + echo 'do { writeFile "$@.started" ""; Control.Concurrent.threadDelay 100000000; putStrLn "threadDelay was not interrupted" }' | \
|
|
| 12 | + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(T3171_OPTS) & \
|
|
| 13 | + while [ ! -e $@.started ] && kill -0 $$! 2>/dev/null; do sleep 0.1; done; \
|
|
| 14 | + kill -INT $$! $$(pgrep -P $$!); wait
|
|
| 10 | 15 | |
| 11 | 16 | TopEnvIface:
|
| 12 | 17 | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) TopEnvIface -v1 -fno-hide-source-paths -e "a" -e ":q" -fwrite-if-simplified-core -fwrite-interface
|
| ... | ... | @@ -12,11 +12,17 @@ test('T27287', [just_ghci, combined_output], makefile_test, []) |
| 12 | 12 | |
| 13 | 13 | test('T3171',
|
| 14 | 14 | [when(opsys('mingw32'),skip),
|
| 15 | - fragile(15383),
|
|
| 16 | 15 | req_interp,
|
| 17 | 16 | combined_output],
|
| 18 | 17 | makefile_test, [])
|
| 19 | 18 | |
| 19 | +test('T3171ext',
|
|
| 20 | + [when(opsys('mingw32'),skip),
|
|
| 21 | + req_interp,
|
|
| 22 | + unless(config.have_ext_interp, skip),
|
|
| 23 | + combined_output],
|
|
| 24 | + makefile_test, [])
|
|
| 25 | + |
|
| 20 | 26 | test('ghcirun004', just_ghci, compile_and_run, [''])
|
| 21 | 27 | test('T8377', just_ghci, compile_and_run, [''])
|
| 22 | 28 | test('T9914', just_ghci, ghci_script, ['T9914.script'])
|