diff options
author | 2022-07-15 16:58:17 +0000 | |
---|---|---|
committer | 2022-07-15 16:58:17 +0000 | |
commit | 857cd25e3da169f31e985d38919c7313be05aaf1 (patch) | |
tree | 136b93d69a4f37dff2c84ca2f5391523588bc4f3 | |
parent | 4477824cc42fd36e03c74e27a03028cefbf82b7a (diff) | |
parent | 3fa3292df51460e937ce7359f0f9afeb551dcfda (diff) |
Merge "libbinder: RPC node toString"
-rw-r--r-- | libs/binder/RpcState.cpp | 39 | ||||
-rw-r--r-- | libs/binder/RpcState.h | 2 |
2 files changed, 24 insertions, 17 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 0ae75cdefa..28730ffc2b 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -258,7 +258,9 @@ void RpcState::clear() { mTerminated = true; for (auto& [address, node] : mNodeForAddress) { sp<IBinder> binder = node.binder.promote(); - LOG_ALWAYS_FATAL_IF(binder == nullptr, "Binder %p expected to be owned.", binder.get()); + LOG_ALWAYS_FATAL_IF(binder == nullptr, + "Binder expected to be owned with address: %" PRIu64 " %s", address, + node.toString().c_str()); if (node.sentRef != nullptr) { tempHoldBinder.push_back(node.sentRef); @@ -275,29 +277,32 @@ void RpcState::dumpLocked() { ALOGE("DUMP OF RpcState %p", this); ALOGE("DUMP OF RpcState (%zu nodes)", mNodeForAddress.size()); for (const auto& [address, node] : mNodeForAddress) { - sp<IBinder> binder = node.binder.promote(); + ALOGE("- address: %" PRIu64 " %s", address, node.toString().c_str()); + } + ALOGE("END DUMP OF RpcState"); +} - const char* desc; - if (binder) { - if (binder->remoteBinder()) { - if (binder->remoteBinder()->isRpcBinder()) { - desc = "(rpc binder proxy)"; - } else { - desc = "(binder proxy)"; - } +std::string RpcState::BinderNode::toString() const { + sp<IBinder> strongBinder = this->binder.promote(); + + const char* desc; + if (strongBinder) { + if (strongBinder->remoteBinder()) { + if (strongBinder->remoteBinder()->isRpcBinder()) { + desc = "(rpc binder proxy)"; } else { - desc = "(local binder)"; + desc = "(binder proxy)"; } } else { - desc = "(null)"; + desc = "(local binder)"; } - - ALOGE("- BINDER NODE: %p times sent:%zu times recd: %zu a: %" PRIu64 " type: %s", - node.binder.unsafe_get(), node.timesSent, node.timesRecd, address, desc); + } else { + desc = "(not promotable)"; } - ALOGE("END DUMP OF RpcState"); -} + return StringPrintf("node{%p times sent: %zu times recd: %zu type: %s}", + this->binder.unsafe_get(), this->timesSent, this->timesRecd, desc); +} RpcState::CommandData::CommandData(size_t size) : mSize(size) { // The maximum size for regular binder is 1MB for all concurrent diff --git a/libs/binder/RpcState.h b/libs/binder/RpcState.h index 6fb2e4a011..892ecd691d 100644 --- a/libs/binder/RpcState.h +++ b/libs/binder/RpcState.h @@ -258,6 +258,8 @@ private: // // (no additional data specific to remote binders) + + std::string toString() const; }; // checks if there is any reference left to a node and erases it. If erase |