Move proxy debug info dumping back to Java.

This had to be called from native because serialization
was done from native, but now that serialization is in Java
we can move this back to a more logical place.

Also, this allows us to dump the per-UID proxy counts in
this situation again.

Bug: 109888955
Test: sailfish builds, proxy debug info shown on hitting limits
Merged-In: I4e06b3f93e30ed1c7868ec9e018709a7e796e441
Change-Id: I4e06b3f93e30ed1c7868ec9e018709a7e796e441
This commit is contained in:
Martijn Coenen
2018-07-06 12:04:48 +02:00
committed by Andreas Gampe
parent 345d4c16bb
commit c1493b283b
3 changed files with 6 additions and 21 deletions

View File

@@ -353,13 +353,12 @@ public final class BinderProxy implements IBinder {
*
* @hide
*/
private static void dumpProxyDebugInfo() {
public static void dumpProxyDebugInfo() {
if (Build.IS_DEBUGGABLE) {
sProxyMap.dumpProxyInterfaceCounts();
// Note that we don't call dumpPerUidProxyCounts(); this is because this
// method may be called as part of the uid limit being hit, and calling
// back into the UID tracking code would cause us to try to acquire a mutex
// that is held during that callback.
synchronized (sProxyMap) {
sProxyMap.dumpProxyInterfaceCounts();
sProxyMap.dumpPerUidProxyCounts();
}
}
}

View File

@@ -110,7 +110,6 @@ static struct binderproxy_offsets_t
jclass mClass;
jmethodID mGetInstance;
jmethodID mSendDeathNotice;
jmethodID mDumpProxyDebugInfo;
// Object state.
jfieldID mNativeData; // Field holds native pointer to BinderProxyNativeData.
@@ -1038,18 +1037,6 @@ static void android_os_BinderInternal_handleGc(JNIEnv* env, jobject clazz)
static void android_os_BinderInternal_proxyLimitcallback(int uid)
{
JNIEnv *env = AndroidRuntime::getJNIEnv();
{
// Calls into BinderProxy must be serialized
AutoMutex _l(gProxyLock);
env->CallStaticObjectMethod(gBinderProxyOffsets.mClass,
gBinderProxyOffsets.mDumpProxyDebugInfo);
}
if (env->ExceptionCheck()) {
ScopedLocalRef<jthrowable> excep(env, env->ExceptionOccurred());
report_exception(env, excep.get(),
"*** Uncaught exception in dumpProxyDebugInfo");
}
env->CallStaticVoidMethod(gBinderInternalOffsets.mClass,
gBinderInternalOffsets.mProxyLimitCallback,
uid);
@@ -1439,8 +1426,6 @@ static int int_register_android_os_BinderProxy(JNIEnv* env)
"(JJ)Landroid/os/BinderProxy;");
gBinderProxyOffsets.mSendDeathNotice = GetStaticMethodIDOrDie(env, clazz, "sendDeathNotice",
"(Landroid/os/IBinder$DeathRecipient;)V");
gBinderProxyOffsets.mDumpProxyDebugInfo = GetStaticMethodIDOrDie(env, clazz, "dumpProxyDebugInfo",
"()V");
gBinderProxyOffsets.mNativeData = GetFieldIDOrDie(env, clazz, "mNativeData", "J");
clazz = FindClassOrDie(env, "java/lang/Class");

View File

@@ -15211,6 +15211,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());
BinderProxy.dumpProxyDebugInfo();
if (uid == Process.SYSTEM_UID) {
Slog.i(TAG, "Skipping kill (uid is SYSTEM)");
} else {