| Index: runtime/bin/platform_win.cc
|
| diff --git a/runtime/bin/platform_win.cc b/runtime/bin/platform_win.cc
|
| index b0e8eabb1e78c9126fe2bcca2f76107c7c18a0f3..37e33c3055e117465d043b003033c7d8b2ec7dcf 100644
|
| --- a/runtime/bin/platform_win.cc
|
| +++ b/runtime/bin/platform_win.cc
|
| @@ -62,6 +62,10 @@ class PlatformWin {
|
| // CTRL_C_EVENT signal. This will only run when there is no signal handler
|
| // registered for the CTRL_C_EVENT from Dart code.
|
| SetConsoleCtrlHandler(SignalHandler, TRUE);
|
| +#ifndef PRODUCT
|
| + // Set up global exception handler to be able to dump stack trace on crash.
|
| + SetExceptionHandler();
|
| +#endif
|
| }
|
|
|
| static BOOL WINAPI SignalHandler(DWORD signal) {
|
| @@ -106,6 +110,26 @@ class PlatformWin {
|
| RestoreConsoleLocked();
|
| }
|
|
|
| +
|
| + // Windows top-level unhandled exception handler function.
|
| + // See MSDN documentation for UnhandledExceptionFilter.
|
| + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms681401(v=vs.85).aspx
|
| + static LONG WINAPI
|
| + DartExceptionHandler(struct _EXCEPTION_POINTERS* ExceptionInfo) {
|
| + if (ExceptionInfo->ExceptionRecord->ExceptionCode ==
|
| + EXCEPTION_ACCESS_VIOLATION) {
|
| + Dart_DumpNativeStackTrace(ExceptionInfo->ContextRecord);
|
| + RestoreConsole();
|
| + abort();
|
| + }
|
| + return EXCEPTION_CONTINUE_SEARCH;
|
| + }
|
| +
|
| +
|
| + static void SetExceptionHandler() {
|
| + SetUnhandledExceptionFilter(DartExceptionHandler);
|
| + }
|
| +
|
| private:
|
| static Mutex* platform_win_mutex_;
|
| static int saved_output_cp_;
|
|
|