[commit: ghc] ghc-8.0: Use implicit CallStacks for ASSERT when available (ec85e1e)
git at git.haskell.org
git at git.haskell.org
Wed Jan 13 19:34:09 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/ec85e1e58fdcea165c4bd9881b091f07f2989014/ghc
>---------------------------------------------------------------
commit ec85e1e58fdcea165c4bd9881b091f07f2989014
Author: Bartosz Nitka <niteria at gmail.com>
Date: Wed Jan 13 14:44:58 2016 +0100
Use implicit CallStacks for ASSERT when available
This aids with debugging, since all you have to do to get more
stack frames is add a constraint `(?callStack :: CallStack) =>`.
Old output:
```
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20160107 for x86_64-unknown-linux):
ASSERT failed!
file compiler/types/TyCoRep.hs line 1800
InScope []
[Xuv :-> n_av5[sk]]
[]
```
New output:
```
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20160107 for x86_64-unknown-linux):
ASSERT failed!
CallStack (from ImplicitParams):
assertPprPanic, called at compiler/types/TyCoRep.hs:1800:95 in
ghc:TyCoRep
InScope []
[Xuv :-> n_av5[sk]]
[]
```
Test Plan:
harbormaster
manual testing
Reviewers: austin, gridaphobe, bgamari
Reviewed By: gridaphobe, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1751
(cherry picked from commit 88d6d5aae2ae86646084f3a060ae911eff589b7a)
>---------------------------------------------------------------
ec85e1e58fdcea165c4bd9881b091f07f2989014
compiler/utils/Outputable.hs | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index c3bdf5e..35a59c6 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -1096,15 +1096,24 @@ warnPprTrace True file line msg x
where
heading = hsep [text "WARNING: file", text file <> comma, text "line", int line]
+-- | Panic with an assertation failure, recording the given file and
+-- line number. Should typically be accessed with the ASSERT family of macros
+#if __GLASGOW_HASKELL__ > 710
+assertPprPanic :: (?callStack :: CallStack) => String -> Int -> SDoc -> a
+assertPprPanic _file _line msg
+ = pprPanic "ASSERT failed!" doc
+ where
+ doc = sep [ text (prettyCallStack ?callStack)
+ , msg ]
+#else
assertPprPanic :: String -> Int -> SDoc -> a
--- ^ Panic with an assertation failure, recording the given file and line number.
--- Should typically be accessed with the ASSERT family of macros
assertPprPanic file line msg
= pprPanic "ASSERT failed!" doc
where
doc = sep [ hsep [ text "file", text file
, text "line", int line ]
, msg ]
+#endif
pprDebugAndThen :: DynFlags -> (String -> a) -> SDoc -> SDoc -> a
pprDebugAndThen dflags cont heading pretty_msg
More information about the ghc-commits
mailing list