Bug 1422269 - Allow asan-reporter to report crashed tabs immediately. r?mconley draft
authorChristian Holler <choller@mozilla.com>
Fri, 01 Dec 2017 12:43:09 +0100
changeset 706999 20fbe71e2be0c67b5768bd49053c4e0a03d11a88
parent 706209 ac74d02ba092b6baa982e8077d00d1aacc135592
child 742829 ad8b4f16e3063bba04048768c25fbb7dd9a8af66
push id91991
push usercholler@mozilla.com
push dateMon, 04 Dec 2017 17:17:54 +0000
reviewersmconley
bugs1422269
milestone59.0a1
Bug 1422269 - Allow asan-reporter to report crashed tabs immediately. r?mconley MozReview-Commit-ID: BsO3LID1J9s
browser/extensions/asan-reporter/bootstrap.js
browser/extensions/asan-reporter/clone_asan_reporter.sh
--- a/browser/extensions/asan-reporter/bootstrap.js
+++ b/browser/extensions/asan-reporter/bootstrap.js
@@ -26,22 +26,47 @@ const PREF_LOG_LEVEL = "asanreporter.log
 
 // Setup logging
 const LOGGER_NAME = "extensions.asanreporter";
 let logger = Log.repository.getLogger(LOGGER_NAME);
 logger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
 logger.addAppender(new Log.DumpAppender(new Log.BasicFormatter()));
 logger.level = Preferences.get(PREF_LOG_LEVEL, Log.Level.Info);
 
+this.TabCrashObserver = {
+  init() {
+    if (this.initialized)
+      return;
+    this.initialized = true;
+
+    Services.obs.addObserver(this, "ipc:content-shutdown");
+  },
+
+  observe(aSubject, aTopic, aData) {
+    if (aTopic == "ipc:content-shutdown") {
+        aSubject.QueryInterface(Ci.nsIPropertyBag2);
+        if (!aSubject.get("abnormal")) {
+          return;
+        }
+        processDirectory("/tmp");
+    }
+  },
+};
+
 function install(aData, aReason) {}
 
 function uninstall(aData, aReason) {}
 
 function startup(aData, aReason) {
   logger.info("Starting up...");
+
+  // Install a handler to observe tab crashes, so we can report those right
+  // after they happen instead of relying on the user to restart the browser.
+  TabCrashObserver.init();
+
   // We could use OS.Constants.Path.tmpDir here, but unfortunately there is
   // no way in C++ to get the same value *prior* to xpcom initialization.
   // Since ASan needs its options, including the "log_path" option already
   // at early startup, there is no way to pass this on to ASan.
   //
   // Instead, we hardcode the /tmp directory here, which should be fine in
   // most cases, as long as we are on Linux and Mac (the main targets for
   // this addon at the time of writing).
--- a/browser/extensions/asan-reporter/clone_asan_reporter.sh
+++ b/browser/extensions/asan-reporter/clone_asan_reporter.sh
@@ -1,11 +1,11 @@
 #!/bin/sh
 
 mkdir tmp/
 git clone --no-checkout --depth 1 https://github.com/choller/firefox-asan-reporter tmp/
-(cd tmp && git reset --hard e1a5d7dc5a2706af72bac0f11eab34b3afdb48ba)
+(cd tmp && git reset --hard d508c6e3f5df752a9a7a2d6f1e4e7261ec2290e7)
 
 # Copy only whitelisted files
 cp tmp/bootstrap.js tmp/install.rdf.in tmp/moz.build tmp/README.md tmp/LICENSE .
 
 # Remove the temporary directory
 rm -Rf tmp/