Bug 709088 - Put dump() calls in debugger code behind a pref; r=rcampbell
authorPanos Astithas <past@mozilla.com>
Thu, 08 Mar 2012 09:14:41 +0200
changeset 88513 1fd0ed258309987a39683a2f15b54ebc81d60a7a
parent 88512 af56647a2715fa6d5b453f7ad92c3418b38e01cf
child 88514 e3edd93da0fcbad7ef3085e7e8905bbcacf585d6
push id22201
push userrcampbell@mozilla.com
push dateThu, 08 Mar 2012 14:30:33 +0000
treeherdermozilla-central@75b24396b0ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs709088
milestone13.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 709088 - Put dump() calls in debugger code behind a pref; r=rcampbell
browser/app/profile/firefox.js
browser/devtools/debugger/debugger-view.js
browser/devtools/debugger/debugger.js
toolkit/devtools/debugger/dbg-client.jsm
toolkit/devtools/debugger/server/dbg-server.jsm
toolkit/devtools/debugger/tests/unit/test_frameclient-01.js
toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1037,16 +1037,19 @@ pref("devtools.inspector.sidebarOpen", f
 pref("devtools.inspector.activeSidebar", "ruleview");
 
 // Enable the Debugger
 pref("devtools.debugger.enabled", false);
 
 // The default Debugger UI height
 pref("devtools.debugger.ui.height", 250);
 
+// Disable remote debugging protocol logging
+pref("devtools.debugger.log", false);
+
 // Enable the style inspector
 pref("devtools.styleinspector.enabled", true);
 
 // Enable the Tilt inspector
 pref("devtools.tilt.enabled", true);
 pref("devtools.tilt.intro_transition", true);
 pref("devtools.tilt.outro_transition", true);
 
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -195,17 +195,16 @@ DebuggerView.Stackframes = {
    * @param boolean aSelect
    *        True if the frame should be selected, false otherwise.
    */
   highlightFrame: function DVF_highlightFrame(aDepth, aSelect) {
     let frame = document.getElementById("stackframe-" + aDepth);
 
     // the list item wasn't found in the stackframe container
     if (!frame) {
-      dump("The frame list item wasn't found in the stackframes container.");
       return;
     }
 
     // add the 'selected' css class if the frame isn't already selected
     if (aSelect && !frame.classList.contains("selected")) {
       frame.classList.add("selected");
 
     // remove the 'selected' css class if the frame is already selected
@@ -352,17 +351,16 @@ DebuggerView.Properties = {
     // compute the id of the element if not specified
     aId = aId || (aName.toLowerCase().trim().replace(" ", "-") + "-scope");
 
     // contains generic nodes and functionality
     let element = this._createPropertyElement(aName, aId, "scope", this._vars);
 
     // make sure the element was created successfully
     if (!element) {
-      dump("The debugger scope container wasn't created properly: " + aId);
       return null;
     }
 
     /**
      * @see DebuggerView.Properties._addVar
      */
     element.addVar = this._addVar.bind(this, element);
 
@@ -394,17 +392,16 @@ DebuggerView.Properties = {
     aId = aId || (aScope.id + "->" + aName + "-variable");
 
     // contains generic nodes and functionality
     let element = this._createPropertyElement(aName, aId, "variable",
                                               aScope.querySelector(".details"));
 
     // make sure the element was created successfully
     if (!element) {
-      dump("The debugger variable container wasn't created properly: " + aId);
       return null;
     }
 
     /**
      * @see DebuggerView.Properties._setGrip
      */
     element.setGrip = this._setGrip.bind(this, element);
 
@@ -462,17 +459,16 @@ DebuggerView.Properties = {
     if (!aVar) {
       return null;
     }
 
     let info = aVar.querySelector(".info") || aVar.target.info;
 
     // make sure the info node exists
     if (!info) {
-      dump("Could not set the grip for the corresponding variable: " + aVar.id);
       return null;
     }
 
     info.textContent = this._propertyString(aGrip);
     info.classList.add(this._propertyColor(aGrip));
 
     return aVar;
   },
@@ -565,17 +561,16 @@ DebuggerView.Properties = {
     aId = aId || (aVar.id + "->" + aProperty[0] + "-property");
 
     // contains generic nodes and functionality
     let element = this._createPropertyElement(aName, aId, "property",
                                               aVar.querySelector(".details"));
 
     // make sure the element was created successfully
     if (!element) {
-      dump("The debugger property container wasn't created properly.");
       return null;
     }
 
     /**
      * @see DebuggerView.Properties._setGrip
      */
     element.setGrip = this._setGrip.bind(this, element);
 
@@ -706,21 +701,19 @@ DebuggerView.Properties = {
    * @param object aParent
    *        The parent node which will contain the element.
    * @return object
    *         The newly created html node representing the generic elem.
    */
   _createPropertyElement: function DVP__createPropertyElement(aName, aId, aClass, aParent) {
     // make sure we don't duplicate anything and the parent exists
     if (document.getElementById(aId)) {
-      dump("Duplicating a property element id is not allowed.");
       return null;
     }
     if (!aParent) {
-      dump("A property element must have a valid parent node specified.");
       return null;
     }
 
     let element = document.createElement("div");
     let arrow = document.createElement("span");
     let name = document.createElement("span");
     let title = document.createElement("div");
     let details = document.createElement("div");
--- a/browser/devtools/debugger/debugger.js
+++ b/browser/devtools/debugger/debugger.js
@@ -73,17 +73,18 @@ function startDebuggingTab(aClient, aTab
 {
   gClient = aClient;
 
   gClient.attachTab(aTabGrip.actor, function(aResponse, aTabClient) {
     if (aTabClient) {
       gTabClient = aTabClient;
       gClient.attachThread(aResponse.threadActor, function(aResponse, aThreadClient) {
         if (!aThreadClient) {
-          dump("Couldn't attach to thread: "+aResponse.error+"\n");
+          Components.utils.reportError("Couldn't attach to thread: " +
+                                       aResponse.error);
           return;
         }
         ThreadState.connect(aThreadClient, function() {
           StackFrames.connect(aThreadClient, function() {
             SourceScripts.connect(aThreadClient, function() {
               aThreadClient.resume();
             });
           });
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/debugger/dbg-client.jsm
@@ -46,24 +46,29 @@ const Cu = Components.utils;
 const Cr = Components.results;
 
 var EXPORTED_SYMBOLS = ["DebuggerTransport",
                         "DebuggerClient",
                         "debuggerSocketConnect"];
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "socketTransportService",
                                    "@mozilla.org/network/socket-transport-service;1",
                                    "nsISocketTransportService");
 
+let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
+
 function dumpn(str)
 {
-  dump("DBG-CLIENT: " + str + "\n");
+  if (wantLogging) {
+    dump("DBG-CLIENT: " + str + "\n");
+  }
 }
 
 let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader);
 loader.loadSubScript("chrome://global/content/devtools/dbg-transport.js");
 
 /**
  * Add simple event notification to a prototype object. Any object that has
--- a/toolkit/devtools/debugger/server/dbg-server.jsm
+++ b/toolkit/devtools/debugger/server/dbg-server.jsm
@@ -45,31 +45,36 @@
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const CC = Components.Constructor;
 const Cu = Components.utils;
 
 var EXPORTED_SYMBOLS = ["DebuggerServer"];
 
+Cu.import("resource://gre/modules/Services.jsm");
+let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
+
 function loadSubScript(aURL)
 {
   try {
     let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
       .getService(Components.interfaces.mozIJSSubScriptLoader);
     loader.loadSubScript(aURL, this);
   } catch(e) {
-    dump("Error loading: " + aURL + ": " + e + " - " + e.stack + "\n");
+    dumpn("Error loading: " + aURL + ": " + e + " - " + e.stack + "\n");
 
     throw e;
   }
 }
 
 function dumpn(str) {
-  dump("DBG-SERVER: " + str + "\n");
+  if (wantLogging) {
+    dump("DBG-SERVER: " + str + "\n");
+  }
 }
 
 function dbg_assert(cond, e) {
   if (!cond) {
     return e;
   }
 }
 
--- a/toolkit/devtools/debugger/tests/unit/test_frameclient-01.js
+++ b/toolkit/devtools/debugger/tests/unit/test_frameclient-01.js
@@ -37,17 +37,16 @@ function test_pause_frame()
       });
     });
     do_check_true(gThreadClient.fillFrames(3));
   });
 
   gDebuggee.eval("(" + function() {
     var recurseLeft = 5;
     function recurse() {
-      dump(recurseLeft);
       if (--recurseLeft == 0) {
         debugger;
         return;
       }
       recurse();
     };
     recurse();
     ")"
--- a/toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js
+++ b/toolkit/devtools/debugger/tests/unit/test_pauselifetime-04.js
@@ -27,17 +27,16 @@ function run_test()
 function test_pause_frame()
 {
   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
     let args = aPacket.frame["arguments"];
     let objActor1 = args[0].actor;
 
     gThreadClient.getFrames(0, 1, function(aResponse) {
       let frame = aResponse.frames[0];
-      dump(JSON.stringify(frame));
       do_check_eq(objActor1, frame.arguments[0].actor);
       gThreadClient.resume(function () {
         finishClient(gClient);
       });
     });
   });
 
   gDebuggee.eval("(" + function() {