Loading cmds/dumpstate/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ cc_defaults { "libhidlbase", "liblog", "libutils", "libbinderdebug", ], srcs: [ "DumpstateService.cpp", Loading cmds/dumpsys/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ cc_defaults { "libutils", "liblog", "libbinder", "libbinderdebug", ], static_libs: [ Loading cmds/dumpsys/dumpsys.cpp +28 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <binder/Parcel.h> #include <binder/ProcessState.h> #include <binder/TextOutput.h> #include <binderdebug/BinderDebug.h> #include <serviceutils/PriorityDumper.h> #include <utils/Log.h> #include <utils/Vector.h> Loading Loading @@ -60,13 +61,15 @@ static void usage() { "usage: dumpsys\n" " To dump all services.\n" "or:\n" " dumpsys [-t TIMEOUT] [--priority LEVEL] [--pid] [--help | -l | --skip SERVICES " " dumpsys [-t TIMEOUT] [--priority LEVEL] [--pid] [--thread] [--help | -l | " "--skip SERVICES " "| SERVICE [ARGS]]\n" " --help: shows this help\n" " -l: only list services, do not dump them\n" " -t TIMEOUT_SEC: TIMEOUT to use in seconds instead of default 10 seconds\n" " -T TIMEOUT_MS: TIMEOUT to use in milliseconds instead of default 10 seconds\n" " --pid: dump PID instead of usual dump\n" " --thread: dump thread usage instead of usual dump\n" " --proto: filter services that support dumping data in proto format. Dumps\n" " will be in proto format.\n" " --priority LEVEL: filter services based on specified priority\n" Loading Loading @@ -125,7 +128,8 @@ int Dumpsys::main(int argc, char* const argv[]) { Type type = Type::DUMP; int timeoutArgMs = 10000; int priorityFlags = IServiceManager::DUMP_FLAG_PRIORITY_ALL; static struct option longOptions[] = {{"pid", no_argument, 0, 0}, static struct option longOptions[] = {{"thread", no_argument, 0, 0}, {"pid", no_argument, 0, 0}, {"priority", required_argument, 0, 0}, {"proto", no_argument, 0, 0}, {"skip", no_argument, 0, 0}, Loading Loading @@ -163,6 +167,8 @@ int Dumpsys::main(int argc, char* const argv[]) { } } else if (!strcmp(longOptions[optionIndex].name, "pid")) { type = Type::PID; } else if (!strcmp(longOptions[optionIndex].name, "thread")) { type = Type::THREAD; } break; Loading Loading @@ -329,6 +335,23 @@ static status_t dumpPidToFd(const sp<IBinder>& service, const unique_fd& fd) { return OK; } static status_t dumpThreadsToFd(const sp<IBinder>& service, const unique_fd& fd) { pid_t pid; status_t status = service->getDebugPid(&pid); if (status != OK) { return status; } BinderPidInfo pidInfo; status = getBinderPidInfo(BinderDebugContext::BINDER, pid, &pidInfo); if (status != OK) { return status; } WriteStringToFd("Threads in use: " + std::to_string(pidInfo.threadUsage) + "/" + std::to_string(pidInfo.threadCount) + "\n", fd.get()); return OK; } status_t Dumpsys::startDumpThread(Type type, const String16& serviceName, const Vector<String16>& args) { sp<IBinder> service = sm_->checkService(serviceName); Loading Loading @@ -359,6 +382,9 @@ status_t Dumpsys::startDumpThread(Type type, const String16& serviceName, case Type::PID: err = dumpPidToFd(service, remote_end); break; case Type::THREAD: err = dumpThreadsToFd(service, remote_end); break; default: std::cerr << "Unknown dump type" << static_cast<int>(type) << std::endl; return; Loading cmds/dumpsys/dumpsys.h +4 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class Dumpsys { enum class Type { DUMP, // dump using `dump` function PID, // dump pid of server only THREAD, // dump thread usage of server only }; /** Loading cmds/dumpsys/tests/Android.bp +1 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ cc_test { "libbase", "libbinder", "libutils", "libbinderdebug", ], static_libs: [ Loading @@ -26,6 +27,4 @@ cc_test { "libgmock", "libserviceutils", ], clang: true, } Loading
cmds/dumpstate/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ cc_defaults { "libhidlbase", "liblog", "libutils", "libbinderdebug", ], srcs: [ "DumpstateService.cpp", Loading
cmds/dumpsys/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ cc_defaults { "libutils", "liblog", "libbinder", "libbinderdebug", ], static_libs: [ Loading
cmds/dumpsys/dumpsys.cpp +28 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <binder/Parcel.h> #include <binder/ProcessState.h> #include <binder/TextOutput.h> #include <binderdebug/BinderDebug.h> #include <serviceutils/PriorityDumper.h> #include <utils/Log.h> #include <utils/Vector.h> Loading Loading @@ -60,13 +61,15 @@ static void usage() { "usage: dumpsys\n" " To dump all services.\n" "or:\n" " dumpsys [-t TIMEOUT] [--priority LEVEL] [--pid] [--help | -l | --skip SERVICES " " dumpsys [-t TIMEOUT] [--priority LEVEL] [--pid] [--thread] [--help | -l | " "--skip SERVICES " "| SERVICE [ARGS]]\n" " --help: shows this help\n" " -l: only list services, do not dump them\n" " -t TIMEOUT_SEC: TIMEOUT to use in seconds instead of default 10 seconds\n" " -T TIMEOUT_MS: TIMEOUT to use in milliseconds instead of default 10 seconds\n" " --pid: dump PID instead of usual dump\n" " --thread: dump thread usage instead of usual dump\n" " --proto: filter services that support dumping data in proto format. Dumps\n" " will be in proto format.\n" " --priority LEVEL: filter services based on specified priority\n" Loading Loading @@ -125,7 +128,8 @@ int Dumpsys::main(int argc, char* const argv[]) { Type type = Type::DUMP; int timeoutArgMs = 10000; int priorityFlags = IServiceManager::DUMP_FLAG_PRIORITY_ALL; static struct option longOptions[] = {{"pid", no_argument, 0, 0}, static struct option longOptions[] = {{"thread", no_argument, 0, 0}, {"pid", no_argument, 0, 0}, {"priority", required_argument, 0, 0}, {"proto", no_argument, 0, 0}, {"skip", no_argument, 0, 0}, Loading Loading @@ -163,6 +167,8 @@ int Dumpsys::main(int argc, char* const argv[]) { } } else if (!strcmp(longOptions[optionIndex].name, "pid")) { type = Type::PID; } else if (!strcmp(longOptions[optionIndex].name, "thread")) { type = Type::THREAD; } break; Loading Loading @@ -329,6 +335,23 @@ static status_t dumpPidToFd(const sp<IBinder>& service, const unique_fd& fd) { return OK; } static status_t dumpThreadsToFd(const sp<IBinder>& service, const unique_fd& fd) { pid_t pid; status_t status = service->getDebugPid(&pid); if (status != OK) { return status; } BinderPidInfo pidInfo; status = getBinderPidInfo(BinderDebugContext::BINDER, pid, &pidInfo); if (status != OK) { return status; } WriteStringToFd("Threads in use: " + std::to_string(pidInfo.threadUsage) + "/" + std::to_string(pidInfo.threadCount) + "\n", fd.get()); return OK; } status_t Dumpsys::startDumpThread(Type type, const String16& serviceName, const Vector<String16>& args) { sp<IBinder> service = sm_->checkService(serviceName); Loading Loading @@ -359,6 +382,9 @@ status_t Dumpsys::startDumpThread(Type type, const String16& serviceName, case Type::PID: err = dumpPidToFd(service, remote_end); break; case Type::THREAD: err = dumpThreadsToFd(service, remote_end); break; default: std::cerr << "Unknown dump type" << static_cast<int>(type) << std::endl; return; Loading
cmds/dumpsys/dumpsys.h +4 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class Dumpsys { enum class Type { DUMP, // dump using `dump` function PID, // dump pid of server only THREAD, // dump thread usage of server only }; /** Loading
cmds/dumpsys/tests/Android.bp +1 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ cc_test { "libbase", "libbinder", "libutils", "libbinderdebug", ], static_libs: [ Loading @@ -26,6 +27,4 @@ cc_test { "libgmock", "libserviceutils", ], clang: true, }