Bug 1248303 - respect break on exceptions flag in subsequent debugger instances. r=ejpbruel, a=ritu
authorJames Long <longster@gmail.com>
Wed, 16 Mar 2016 13:53:34 -0400
changeset 323553 dbb7628d3963eed482f055a8921429163162ee36
parent 323552 680d97831b6211e6e4637210626de1bf5fe3fcd6
child 323554 34f2a18ac02519a97bc6a0e6c5de331fca149404
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel, ritu
bugs1248303
milestone47.0a2
Bug 1248303 - respect break on exceptions flag in subsequent debugger instances. r=ejpbruel, a=ritu
devtools/client/framework/attach-thread.js
devtools/shared/client/main.js
--- a/devtools/client/framework/attach-thread.js
+++ b/devtools/client/framework/attach-thread.js
@@ -43,35 +43,42 @@ function handleThreadState(toolbox, even
 
 function attachThread(toolbox) {
   let deferred = promise.defer();
 
   let target = toolbox.target;
   let { form: { chromeDebugger, actor } } = target;
   let threadOptions = {
     useSourceMaps: Services.prefs.getBoolPref("devtools.debugger.source-maps-enabled"),
-    autoBlackBox: Services.prefs.getBoolPref("devtools.debugger.auto-black-box"),
-    pauseOnExceptions: Services.prefs.getBoolPref("devtools.debugger.pause-on-exceptions"),
-    ignoreCaughtExceptions: Services.prefs.getBoolPref("devtools.debugger.ignore-caught-exceptions")
+    autoBlackBox: Services.prefs.getBoolPref("devtools.debugger.auto-black-box")
   };
 
   let handleResponse = (res, threadClient) => {
     if (res.error) {
       deferred.reject(new Error("Couldn't attach to thread: " + res.error));
       return;
     }
     threadClient.addListener("paused", handleThreadState.bind(null, toolbox));
     threadClient.addListener("resumed", handleThreadState.bind(null, toolbox));
 
     if (!threadClient.paused) {
       deferred.reject(
         new Error("Thread in wrong state when starting up, should be paused")
       );
     }
 
+    // These flags need to be set here because the client sends them
+    // with the `resume` request. We make sure to do this before
+    // resuming to avoid another interrupt. We can't pass it in with
+    // `threadOptions` because the resume request will override them.
+    threadClient.pauseOnExceptions(
+      Services.prefs.getBoolPref("devtools.debugger.pause-on-exceptions"),
+      Services.prefs.getBoolPref("devtools.debugger.ignore-caught-exceptions")
+    );
+
     threadClient.resume(res => {
       if (res.error === "wrongOrder") {
         const box = toolbox.getNotificationBox();
         box.appendNotification(
           l10n("toolbox.resumeOrderWarning"),
           "wrong-resume-order",
           "",
           box.PRIORITY_WARNING_HIGH
--- a/devtools/shared/client/main.js
+++ b/devtools/shared/client/main.js
@@ -1844,33 +1844,30 @@ ThreadClient.prototype = {
    *        Called with the response packet.
    */
   pauseOnExceptions: function (aPauseOnExceptions,
                                aIgnoreCaughtExceptions,
                                aOnResponse = noop) {
     this._pauseOnExceptions = aPauseOnExceptions;
     this._ignoreCaughtExceptions = aIgnoreCaughtExceptions;
 
-    // If the debuggee is paused, we have to send the flag via a reconfigure
-    // request.
-    if (this.paused) {
-      return this.reconfigure({
-        pauseOnExceptions: aPauseOnExceptions,
-        ignoreCaughtExceptions: aIgnoreCaughtExceptions
-      }, aOnResponse);
+    // Otherwise send the flag using a standard resume request.
+    if(!this.paused) {
+      return this.interrupt(aResponse => {
+        if (aResponse.error) {
+          // Can't continue if pausing failed.
+          aOnResponse(aResponse);
+          return aResponse;
+        }
+        return this.resume(aOnResponse);
+      });
     }
-    // Otherwise send the flag using a standard resume request.
-    return this.interrupt(aResponse => {
-      if (aResponse.error) {
-        // Can't continue if pausing failed.
-        aOnResponse(aResponse);
-        return aResponse;
-      }
-      return this.resume(aOnResponse);
-    });
+
+    aOnResponse();
+    return promise.resolve();
   },
 
   /**
    * Enable pausing when the specified DOM events are triggered. Disabling
    * pausing on an event can be realized by calling this method with the updated
    * array of events that doesn't contain it.
    *
    * @param array|string events