bug 1523104: remote: change flag from --debug to --remote-debugger; r=ochameau
authorAndreas Tolfsen <ato@sny.no>
Sun, 17 Feb 2019 16:14:01 +0000
changeset 521091 d4ddf649862b
parent 521090 6ee3f621e6b8
child 521092 f8726e16183f
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1523104
milestone67.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 1523104: remote: change flag from --debug to --remote-debugger; r=ochameau Also introduces a --remote-debugging-port <port> flag for compatibility with Chrome and Opera.
remote/README
remote/RemoteAgent.js
remote/doc/Building.md
remote/doc/Debugging.md
remote/doc/Prefs.md
--- a/remote/README
+++ b/remote/README
@@ -10,11 +10,12 @@ of a remote devtools interface using the
 
 See https://firefox-source-docs.mozilla.org/remote/ for documentation.
 
 The remote agent is not by default included in Firefox builds.
 To build it, put this in your mozconfig:
 
 	ac_add_options --enable-cdp
 
-This exposes a --debug flag you can use to start the remote agent:
+This exposes a --remote-debugger flag you can use to start the
+remote agent:
 
-	% ./mach run --setpref "browser.fission.simulate=true" -- --debug
+	% ./mach run --setpref "browser.fission.simulate=true" -- --remote-debugger
--- a/remote/RemoteAgent.js
+++ b/remote/RemoteAgent.js
@@ -126,37 +126,50 @@ class ParentRemoteAgent {
       return null;
     }
     return this.server.identity.primaryPort;
   }
 
   // nsICommandLineHandler
 
   async handle(cmdLine) {
-    let flag;
-    try {
-      flag = cmdLine.handleFlagWithParam("debug", false);
-    } catch (e) {
-      flag = cmdLine.handleFlag("debug", false);
+    function flag(name) {
+      const caseSensitive = true;
+      try {
+        return cmdLine.handleFlagWithParam(name, caseSensitive);
+      } catch (e) {
+        return cmdLine.handleFlag(name, caseSensitive);
+      }
     }
 
-    if (!flag) {
+    const remoteDebugger = flag("remote-debugger");
+    const remoteDebuggingPort = flag("remote-debugging-port");
+
+    if (remoteDebugger && remoteDebuggingPort) {
+      log.fatal("Conflicting flags --remote-debugger and --remote-debugging-port");
+      cmdLine.preventDefault = true;
+      return;
+    }
+
+    if (!remoteDebugger && !remoteDebuggingPort) {
       return;
     }
 
     let host, port;
-    if (typeof flag == "string") {
-      [host, port] = flag.split(":");
+    if (typeof remoteDebugger == "string") {
+      [host, port] = remoteDebugger.split(":");
+    } else if (typeof remoteDebuggingPort == "string") {
+      port = remoteDebuggingPort;
     }
 
     let addr;
     try {
       addr = NetUtil.newURI(`http://${host || DEFAULT_HOST}:${port || DEFAULT_PORT}/`);
     } catch (e) {
-      log.fatal(`Expected address syntax [<host>]:<port>: ${flag}`);
+      log.fatal(`Expected address syntax [<host>]:<port>: ${remoteDebugger || remoteDebuggingPort}`);
       cmdLine.preventDefault = true;
       return;
     }
 
     await Observer.once("sessionstore-windows-restored");
     await this.tabs.start();
 
     try {
@@ -164,27 +177,25 @@ class ParentRemoteAgent {
     } catch ({message}) {
       this.close();
       log.fatal(`Unable to start remote agent on ${addr.spec}: ${message}`);
       cmdLine.preventDefault = true;
     }
   }
 
   get helpInfo() {
-    return "  --debug [<host>][:<port>] Start the Firefox remote agent, which is a low-level\n" +
-           "                     debugging interface based on the CDP protocol.  Defaults to\n" +
-           "                     listen on port 9222.\n";
+    return "  --remote-debugger [<host>][:<port>] Start the Firefox remote agent, which is \n" +
+           "                     a low-level debugging interface based on the CDP protocol.\n" +
+           "                     Defaults to listen on port 9222.\n";
   }
 
   // XPCOM
 
   get QueryInterface() {
-    return ChromeUtils.generateQI([
-      Ci.nsICommandLineHandler,
-    ]);
+    return ChromeUtils.generateQI([Ci.nsICommandLineHandler]);
   }
 }
 
 class Targets {
   constructor() {
     // browser context ID -> Target<XULElement>
     this._targets = new Map();
   }
--- a/remote/doc/Building.md
+++ b/remote/doc/Building.md
@@ -1,19 +1,20 @@
 Building
 ========
 
 The remote agent is by default not included in Firefox builds.
 To build it, put this in your [mozconfig]:
 
 	ac_add_options --enable-cdp
 
-This exposes a --debug flag you can use to start the remote agent:
+This exposes a `--remote-debugger` flag you can use to start the
+remote agent:
 
-	% ./mach run --setpref "browser.fission.simulate=true" -- --debug
+	% ./mach run --setpref "browser.fission.simulate=true" -- --remote-debugger
 
 When you make changes to the XPCOM component you need to rebuild
 in order for the changes to take effect.  The most efficient way to
 do this, provided you haven’t touched any compiled code (C++ or Rust):
 
 	% ./mach build faster
 
 Component files include the likes of RemoteAgent.js, RemoteAgent.manifest,
--- a/remote/doc/Debugging.md
+++ b/remote/doc/Debugging.md
@@ -4,11 +4,11 @@ Debugging
 Increasing the logging verbosity
 --------------------------------
 
 To increase the internal logging verbosity you can use the
 `remote.log.level` [preference].
 
 If you use mach to start the Firefox:
 
-	./mach run --setpref "browser.fission.simulate=true" --setpref "remote.log.level=Debug" -- --debug
+	./mach run --setpref "browser.fission.simulate=true" --setpref "remote.log.level=Debug" -- --remote-debugger
 
 [preference]: ./Prefs.md
--- a/remote/doc/Prefs.md
+++ b/remote/doc/Prefs.md
@@ -4,19 +4,19 @@ Preferences
 There are a couple of preferences associated with the remote agent:
 
 
 Configurable preferences
 ------------------------
 
 ### `remote.enabled`
 
-Indicates whether the remote agent is enabled.  When the remote agent
-is enabled, it exposes a `--debug` flag for Firefox.  When set to
-false, the remote agent will not be loaded on startup.
+Indicates whether the remote agent is enabled.  When the remote
+agent is enabled, it exposes a `--remote-debugger` flag for Firefox.
+When set to false, the remote agent will not be loaded on startup.
 
 ### `remote.force-local`
 
 Limits the remote agent to be allowed to listen on loopback devices,
 e.g. 127.0.0.1, localhost, and ::1.
 
 ### `remote.log.level`
 
@@ -37,15 +37,15 @@ HTTPD frontend:
 Scheme the server is listening on, e.g. `httpd`.
 
 ### `remote.httpd.host`
 
 Hostname the server is bound to.
 
 ### `remote.httpd.port`
 
-The port bound by the server.  When starting Firefox with `--debug`
-you can ask the remote agent to listen on port 0 to have the system
-atomically allocate a free port.  You can then later check this
-preference to find out on what port it is listening:
+The port bound by the server.  When starting Firefox with
+`--remote-debugger` you can ask the remote agent to listen on port
+0 to have the system atomically allocate a free port.  You can then
+later check this preference to find out on what port it is listening:
 
-	./firefox --debug :0
+	./firefox --remote-debugger :0
 	1548002326113	RemoteAgent	INFO	Remote debugging agent listening on http://localhost:16738/