OSDN Git Service

Dump proxy debug info when exceeding proxy limit.
authorMartijn Coenen <maco@google.com>
Fri, 25 May 2018 17:28:26 +0000 (19:28 +0200)
committerMartijn Coenen <maco@google.com>
Fri, 25 May 2018 18:13:24 +0000 (20:13 +0200)
If a process gets killed because it sends too many proxies,
dump proxy debug info so we can see what types of interfaces
it sends.

Bug: 71353150
Test: builds, output generated
Change-Id: I3a7787cb3fa73b0b4ad223b18cd79f44e22b9ef5

core/java/android/os/Binder.java
services/core/java/com/android/server/am/ActivityManagerService.java

index 0ae5394..3d76c25 100644 (file)
@@ -138,6 +138,15 @@ public class Binder implements IBinder {
     }
 
     /**
+     * Dump proxy debug information.
+     *
+     * @hide
+     */
+    public static void dumpProxyDebugInfo() {
+        BinderProxy.dumpProxyDebugInfo();
+    }
+
+    /**
      * Check if binder transaction tracing is enabled.
      *
      * @hide
@@ -941,8 +950,7 @@ final class BinderProxy implements IBinder {
                     // about to crash.
                     final int totalUnclearedSize = unclearedSize();
                     if (totalUnclearedSize >= CRASH_AT_SIZE) {
-                        dumpProxyInterfaceCounts();
-                        dumpPerUidProxyCounts();
+                        dumpProxyDebugInfo();
                         Runtime.getRuntime().gc();
                         throw new AssertionError("Binder ProxyMap has too many entries: "
                                 + totalSize + " (total), " + totalUnclearedSize + " (uncleared), "
@@ -1027,6 +1035,14 @@ final class BinderProxy implements IBinder {
     private static ProxyMap sProxyMap = new ProxyMap();
 
     /**
+      * @hide
+      */
+    public static void dumpProxyDebugInfo() {
+        sProxyMap.dumpProxyInterfaceCounts();
+        sProxyMap.dumpPerUidProxyCounts();
+    }
+
+    /**
      * Return a BinderProxy for IBinder.
      * This method is thread-hostile!  The (native) caller serializes getInstance() calls using
      * gProxyLock.
index 98bf740..936e2ce 100644 (file)
@@ -15304,6 +15304,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                         public void onLimitReached(int uid) {
                             Slog.wtf(TAG, "Uid " + uid + " sent too many Binders to uid "
                                     + Process.myUid());
+                            Binder.dumpProxyDebugInfo();
                             if (uid == Process.SYSTEM_UID) {
                                 Slog.i(TAG, "Skipping kill (uid is SYSTEM)");
                             } else {