diff options
author | Shukang Zhou <shukang@google.com> | 2020-02-13 17:01:39 -0800 |
---|---|---|
committer | Shukang Zhou <shukang@google.com> | 2020-03-06 13:56:27 -0800 |
commit | 420ad5564a4189128d79f7efe1ffe6bba9ea9d2e (patch) | |
tree | 11e098addc26dff7bbcd2843f5365e41ecaebc05 /libs/adbconnection/adbconnection_server.cpp | |
parent | 43a95f19255333cb68b6a0a724707faf867a79aa (diff) | |
download | adb-420ad5564a4189128d79f7efe1ffe6bba9ea9d2e.tar.gz |
"track-app" service showing debuggable/profileable apps
Add a "track-app" service in adbd. For every debuggable or
profileable-from-shell process, ART sends related info to
adbd and adbd surfaces the info through the "track-app"
service.
The output format of "track-app" is a line summarizing
the number of reported processes, followed by a protobuf
message in human readable form. For example,
Process count: 2
process {
pid: 3307
profileable: true
architecture: "arm64"
}
process {
pid: 3341
debuggable: true
profileable: true
architecture: "arm64"
}
Bug: 149050485
Test: manually unplugged/replugged, "adb track-app",
"adb track-jdwp"
Change-Id: Id1f1a920e1afc148c7e4d2add790baab796178e1
Diffstat (limited to 'libs/adbconnection/adbconnection_server.cpp')
-rw-r--r-- | libs/adbconnection/adbconnection_server.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libs/adbconnection/adbconnection_server.cpp b/libs/adbconnection/adbconnection_server.cpp index 939da2f6..aac9615e 100644 --- a/libs/adbconnection/adbconnection_server.cpp +++ b/libs/adbconnection/adbconnection_server.cpp @@ -28,6 +28,8 @@ #include <android-base/logging.h> #include <android-base/unique_fd.h> +#include "adbconnection/process_info.h" + using android::base::unique_fd; #define JDWP_CONTROL_NAME "\0jdwp-control" @@ -36,7 +38,7 @@ using android::base::unique_fd; static_assert(JDWP_CONTROL_NAME_LEN <= sizeof(reinterpret_cast<sockaddr_un*>(0)->sun_path)); // Listen for incoming jdwp clients forever. -void adbconnection_listen(void (*callback)(int fd, pid_t pid)) { +void adbconnection_listen(void (*callback)(int fd, ProcessInfo process)) { sockaddr_un addr = {}; socklen_t addrlen = JDWP_CONTROL_NAME_LEN + sizeof(addr.sun_family); @@ -106,16 +108,13 @@ void adbconnection_listen(void (*callback)(int fd, pid_t pid)) { << ") in pending connections"; } - // Massively oversized buffer: we're expecting an int32_t from the other end. - char buf[32]; - int rc = TEMP_FAILURE_RETRY(recv(it->get(), buf, sizeof(buf), MSG_DONTWAIT)); - if (rc != 4) { + ProcessInfo process; + int rc = TEMP_FAILURE_RETRY(recv(it->get(), &process, sizeof(process), MSG_DONTWAIT)); + if (rc != sizeof(process)) { LOG(ERROR) << "received data of incorrect size from JDWP client: read " << rc - << ", expected 4"; + << ", expected " << sizeof(process); } else { - int32_t pid; - memcpy(&pid, buf, sizeof(pid)); - callback(it->release(), static_cast<pid_t>(pid)); + callback(it->release(), process); } if (epoll_ctl(epfd.get(), EPOLL_CTL_DEL, event.data.fd, nullptr) != 0) { |