binder: add tracing for binder proxies
Test: trace shows binder proxies
Bug: 341083395
Change-Id: Iab43329097488f5de531ab9da46893c9df8e46b5
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 54457fc..7a855e1 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "BpBinder"
+#define ATRACE_TAG ATRACE_TAG_AIDL
//#define LOG_NDEBUG 0
#include <binder/BpBinder.h>
@@ -26,6 +27,12 @@
#include <stdio.h>
+#ifndef __TRUSTY__
+#include <cutils/trace.h>
+#else
+#define ATRACE_INT(...)
+#endif
+
#include "BuildFlags.h"
#include "file.h"
@@ -209,6 +216,7 @@
sTrackingMap[trackedUid]++;
}
uint32_t numProxies = sBinderProxyCount.fetch_add(1, std::memory_order_relaxed);
+ ATRACE_INT("binder_proxies", numProxies);
uint32_t numLastWarned = sBinderProxyCountWarned.load(std::memory_order_relaxed);
uint32_t numNextWarn = numLastWarned + kBinderProxyCountWarnInterval;
if (numProxies >= numNextWarn) {
@@ -632,8 +640,8 @@
}
}
}
- --sBinderProxyCount;
-
+ [[maybe_unused]] uint32_t numProxies = --sBinderProxyCount;
+ ATRACE_INT("binder_proxies", numProxies);
if (ipc) {
ipc->expungeHandle(binderHandle(), this);
ipc->decWeakHandle(binderHandle());