From 6373626b4259d9be2b72a3f1453d269e63ba1dc1 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek%gmail.com" Date: Wed, 25 Jul 2007 01:07:01 +0000 Subject: [PATCH] bug 382541 - Mozilla Crash Reporter supresses writing of Mac OS X crash log - short term workaround. r=mento --- toolkit/crashreporter/Makefile.in | 2 + toolkit/crashreporter/mac_utils.h | 47 ++++++++++++++++++ toolkit/crashreporter/mac_utils.mm | 50 ++++++++++++++++++++ toolkit/crashreporter/nsExceptionHandler.cpp | 19 ++++++-- 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 toolkit/crashreporter/mac_utils.h create mode 100644 toolkit/crashreporter/mac_utils.mm diff --git a/toolkit/crashreporter/Makefile.in b/toolkit/crashreporter/Makefile.in index c9de0a5d9ff..b9f09fb6a32 100644 --- a/toolkit/crashreporter/Makefile.in +++ b/toolkit/crashreporter/Makefile.in @@ -61,6 +61,8 @@ ifeq ($(OS_ARCH),WINNT) endif ifeq ($(OS_ARCH),Darwin) +CMMSRCS = mac_utils.mm + DIRS += \ airbag/src/common \ airbag/src/common/mac \ diff --git a/toolkit/crashreporter/mac_utils.h b/toolkit/crashreporter/mac_utils.h new file mode 100644 index 00000000000..7c67c847c42 --- /dev/null +++ b/toolkit/crashreporter/mac_utils.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Breakpad integration + * + * The Initial Developer of the Original Code is + * Ted Mielczarek + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef toolkit_breakpad_mac_utils_h__ +#define toolkit_breakpad_mac_utils_h__ + +/* + * Look up a setting in our user defaults indicating + * that the user wants to see the OS crash reporting dialog. + */ +bool PassToOSCrashReporter(); + +#endif /* toolkit_breakpad_mac_utils_h__ */ diff --git a/toolkit/crashreporter/mac_utils.mm b/toolkit/crashreporter/mac_utils.mm new file mode 100644 index 00000000000..99d462aba32 --- /dev/null +++ b/toolkit/crashreporter/mac_utils.mm @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Breakpad integration + * + * The Initial Developer of the Original Code is + * Ted Mielczarek + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include + +#include "mac_utils.h" + +bool PassToOSCrashReporter() +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; + BOOL osCrashReporter = [userDefaults boolForKey:@"OSCrashReporter"]; + [pool release]; + + return osCrashReporter == YES; +} diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 53ec8ccfe08..072d1103fe1 100755 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -49,6 +49,7 @@ #include #include #include +#include "mac_utils.h" #elif defined(XP_LINUX) #include "client/linux/handler/exception_handler.h" #include @@ -104,6 +105,9 @@ static XP_CHAR* crashReporterPath; // if this is false, we don't launch the crash reporter static bool doReport = true; +// if this is true, we pass the exception on to the OS crash reporter +static bool showOSCrashReporter = false; + // this holds additional data sent via the API static nsDataHashtable* crashReporterAPIData_Hash; static nsCString* crashReporterAPIData = nsnull; @@ -131,7 +135,7 @@ bool MinidumpCallback(const XP_CHAR* dump_path, #endif bool succeeded) { - printf("Wrote minidump ID %s\n", minidump_id); + bool returnValue = showOSCrashReporter ? false : succeeded; XP_CHAR minidumpPath[XP_PATH_MAX]; int size = XP_PATH_MAX; @@ -170,7 +174,7 @@ bool MinidumpCallback(const XP_CHAR* dump_path, } if (!doReport) { - return succeeded; + return returnValue; } STARTUPINFO si; @@ -204,7 +208,7 @@ bool MinidumpCallback(const XP_CHAR* dump_path, } if (!doReport) { - return succeeded; + return returnValue; } pid_t pid = fork(); @@ -218,7 +222,7 @@ bool MinidumpCallback(const XP_CHAR* dump_path, } #endif - return succeeded; + return returnValue; } nsresult SetExceptionHandler(nsILocalFile* aXREDirectory, @@ -311,6 +315,13 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory, AnnotateCrashReport(NS_LITERAL_CSTRING("ServerURL"), nsDependentCString(aServerURL)); +#if defined(XP_MACOSX) + // On OS X, many testers like to see the OS crash reporting dialog + // since it offers immediate stack traces. We allow them to set + // a default to pass exceptions to the OS handler. + showOSCrashReporter = PassToOSCrashReporter(); +#endif + return NS_OK; }