Commit 0b852fcf authored by Eric Seidel's avatar Eric Seidel Committed by Austin Seipp

base: use Show for ErrorCall in uncaughtExceptionHandler

The default top-level exception handler now uses the `Show` instance for
`ErrorCall` when printing exceptions, so it will actually print the out-of-band
data (e.g. `CallStack`s) in compiled binaries, instead of just printing the
error message.

This also updates the hpc submodule to fix the test output.

Reviewed By: austin, thomie

Differential Revision: https://phabricator.haskell.org/D1217
parent 83e23c1a
......@@ -1014,7 +1014,7 @@ dsEvCallStack cs = do
let srcLocTy = mkTyConTy srcLocTyCon
let mkSrcLoc l =
liftM (mkCoreConApps srcLocDataCon)
(sequence [ mkStringExprFS (packageKeyFS $ modulePackageKey m)
(sequence [ mkStringExpr (showPpr df $ modulePackageKey m)
, mkStringExprFS (moduleNameFS $ moduleName m)
, mkStringExprFS (srcSpanFile l)
, return $ mkIntExprInt df (srcSpanStartLine l)
......
......@@ -875,9 +875,7 @@ uncaughtExceptionHandler = unsafePerformIO (newIORef defaultHandler)
(hFlush stdout) `catchAny` (\ _ -> return ())
let msg = case cast ex of
Just Deadlock -> "no threads to run: infinite loop or deadlock?"
_ -> case cast ex of
Just (ErrorCall s) -> s
_ -> showsPrec 0 se ""
_ -> showsPrec 0 se ""
withCString "%s" $ \cfmt ->
withCString msg $ \cmsg ->
errorBelch cfmt cmsg
......
......@@ -162,6 +162,10 @@ test('topHandler03',
ignore_output,
signal_exit_code(15)
], compile_and_run, [''])
test('topHandler04',
[when(opsys('mingw32'), skip),
exit_code(1)
], compile_and_run, [''])
test('T8766',
......
readFloat: Prelude.read: no parse
CallStack:
error, called at libraries/base/Text/Read.hs:90:17 in base:Text.Read
import Control.Exception
-- test that the out-of-band data in an ErrorCall exception is printed
main = throw (ErrorCallWithLocation "error" "out-of-band")
topHandler04: error
out-of-band
Subproject commit 315b78ac8fe7b42912d2146783b0366f6b0e9503
Subproject commit 886429bf84097bbc16cdb6602b60ba1b9156cf6a
......@@ -1691,9 +1691,9 @@ def normalise_callstacks(str):
def repl(matches):
location = matches.group(1)
location = normalise_slashes_(location)
return ', called at {}:<line>:<column> in'.format(location)
return ', called at {}:<line>:<column> in <package-id>:'.format(location)
# Ignore line number differences in call stacks (#10834).
return re.sub(', called at (.+):[\\d]+:[\\d]+ in', repl, str)
return re.sub(', called at (.+):[\\d]+:[\\d]+ in [\\w\-\.]+:', repl, str)
def normalise_errmsg( str ):
# remove " error:" and lower-case " Warning:" to make patch for
......
arr003: Ix{Int}.index: Index (4) out of range ((1,3))
CallStack:
error, called at libraries/base/GHC/Arr.hs:176:5 in base:GHC.Arr
arr004: (Array.!): undefined array element
CallStack:
error, called at libraries/base/GHC/Arr.hs:402:16 in base:GHC.Arr
arr007: Ix{Int}.index: Index (1) out of range ((1,0))
CallStack:
error, called at libraries/base/GHC/Arr.hs:176:5 in base:GHC.Arr
arr008: Ix{Int}.index: Index (2) out of range ((0,1))
CallStack:
error, called at libraries/base/GHC/Arr.hs:176:5 in base:GHC.Arr
T5626: Prelude.undefined
CallStack:
error, called at libraries/base/GHC/Err.hs:42:14 in base:GHC.Err
undefined, called at T5626.hs:6:30 in main:Main
cgrun016: 6th call to error
CallStack:
error, called at cgrun016.hs:8:8 in main:Main
cgrun045: hello world!
CallStack:
error, called at cgrun045.hs:6:13 in main:Main
cgrun051: OK
CallStack:
error, called at cgrun051.hs:7:25 in main:Main
cgrun059: Error: File not found
CallStack:
error, called at cgrun059.hs:12:28 in main:Main
conc021: wurble
CallStack:
error, called at conc021.hs:9:9 in main:Main
T5628: Void ==
CallStack:
error, called at T5628.hs:5:1 in main:Main
StrictMain: Prelude.undefined
CallStack:
error, called at libraries/base/GHC/Err.hs:42:14 in base:GHC.Err
undefined, called at Main.hs:6:22 in main:Main
StrictMain: Prelude.undefined
CallStack:
error, called at libraries/base/GHC/Err.hs:42:14 in base:GHC.Err
undefined, called at Main.hs:6:22 in main:Main
ffi008: this is an error
CallStack:
error, called at ffi008.hs:12:12 in main:Main
fptrfail01: GHC.ForeignPtr: attempt to mix Haskell and C finalizers in the same ForeignPtr
CallStack:
error, called at libraries/base/GHC/ForeignPtr.hs:352:17 in base:GHC.ForeignPtr
ghc-e005-prog: foo
CallStack:
error, called at ghc-e005.hs:12:10 in main:Main
SafeLang09: This curry is poisoned!
CallStack:
error, called at ./SafeLang09_B.hs:14:13 in main:SafeLang09_B
T7411: Prelude.undefined
CallStack:
error, called at libraries/base/GHC/Err.hs:42:14 in base:GHC.Err
undefined, called at T7411.hs:3:25 in main:Main
T457: Correct
CallStack:
error, called at T457.hs:5:22 in main:Main
T5587: hidden error
CallStack:
error, called at T5587.hs:7:15 in main:Main
T5625: Prelude.undefined
CallStack:
error, called at libraries/base/GHC/Err.hs:42:14 in base:GHC.Err
undefined, called at T5625.hs:3:31 in main:Main
strun002: Variable not found: (2) hello
CallStack:
error, called at strun002.hs:7:11 in main:Main
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