Created
June 20, 2019 02:48
-
-
Save luochen1990/7b274e1e7b58250d2bb0aa4d760d3f17 to your computer and use it in GitHub Desktop.
Get Call Stack from `-xc` without `HasCallStack`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import GHC.Stack | |
| foo :: [Int] -> Int | |
| foo xs = last xs + 1 | |
| bar :: [Int] -> Int | |
| bar xs = foo xs | |
| xs :: [Int] | |
| xs = [] | |
| main :: IO () | |
| main = print $ bar xs | |
| {- | |
| $ ghc -prof -fprof-auto-top call-stack-without-hascallstack.hs | |
| $ ./call-stack-without-hascallstack | |
| call-stack-without-hascallstack: Prelude.last: empty list | |
| $ ./call-stack-without-hascallstack +RTS -xc | |
| *** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace: | |
| GHC.List.CAF | |
| --> evaluated by: Main.foo, | |
| called from Main.bar, | |
| called from Main.main, | |
| called from Main.CAF | |
| --> evaluated by: Main.main, | |
| called from Main.CAF | |
| --> evaluated by: Main.main | |
| call-stack-without-hascallstack: Prelude.last: empty list | |
| -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment