diff options
| author | 2021-08-10 17:45:42 +0000 | |
|---|---|---|
| committer | 2021-08-10 17:45:42 +0000 | |
| commit | 66cce72d877c035c46f823c41d43f560c23c32be (patch) | |
| tree | 719f63cf1d7245394e2ed5b3ca1a45ca897f0718 /libs/binderdebug/BinderDebug.cpp | |
| parent | 7aaabba1a0f900f9177478bbc9ef7181710a0850 (diff) | |
| parent | b006f68034c5250d0b7c6a30d8b935f3a15825ba (diff) | |
Merge changes I0daebc18,I87df46d1 am: b438f33e52 am: 42a6861398 am: e7ddbe0b99 am: 12c4b01f8b am: b006f68034
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1788708
Change-Id: I6e80c4ca28f6f56f1257a9cfffe1f64a20f60fac
Diffstat (limited to 'libs/binderdebug/BinderDebug.cpp')
| -rw-r--r-- | libs/binderdebug/BinderDebug.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libs/binderdebug/BinderDebug.cpp b/libs/binderdebug/BinderDebug.cpp index b435dba197..d086b49a7b 100644 --- a/libs/binderdebug/BinderDebug.cpp +++ b/libs/binderdebug/BinderDebug.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/strings.h> #include <binder/Binder.h> @@ -116,4 +117,60 @@ status_t getBinderPidInfo(BinderDebugContext context, pid_t pid, BinderPidInfo* return ret; } +status_t getBinderClientPids(BinderDebugContext context, pid_t pid, pid_t servicePid, + int32_t handle, std::vector<pid_t>* pids) { + std::smatch match; + static const std::regex kNodeNumber("^\\s+ref \\d+:\\s+desc\\s+(\\d+)\\s+node\\s+(\\d+).*"); + std::string contextStr = contextToString(context); + int32_t node; + status_t ret = scanBinderContext(pid, contextStr, [&](const std::string& line) { + if (std::regex_search(line, match, kNodeNumber)) { + const std::string& descString = match.str(1); + int32_t desc; + if (!::android::base::ParseInt(descString.c_str(), &desc)) { + LOG(ERROR) << "Failed to parse desc int: " << descString; + return; + } + if (handle != desc) { + return; + } + const std::string& nodeString = match.str(2); + if (!::android::base::ParseInt(nodeString.c_str(), &node)) { + LOG(ERROR) << "Failed to parse node int: " << nodeString; + return; + } + return; + } + return; + }); + if (ret != OK) { + return ret; + } + static const std::regex kClients("^\\s+node\\s+(\\d+).*proc\\s+([\\d+\\s*]*)"); + ret = scanBinderContext(servicePid, contextStr, [&](const std::string& line) { + if (std::regex_search(line, match, kClients)) { + const std::string nodeString = match.str(1); + int32_t matchedNode; + if (!::android::base::ParseInt(nodeString.c_str(), &matchedNode)) { + LOG(ERROR) << "Failed to parse node int: " << nodeString; + return; + } + if (node != matchedNode) { + return; + } + const std::string clients = match.str(2); + for (const std::string& pidStr : base::Split(clients, " ")) { + int32_t pid; + if (!::android::base::ParseInt(pidStr, &pid)) { + return; + } + pids->push_back(pid); + } + return; + } + return; + }); + return ret; +} + } // namespace android |