summaryrefslogtreecommitdiff
path: root/rts/RtsFlags.c
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2017-10-03 13:37:52 -0400
committerBen Gamari <ben@smart-cactus.org>2017-10-03 15:16:27 -0400
commitec9ac20d0964c9f1323105b5a2df24f50d4fe3ef (patch)
tree5e21ede1766511cc09b1eb46e7f571d36f3c34ae /rts/RtsFlags.c
parent55001c0c9934de2cf94d3879cea20c0faf73695c (diff)
downloadhaskell-ec9ac20d0964c9f1323105b5a2df24f50d4fe3ef.tar.gz
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
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r--rts/RtsFlags.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 5a5abb0d19..5bdf9922de 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -226,6 +226,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.MiscFlags.install_signal_handlers = true;
RtsFlags.MiscFlags.install_seh_handlers = true;
+ RtsFlags.MiscFlags.generate_dump_file = false;
RtsFlags.MiscFlags.machineReadable = false;
RtsFlags.MiscFlags.linkerMemBase = 0;
@@ -430,6 +431,10 @@ usage_text[] = {
#if defined(mingw32_HOST_OS)
" --install-seh-handlers=<yes|no>",
" Install exception handlers (default: yes)",
+" --generate-crash-dumps",
+" Generate Windows crash dumps, requires exception handlers",
+" to be installed. Implies --install-signal-handlers=yes.",
+" (default: no)",
#endif
#if defined(THREADED_RTS)
" -e<n> Maximum number of outstanding local sparks (default: 4096)",
@@ -855,6 +860,11 @@ error = true;
OPTION_UNSAFE;
RtsFlags.MiscFlags.install_seh_handlers = false;
}
+ else if (strequal("generate-crash-dumps",
+ &rts_argv[arg][2])) {
+ OPTION_UNSAFE;
+ RtsFlags.MiscFlags.generate_dump_file = true;
+ }
else if (strequal("machine-readable",
&rts_argv[arg][2])) {
OPTION_UNSAFE;
@@ -1608,6 +1618,11 @@ static void normaliseRtsOpts (void)
RtsFlags.ParFlags.parGcLoadBalancingGen = 1;
}
}
+
+ // We can't generate dumps without signal handlers
+ if (RtsFlags.MiscFlags.generate_dump_file) {
+ RtsFlags.MiscFlags.install_seh_handlers = true;
+ }
}
static void errorUsage (void)