summaryrefslogtreecommitdiff
path: root/libs/binder/IPCThreadState.cpp
diff options
context:
space:
mode:
author Carlos Llamas <cmllamas@google.com> 2021-12-20 06:38:44 -0800
committer Carlos Llamas <cmllamas@google.com> 2022-05-10 04:18:19 +0000
commitb235b12c02b3dfcf807c1c14b4342bbf0e502858 (patch)
tree79cf966378e1917285d355be39bbb3d12da40de2 /libs/binder/IPCThreadState.cpp
parent864034bf750090c0522ba6a3cd1abb379999ba6e (diff)
libbinder: add BINDER_GET_EXTENDED_ERROR support
This adds basic support to pull extended error information provided by the driver via BINDER_GET_EXTENDED_ERROR ioctl. For now, we'll only log the information upon a failed transaction. However, this data can later be used to handle error scenarios such as retry strategies. Bug: 28321379 Test: atest binderLibTest Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: I8aed63cb0d1aa15aa96db4ab8999e300fef1f505
Diffstat (limited to 'libs/binder/IPCThreadState.cpp')
-rw-r--r--libs/binder/IPCThreadState.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 3c97dcab93..d453ac7532 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -989,6 +989,7 @@ finish:
if (acquireResult) *acquireResult = err;
if (reply) reply->setError(err);
mLastError = err;
+ logExtendedError();
}
return err;
@@ -1443,6 +1444,23 @@ status_t IPCThreadState::freeze(pid_t pid, bool enable, uint32_t timeout_ms) {
return ret;
}
+void IPCThreadState::logExtendedError() {
+ struct binder_extended_error ee = {.command = BR_OK};
+
+ if (!ProcessState::isDriverFeatureEnabled(ProcessState::DriverFeature::EXTENDED_ERROR))
+ return;
+
+#if defined(__ANDROID__)
+ if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_EXTENDED_ERROR, &ee) < 0) {
+ ALOGE("Failed to get extended error: %s", strerror(errno));
+ return;
+ }
+#endif
+
+ ALOGE_IF(ee.command != BR_OK, "Binder transaction failure: %d/%d/%d",
+ ee.id, ee.command, ee.param);
+}
+
void IPCThreadState::freeBuffer(Parcel* parcel, const uint8_t* data,
size_t /*dataSize*/,
const binder_size_t* /*objects*/,