Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / xpcom / base / nsObjCExceptions.mm
blob77a7edc9980e5e671d4a265f335558c9aede9982
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsObjCExceptions.h"
9 #import <Foundation/Foundation.h>
11 #include <unistd.h>
12 #include <signal.h>
14 #include "nsICrashReporter.h"
15 #include "nsCOMPtr.h"
16 #include "nsServiceManagerUtils.h"
18 #include "nsError.h"
20 void nsObjCExceptionLog(NSException* aException) {
21   NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]", [aException name],
22         [aException reason]);
24   // Attach exception info to the crash report.
25   nsCOMPtr<nsICrashReporter> crashReporter =
26       do_GetService("@mozilla.org/toolkit/crash-reporter;1");
27   if (crashReporter) {
28     crashReporter->AppendObjCExceptionInfoToAppNotes(
29         static_cast<void*>(aException));
30   }
32 #ifdef DEBUG
33   NSLog(@"Stack trace:\n%@", [aException callStackSymbols]);
34 #endif
37 namespace mozilla {
39 bool ShouldIgnoreObjCException(NSException* aException) {
40   // Ignore known exceptions that we've seen in crash reports, which shouldn't
41   // cause a MOZ_CRASH in Nightly.
42   if (aException.name == NSInternalInconsistencyException) {
43     if ([aException.reason containsString:@"Missing Touches."]) {
44       // Seen in bug 1694000.
45       return true;
46     }
47   }
48   return false;
51 }  // namespace mozilla