Bug 1248303 - respect break on exceptions flag in subsequent debugger instances r=ejpbruel
authorJames Long <longster@gmail.com>
Wed, 16 Mar 2016 13:53:34 -0400
changeset 289070 14712d1923d4aed10b8bd23dde4f2980101d83c1
parent 289069 70f6fa801977779676eb46ee9531022c491b8089
child 289071 7afcc6cf189d172c6c754b4a5645b9659598ebb1
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel
bugs1248303
milestone48.0a1
Bug 1248303 - respect break on exceptions flag in subsequent debugger instances r=ejpbruel
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
@@ -1859,33 +1859,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