Loading libs/binder/IPCThreadState.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,7 @@ finish: if (acquireResult) *acquireResult = err; if (reply) reply->setError(err); mLastError = err; logExtendedError(); } return err; Loading Loading @@ -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*/, Loading libs/binder/ProcessState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -415,6 +415,8 @@ bool ProcessState::isDriverFeatureEnabled(const DriverFeature feature) { static const char* const names[] = { [static_cast<int>(DriverFeature::ONEWAY_SPAM_DETECTION)] = DRIVER_FEATURES_PATH "oneway_spam_detection", [static_cast<int>(DriverFeature::EXTENDED_ERROR)] = DRIVER_FEATURES_PATH "extended_error", }; int fd = open(names[static_cast<int>(feature)], O_RDONLY | O_CLOEXEC); char on; Loading libs/binder/binder_module.h +19 −0 Original line number Diff line number Diff line Loading @@ -100,4 +100,23 @@ struct binder_frozen_status_info { #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) #endif // BINDER_ENABLE_ONEWAY_SPAM_DETECTION #ifndef BINDER_GET_EXTENDED_ERROR /* struct binder_extened_error - extended error information * @id: identifier for the failed operation * @command: command as defined by binder_driver_return_protocol * @param: parameter holding a negative errno value * * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information * returned by the driver upon a failed operation. Userspace can pull this * data to properly handle specific error scenarios. */ struct binder_extended_error { __u32 id; __u32 command; __s32 param; }; #define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error) #endif // BINDER_GET_EXTENDED_ERROR #endif // _BINDER_MODULE_H_ libs/binder/include/binder/IPCThreadState.h +1 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ private: static void freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize, const binder_size_t* objects, size_t objectsSize); static void logExtendedError(); const sp<ProcessState> mProcess; Vector<BBinder*> mPendingStrongDerefs; Loading libs/binder/include/binder/ProcessState.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ public: enum class DriverFeature { ONEWAY_SPAM_DETECTION, EXTENDED_ERROR, }; // Determine whether a feature is supported by the binder driver. static bool isDriverFeatureEnabled(const DriverFeature feature); Loading Loading
libs/binder/IPCThreadState.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -989,6 +989,7 @@ finish: if (acquireResult) *acquireResult = err; if (reply) reply->setError(err); mLastError = err; logExtendedError(); } return err; Loading Loading @@ -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*/, Loading
libs/binder/ProcessState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -415,6 +415,8 @@ bool ProcessState::isDriverFeatureEnabled(const DriverFeature feature) { static const char* const names[] = { [static_cast<int>(DriverFeature::ONEWAY_SPAM_DETECTION)] = DRIVER_FEATURES_PATH "oneway_spam_detection", [static_cast<int>(DriverFeature::EXTENDED_ERROR)] = DRIVER_FEATURES_PATH "extended_error", }; int fd = open(names[static_cast<int>(feature)], O_RDONLY | O_CLOEXEC); char on; Loading
libs/binder/binder_module.h +19 −0 Original line number Diff line number Diff line Loading @@ -100,4 +100,23 @@ struct binder_frozen_status_info { #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) #endif // BINDER_ENABLE_ONEWAY_SPAM_DETECTION #ifndef BINDER_GET_EXTENDED_ERROR /* struct binder_extened_error - extended error information * @id: identifier for the failed operation * @command: command as defined by binder_driver_return_protocol * @param: parameter holding a negative errno value * * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information * returned by the driver upon a failed operation. Userspace can pull this * data to properly handle specific error scenarios. */ struct binder_extended_error { __u32 id; __u32 command; __s32 param; }; #define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error) #endif // BINDER_GET_EXTENDED_ERROR #endif // _BINDER_MODULE_H_
libs/binder/include/binder/IPCThreadState.h +1 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ private: static void freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize, const binder_size_t* objects, size_t objectsSize); static void logExtendedError(); const sp<ProcessState> mProcess; Vector<BBinder*> mPendingStrongDerefs; Loading
libs/binder/include/binder/ProcessState.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ public: enum class DriverFeature { ONEWAY_SPAM_DETECTION, EXTENDED_ERROR, }; // Determine whether a feature is supported by the binder driver. static bool isDriverFeatureEnabled(const DriverFeature feature); Loading