Log outgoing transactions/replies over 300kB.

There's some occurences of a transaction just under 1 MB into
system_server, which causes system_server to reject other transactions,
and sometimes throw DeadSystemException.

Until we have better backend infrastructure in place, at least log the
source and some data of really large transactions, which might give us
some sort of clue.

Bug: 198380036
Bug: 213349547
Test: N/A
Change-Id: Ifccf4a2dea32cd43421b61d3003d2a2bdc86ee23
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index ec9d554..0970ca5 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -54,6 +54,8 @@
 constexpr const bool kEnableRpcDevServers = false;
 #endif
 
+// Log any reply transactions for which the data exceeds this size
+#define LOG_REPLIES_OVER_SIZE (300 * 1024)
 // ---------------------------------------------------------------------------
 
 IBinder::IBinder()
@@ -296,6 +298,10 @@
     // In case this is being transacted on in the same process.
     if (reply != nullptr) {
         reply->setDataPosition(0);
+        if (reply->dataSize() > LOG_REPLIES_OVER_SIZE) {
+            ALOGW("Large reply transaction of %zu bytes, interface descriptor %s, code %d",
+                  reply->dataSize(), String8(getInterfaceDescriptor()).c_str(), code);
+        }
     }
 
     return err;