diff options
| author | 2019-09-26 09:26:35 -0700 | |
|---|---|---|
| committer | 2019-09-26 09:26:35 -0700 | |
| commit | 1c60e12b9d3bb779a664fb079a565cd1a2fd21e6 (patch) | |
| tree | 641349f8c2c3230d42ef8a6ebff3cdab694505a3 /libs | |
| parent | 03068f48f2ef13d1ebd9af01044c766b54dd9cb8 (diff) | |
| parent | 0e8a145380074762a98d0bc463a599ef4b3d296e (diff) | |
Merge changes I1893a45e,I29bf9acf am: ca5868f882
am: 0e8a145380
Change-Id: Ibb3b4d5a877b50582f77734c435447471a7fb47d
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/binder/Binder.cpp | 33 | ||||
| -rw-r--r-- | libs/binder/include/binder/Binder.h | 2 | ||||
| -rw-r--r-- | libs/binder/include/binder/IBinder.h | 6 |
3 files changed, 41 insertions, 0 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index 693045e7f3..34b6ea5385 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -99,6 +99,32 @@ status_t IBinder::getExtension(sp<IBinder>* out) { return reply.readNullableStrongBinder(out); } +status_t IBinder::getDebugPid(pid_t* out) { + BBinder* local = this->localBinder(); + if (local != nullptr) { + *out = local->getDebugPid(); + return OK; + } + + BpBinder* proxy = this->remoteBinder(); + LOG_ALWAYS_FATAL_IF(proxy == nullptr); + + Parcel data; + Parcel reply; + status_t status = transact(DEBUG_PID_TRANSACTION, data, &reply); + if (status != OK) return status; + + int32_t pid; + status = reply.readInt32(&pid); + if (status != OK) return status; + + if (pid < 0 || pid > std::numeric_limits<pid_t>::max()) { + return BAD_VALUE; + } + *out = pid; + return OK; +} + // --------------------------------------------------------------------------- class BBinder::Extras @@ -152,6 +178,9 @@ status_t BBinder::transact( case EXTENSION_TRANSACTION: err = reply->writeStrongBinder(getExtension()); break; + case DEBUG_PID_TRANSACTION: + err = reply->writeInt32(getDebugPid()); + break; default: err = onTransact(code, data, reply, flags); break; @@ -250,6 +279,10 @@ sp<IBinder> BBinder::getExtension() { return e->mExtension; } +pid_t BBinder::getDebugPid() { + return getpid(); +} + void BBinder::setExtension(const sp<IBinder>& extension) { Extras* e = getOrCreateExtras(); e->mExtension = extension; diff --git a/libs/binder/include/binder/Binder.h b/libs/binder/include/binder/Binder.h index 1095c7f28c..5673d5a871 100644 --- a/libs/binder/include/binder/Binder.h +++ b/libs/binder/include/binder/Binder.h @@ -68,6 +68,8 @@ public: // This must be called before the object is sent to another process. Not thread safe. void setExtension(const sp<IBinder>& extension); + pid_t getDebugPid(); + protected: virtual ~BBinder(); diff --git a/libs/binder/include/binder/IBinder.h b/libs/binder/include/binder/IBinder.h index 027e088be6..b12723446d 100644 --- a/libs/binder/include/binder/IBinder.h +++ b/libs/binder/include/binder/IBinder.h @@ -59,6 +59,7 @@ public: INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'), SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'), EXTENSION_TRANSACTION = B_PACK_CHARS('_', 'E', 'X', 'T'), + DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'), // Corresponds to TF_ONE_WAY -- an asynchronous call. FLAG_ONEWAY = 0x00000001 @@ -129,6 +130,11 @@ public: */ status_t getExtension(sp<IBinder>* out); + /** + * Dump PID for a binder, for debugging. + */ + status_t getDebugPid(pid_t* outPid); + // NOLINTNEXTLINE(google-default-arguments) virtual status_t transact( uint32_t code, const Parcel& data, |