From ec9ac20d0964c9f1323105b5a2df24f50d4fe3ef Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Tue, 3 Oct 2017 13:37:52 -0400 Subject: Add ability to produce crash dumps on Windows It's often hard to debug things like segfaults on Windows, mostly because gdb isn't always of use and users don't know how to effectively use it. This patch provides a way to create a crash drump by passing `+RTS --generate-crash-dumps` as an option. If any unhandled exception is triggered a dump is made that contains enough information to be able to diagnose things successfully. Currently the created dumps are a bit big because I include all registers, code and threads information. This looks like ``` $ testsuite/tests/rts/derefnull.run/derefnull.exe +RTS --generate-crash-dumps Access violation in generated code when reading 0000000000000000 Crash dump created. Dump written to: E:\msys64\tmp\ghc-20170901-220250-11216-16628.dmp ``` Test Plan: ./validate Reviewers: austin, hvr, bgamari, erikd, simonmar Reviewed By: bgamari, simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3912 --- libraries/base/GHC/RTS/Flags.hsc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libraries/base/GHC/RTS') diff --git a/libraries/base/GHC/RTS/Flags.hsc b/libraries/base/GHC/RTS/Flags.hsc index df7cebf9b8..62b79ed064 100644 --- a/libraries/base/GHC/RTS/Flags.hsc +++ b/libraries/base/GHC/RTS/Flags.hsc @@ -132,6 +132,7 @@ data MiscFlags = MiscFlags { tickInterval :: RtsTime , installSignalHandlers :: Bool , installSEHHandlers :: Bool + , generateCrashDumpFile :: Bool , machineReadable :: Bool , linkerMemBase :: Word -- ^ address to ask the OS for memory for the linker, 0 ==> off @@ -406,6 +407,7 @@ getMiscFlags = do MiscFlags <$> #{peek MISC_FLAGS, tickInterval} ptr <*> #{peek MISC_FLAGS, install_signal_handlers} ptr <*> #{peek MISC_FLAGS, install_seh_handlers} ptr + <*> #{peek MISC_FLAGS, generate_dump_file} ptr <*> #{peek MISC_FLAGS, machineReadable} ptr <*> #{peek MISC_FLAGS, linkerMemBase} ptr -- cgit v1.2.1