Bug 1433968 - Support pause-for-debugger in GeckoRuntime r=jchen
☠☠ backed out by 3e7ffd532e0a ☠ ☠
authorJames Willcox <snorp@snorp.net>
Wed, 09 May 2018 09:26:35 -0500
changeset 417747 c94c48d763506bc36126b95e6073f62c757a085b
parent 417746 64cccb490a2a93cf744421cf37c485415df44798
child 417748 7a8616427aea19089fffd9423577751deae186e2
push id33979
push userdluca@mozilla.com
push dateThu, 10 May 2018 21:59:38 +0000
treeherdermozilla-central@aabfe960ab59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1433968
milestone62.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 1433968 - Support pause-for-debugger in GeckoRuntime r=jchen MozReview-Commit-ID: FY7HI0c38DU
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -92,16 +92,20 @@ public final class GeckoRuntime implemen
         if (settings.getNativeCrashReportingEnabled()) {
             flags |= GeckoThread.FLAG_ENABLE_NATIVE_CRASHREPORTER;
         }
 
         if (settings.getJavaCrashReportingEnabled()) {
             flags |= GeckoThread.FLAG_ENABLE_JAVA_CRASHREPORTER;
         }
 
+        if (settings.getPauseForDebuggerEnabled()) {
+            flags |= GeckoThread.FLAG_DEBUGGING;
+        }
+
         if (GeckoThread.initMainProcess(/* profile */ null,
                                         settings.getArguments(),
                                         settings.getExtras(),
                                         flags)) {
             if (!GeckoThread.launch()) {
                 Log.d(LOGTAG, "init failed (GeckoThread already launched)");
                 return false;
             }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -134,16 +134,29 @@ public final class GeckoRuntimeSettings 
          * @param enabled A flag determining whether Java crash reporting should be enabled.
          *                Defaults to false.
          * @return This Builder.
          */
         public @NonNull Builder javaCrashReportingEnabled(final boolean enabled) {
             mSettings.mJavaCrashReporting = enabled;
             return this;
         }
+
+        /**
+         * Set whether there should be a pause during startup. This is useful if you need to
+         * wait for a debugger to attach.
+         *
+         * @param enabled A flag determining whether there will be a pause early in startup.
+         *                Defaults to false.
+         * @return This Builder.
+         */
+        public @NonNull Builder pauseForDebugger(boolean enabled) {
+            mSettings.mDebugPause = enabled;
+            return this;
+        }
     }
 
     /* package */ GeckoRuntime runtime;
     /* package */ boolean mUseContentProcess;
     /* package */ String[] mArgs;
     /* package */ Bundle mExtras;
     /* package */ int prefCount;
 
@@ -179,16 +192,17 @@ public final class GeckoRuntimeSettings 
     /* package */ Pref<Boolean> mJavaScript = new Pref<Boolean>(
         "javascript.enabled", true);
     /* package */ Pref<Boolean> mRemoteDebugging = new Pref<Boolean>(
         "devtools.debugger.remote-enabled", false);
     /* package */ Pref<Boolean> mWebFonts = new Pref<Boolean>(
         "browser.display.use_document_fonts", true);
     /* package */ boolean mNativeCrashReporting;
     /* package */ boolean mJavaCrashReporting;
+    /* package */ boolean mDebugPause;
 
     private final Pref<?>[] mPrefs = new Pref<?>[] {
         mJavaScript, mRemoteDebugging, mWebFonts
     };
 
     /* package */ GeckoRuntimeSettings() {
         this(null);
     }
@@ -325,16 +339,23 @@ public final class GeckoRuntimeSettings 
      * Get whether Java crash reporting is enabled or not.
      *
      * @return True if Java crash reporting is enabled.
      */
     public boolean getJavaCrashReportingEnabled() {
         return mJavaCrashReporting;
     }
 
+    /**
+     * Gets whether the pause-for-debugger is enabled or not.
+     *
+     * @return True if the pause is enabled.
+     */
+    public boolean getPauseForDebuggerEnabled() { return mDebugPause; }
+
     @Override // Parcelable
     public int describeContents() {
         return 0;
     }
 
     @Override // Parcelable
     public void writeToParcel(Parcel out, int flags) {
         ParcelableUtils.writeBoolean(out, mUseContentProcess);
@@ -342,16 +363,17 @@ public final class GeckoRuntimeSettings 
         mExtras.writeToParcel(out, flags);
 
         for (final Pref<?> pref : mPrefs) {
             out.writeValue(pref.get());
         }
 
         ParcelableUtils.writeBoolean(out, mNativeCrashReporting);
         ParcelableUtils.writeBoolean(out, mJavaCrashReporting);
+        ParcelableUtils.writeBoolean(out, mDebugPause);
     }
 
     // AIDL code may call readFromParcel even though it's not part of Parcelable.
     public void readFromParcel(final Parcel source) {
         mUseContentProcess = ParcelableUtils.readBoolean(source);
         mArgs = source.createStringArray();
         mExtras.readFromParcel(source);
 
@@ -359,16 +381,17 @@ public final class GeckoRuntimeSettings 
             // We know this is safe.
             @SuppressWarnings("unchecked")
             final Pref<Object> uncheckedPref = (Pref<Object>) pref;
             uncheckedPref.set(source.readValue(getClass().getClassLoader()));
         }
 
         mNativeCrashReporting = ParcelableUtils.readBoolean(source);
         mJavaCrashReporting = ParcelableUtils.readBoolean(source);
+        mJavaCrashReporting = ParcelableUtils.readBoolean(source);
     }
 
     public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
         = new Parcelable.Creator<GeckoRuntimeSettings>() {
         @Override
         public GeckoRuntimeSettings createFromParcel(final Parcel in) {
             final GeckoRuntimeSettings settings = new GeckoRuntimeSettings();
             settings.readFromParcel(in);