Loading cmds/atrace/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ cc_binary { "libz", "libbase", ], static_libs: [ "libpdx_default_transport", ], init_rc: ["atrace.rc"], Loading cmds/atrace/atrace.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include <android/hidl/manager/1.0/IServiceManager.h> #include <hidl/ServiceManagement.h> #include <pdx/default_transport/service_utility.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/Tokenizer.h> Loading @@ -50,6 +51,7 @@ #include <android-base/stringprintf.h> using namespace android; using pdx::default_transport::ServiceUtility; using std::string; Loading @@ -61,6 +63,7 @@ const char* k_traceTagsProperty = "debug.atrace.tags.enableflags"; const char* k_traceAppsNumberProperty = "debug.atrace.app_number"; const char* k_traceAppsPropertyTemplate = "debug.atrace.app_%d"; const char* k_coreServiceCategory = "core_services"; const char* k_pdxServiceCategory = "pdx"; const char* k_coreServicesProp = "ro.atrace.core.services"; typedef enum { OPT, REQ } requiredness ; Loading Loading @@ -114,6 +117,7 @@ static const TracingCategory k_categories[] = { { "network", "Network", ATRACE_TAG_NETWORK, { } }, { "adb", "ADB", ATRACE_TAG_ADB, { } }, { k_coreServiceCategory, "Core services", 0, { } }, { k_pdxServiceCategory, "PDX services", 0, { } }, { "sched", "CPU Scheduling", 0, { { REQ, "events/sched/sched_switch/enable" }, { REQ, "events/sched/sched_wakeup/enable" }, Loading Loading @@ -210,6 +214,7 @@ static const char* g_debugAppCmdLine = ""; static const char* g_outputFile = nullptr; /* Global state */ static bool g_tracePdx = false; static bool g_traceAborted = false; static bool g_categoryEnables[arraysize(k_categories)] = {}; static std::string g_traceFolder; Loading Loading @@ -369,6 +374,10 @@ static bool isCategorySupported(const TracingCategory& category) return !android::base::GetProperty(k_coreServicesProp, "").empty(); } if (strcmp(category.name, k_pdxServiceCategory) == 0) { return true; } bool ok = category.tags != 0; for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; Loading Loading @@ -791,6 +800,11 @@ static bool setUpTrace() if (strcmp(k_categories[i].name, k_coreServiceCategory) == 0) { coreServicesTagEnabled = g_categoryEnables[i]; } // Set whether to poke PDX services in this session. if (strcmp(k_categories[i].name, k_pdxServiceCategory) == 0) { g_tracePdx = g_categoryEnables[i]; } } std::string packageList(g_debugAppCmdLine); Loading @@ -804,6 +818,10 @@ static bool setUpTrace() ok &= pokeBinderServices(); pokeHalServices(); if (g_tracePdx) { ok &= ServiceUtility::PokeServices(); } // Disable all the sysfs enables. This is done as a separate loop from // the enables to allow the same enable to exist in multiple categories. ok &= disableKernelTraceEvents(); Loading Loading @@ -841,6 +859,10 @@ static void cleanUpTrace() clearAppProperties(); pokeBinderServices(); if (g_tracePdx) { ServiceUtility::PokeServices(); } // Set the options back to their defaults. setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); Loading Loading
cmds/atrace/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ cc_binary { "libz", "libbase", ], static_libs: [ "libpdx_default_transport", ], init_rc: ["atrace.rc"], Loading
cmds/atrace/atrace.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include <android/hidl/manager/1.0/IServiceManager.h> #include <hidl/ServiceManagement.h> #include <pdx/default_transport/service_utility.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/Tokenizer.h> Loading @@ -50,6 +51,7 @@ #include <android-base/stringprintf.h> using namespace android; using pdx::default_transport::ServiceUtility; using std::string; Loading @@ -61,6 +63,7 @@ const char* k_traceTagsProperty = "debug.atrace.tags.enableflags"; const char* k_traceAppsNumberProperty = "debug.atrace.app_number"; const char* k_traceAppsPropertyTemplate = "debug.atrace.app_%d"; const char* k_coreServiceCategory = "core_services"; const char* k_pdxServiceCategory = "pdx"; const char* k_coreServicesProp = "ro.atrace.core.services"; typedef enum { OPT, REQ } requiredness ; Loading Loading @@ -114,6 +117,7 @@ static const TracingCategory k_categories[] = { { "network", "Network", ATRACE_TAG_NETWORK, { } }, { "adb", "ADB", ATRACE_TAG_ADB, { } }, { k_coreServiceCategory, "Core services", 0, { } }, { k_pdxServiceCategory, "PDX services", 0, { } }, { "sched", "CPU Scheduling", 0, { { REQ, "events/sched/sched_switch/enable" }, { REQ, "events/sched/sched_wakeup/enable" }, Loading Loading @@ -210,6 +214,7 @@ static const char* g_debugAppCmdLine = ""; static const char* g_outputFile = nullptr; /* Global state */ static bool g_tracePdx = false; static bool g_traceAborted = false; static bool g_categoryEnables[arraysize(k_categories)] = {}; static std::string g_traceFolder; Loading Loading @@ -369,6 +374,10 @@ static bool isCategorySupported(const TracingCategory& category) return !android::base::GetProperty(k_coreServicesProp, "").empty(); } if (strcmp(category.name, k_pdxServiceCategory) == 0) { return true; } bool ok = category.tags != 0; for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; Loading Loading @@ -791,6 +800,11 @@ static bool setUpTrace() if (strcmp(k_categories[i].name, k_coreServiceCategory) == 0) { coreServicesTagEnabled = g_categoryEnables[i]; } // Set whether to poke PDX services in this session. if (strcmp(k_categories[i].name, k_pdxServiceCategory) == 0) { g_tracePdx = g_categoryEnables[i]; } } std::string packageList(g_debugAppCmdLine); Loading @@ -804,6 +818,10 @@ static bool setUpTrace() ok &= pokeBinderServices(); pokeHalServices(); if (g_tracePdx) { ok &= ServiceUtility::PokeServices(); } // Disable all the sysfs enables. This is done as a separate loop from // the enables to allow the same enable to exist in multiple categories. ok &= disableKernelTraceEvents(); Loading Loading @@ -841,6 +859,10 @@ static void cleanUpTrace() clearAppProperties(); pokeBinderServices(); if (g_tracePdx) { ServiceUtility::PokeServices(); } // Set the options back to their defaults. setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); Loading