Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: base/test_suite.h

Issue 201050: Print stack trace on exception in unit tests on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/debug_util_win.cc ('K') | « base/debug_util_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test_suite.h
===================================================================
--- base/test_suite.h (revision 25620)
+++ base/test_suite.h (working copy)
@@ -40,8 +40,23 @@
StackTrace().PrintBacktrace();
_exit(1);
}
-#endif
+#endif // OS_POSIX
+#if defined(OS_WIN)
+// Previous unhandled filter. Will be called if not NULL when we intercept an
+// exception.
+__declspec(selectany) LPTOP_LEVEL_EXCEPTION_FILTER g_previous_filter = NULL;
+
+// Prints the exception call stack.
+// This is the unit tests exception filter.
+inline long WINAPI UnitTestExceptionFilter(EXCEPTION_POINTERS* info) {
+ StackTrace(info).PrintBacktrace();
+ if (g_previous_filter)
+ return g_previous_filter(info);
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+#endif // OS_WIN
+
class TestSuite {
public:
TestSuite(int argc, char** argv) {
@@ -155,6 +170,9 @@
// As a hack workaround, just #ifdef out this code for Purify builds.
logging::SetLogAssertHandler(UnitTestAssertHandler);
#endif // !defined(PURIFY)
+ // Add stack dumping support on exception on windows. Similar to OS_POSIX
+ // signal() handling above.
+ g_previous_filter = SetUnhandledExceptionFilter(&UnitTestExceptionFilter);
}
#endif // defined(OS_WIN)
« base/debug_util_win.cc ('K') | « base/debug_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698