Bug 855040 - Add a bit of logging in the crash report to help diagnostics and silence exception of crash report is disabled. r=fabrice
authorHubert Figuière <hfiguiere@mozilla.com>
Mon, 22 Apr 2013 16:09:15 -0400
changeset 140922 50842c3744ecdd68f307490425e0541df5e86eb2
parent 140921 9c669c34363c901bd22a21f9c1c9c510eb12ed66
child 140923 9b26c4651a1fea3a38692abbc20c97f01050a142
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs855040
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 855040 - Add a bit of logging in the crash report to help diagnostics and silence exception of crash report is disabled. r=fabrice
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -79,24 +79,33 @@ XPCOMUtils.defineLazyServiceGetter(Servi
 function getContentWindow() {
   return shell.contentBrowser.contentWindow;
 }
 
 function debug(str) {
   dump(' -*- Shell.js: ' + str + '\n');
 }
 
+#ifdef MOZ_CRASHREPORTER
+function debugCrashReport(aStr) {
+  dump('Crash reporter : ' + aStr);
+}
+#else
+function debugCrashReport(aStr) {}
+#endif
+
 var shell = {
 
   get CrashSubmit() {
     delete this.CrashSubmit;
 #ifdef MOZ_CRASHREPORTER
     Cu.import("resource://gre/modules/CrashSubmit.jsm", this);
     return this.CrashSubmit;
 #else
+    dump('Crash reporter : disabled at build time.');
     return this.CrashSubmit = null;
 #endif
   },
 
   onlineForCrashReport: function shell_onlineForCrashReport() {
     let wifiManager = navigator.mozWifiManager;
     let onWifi = (wifiManager &&
                   (wifiManager.connection.status == 'connected'));
@@ -106,32 +115,39 @@ var shell = {
   reportCrash: function shell_reportCrash(isChrome, aCrashID) {
     let crashID = aCrashID;
     try {
       // For chrome crashes, we want to report the lastRunCrashID.
       if (isChrome) {
         crashID = Cc["@mozilla.org/xre/app-info;1"]
                     .getService(Ci.nsIXULRuntime).lastRunCrashID;
       }
-    } catch(e) { }
+    } catch(e) {
+      debugCrashReport('Failed to fetch crash id. Crash ID is "' + crashID
+                       + '" Exception: ' + e);
+    }
 
     // Bail if there isn't a valid crashID.
     if (!this.CrashSubmit || !crashID && !this.CrashSubmit.pendingIDs().length) {
       return;
     }
 
     // purge the queue.
     this.CrashSubmit.pruneSavedDumps();
 
     try {
       // Check if we should automatically submit this crash.
-      if (Services.prefs.getBoolPref("app.reportCrashes")) {
+      if (Services.prefs.getBoolPref('app.reportCrashes')) {
         this.submitCrash(crashID);
+      } else {
+        debugCrashReport('app.reportCrashes is disabled');
       }
-    } catch (e) { }
+    } catch (e) {
+      debugCrashReport('Can\'t fetch app.reportCrashes. Exception: ' + e);
+    }
 
     // We can get here if we're just submitting old pending crashes.
     // Check that there's a valid crashID so that we only notify the
     // user if a crash just happened and not when we OOM. Bug 829477
     if (crashID) {
       this.sendChromeEvent({
         type: "handle-crash",
         crashID: crashID,
@@ -141,27 +157,30 @@ var shell = {
   },
 
   // this function submit the pending crashes.
   // make sure you are online.
   submitQueuedCrashes: function shell_submitQueuedCrashes() {
     // submit the pending queue.
     let pending = shell.CrashSubmit.pendingIDs();
     for (let crashid of pending) {
+      debugCrashReport('Submitting crash: ' + crashid);
       shell.CrashSubmit.submit(crashid);
     }
   },
 
   // This function submits a crash when we're online.
   submitCrash: function shell_submitCrash(aCrashID) {
     if (this.onlineForCrashReport()) {
       this.submitQueuedCrashes();
       return;
     }
 
+    debugCrashReport('Not online, postponing.');
+
     Services.obs.addObserver(function observer(subject, topic, state) {
       let network = subject.QueryInterface(Ci.nsINetworkInterface);
       if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
           && network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
         shell.submitQueuedCrashes();
 
         Services.obs.removeObserver(observer, topic);
       }
@@ -237,17 +256,17 @@ var shell = {
         try {
           let cr = Cc["@mozilla.org/xre/app-info;1"]
                      .getService(Ci.nsICrashReporter);
           cr.annotateCrashReport("B2G_OS_Version", value);
         } catch(e) { }
       });
 #endif
     } catch(e) {
-      dump("exception: " + e);
+      debugCrashReport('exception: ' + e);
     }
 
     let homeURL = this.homeURL;
     if (!homeURL) {
       let msg = 'Fatal error during startup: No homescreen found: try setting B2G_HOMESCREEN';
       alert(msg);
       return;
     }