Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c5f5779 authored by Corey Tabaka's avatar Corey Tabaka Committed by android-build-merger
Browse files

Restore PDX support to atrace.

am: a6c0a721

Change-Id: I39bd28bde2cad630c8891727670724df3c234ab6
parents 81876de1 a6c0a721
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,9 @@ cc_binary {
        "libz",
        "libz",
        "libbase",
        "libbase",
    ],
    ],
    static_libs: [
        "libpdx_default_transport",
    ],


    init_rc: ["atrace.rc"],
    init_rc: ["atrace.rc"],


+22 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <hidl/ServiceManagement.h>
#include <hidl/ServiceManagement.h>


#include <pdx/default_transport/service_utility.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/Timers.h>
#include <utils/Tokenizer.h>
#include <utils/Tokenizer.h>
@@ -50,6 +51,7 @@
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>


using namespace android;
using namespace android;
using pdx::default_transport::ServiceUtility;


using std::string;
using std::string;


@@ -61,6 +63,7 @@ const char* k_traceTagsProperty = "debug.atrace.tags.enableflags";
const char* k_traceAppsNumberProperty = "debug.atrace.app_number";
const char* k_traceAppsNumberProperty = "debug.atrace.app_number";
const char* k_traceAppsPropertyTemplate = "debug.atrace.app_%d";
const char* k_traceAppsPropertyTemplate = "debug.atrace.app_%d";
const char* k_coreServiceCategory = "core_services";
const char* k_coreServiceCategory = "core_services";
const char* k_pdxServiceCategory = "pdx";
const char* k_coreServicesProp = "ro.atrace.core.services";
const char* k_coreServicesProp = "ro.atrace.core.services";


typedef enum { OPT, REQ } requiredness  ;
typedef enum { OPT, REQ } requiredness  ;
@@ -114,6 +117,7 @@ static const TracingCategory k_categories[] = {
    { "network",    "Network",          ATRACE_TAG_NETWORK, { } },
    { "network",    "Network",          ATRACE_TAG_NETWORK, { } },
    { "adb",        "ADB",              ATRACE_TAG_ADB, { } },
    { "adb",        "ADB",              ATRACE_TAG_ADB, { } },
    { k_coreServiceCategory, "Core services", 0, { } },
    { k_coreServiceCategory, "Core services", 0, { } },
    { k_pdxServiceCategory, "PDX services", 0, { } },
    { "sched",      "CPU Scheduling",   0, {
    { "sched",      "CPU Scheduling",   0, {
        { REQ,      "events/sched/sched_switch/enable" },
        { REQ,      "events/sched/sched_switch/enable" },
        { REQ,      "events/sched/sched_wakeup/enable" },
        { REQ,      "events/sched/sched_wakeup/enable" },
@@ -209,6 +213,7 @@ static const char* g_debugAppCmdLine = "";
static const char* g_outputFile = nullptr;
static const char* g_outputFile = nullptr;


/* Global state */
/* Global state */
static bool g_tracePdx = false;
static bool g_traceAborted = false;
static bool g_traceAborted = false;
static bool g_categoryEnables[arraysize(k_categories)] = {};
static bool g_categoryEnables[arraysize(k_categories)] = {};
static std::string g_traceFolder;
static std::string g_traceFolder;
@@ -368,6 +373,10 @@ static bool isCategorySupported(const TracingCategory& category)
        return !android::base::GetProperty(k_coreServicesProp, "").empty();
        return !android::base::GetProperty(k_coreServicesProp, "").empty();
    }
    }


    if (strcmp(category.name, k_pdxServiceCategory) == 0) {
        return true;
    }

    bool ok = category.tags != 0;
    bool ok = category.tags != 0;
    for (int i = 0; i < MAX_SYS_FILES; i++) {
    for (int i = 0; i < MAX_SYS_FILES; i++) {
        const char* path = category.sysfiles[i].path;
        const char* path = category.sysfiles[i].path;
@@ -790,6 +799,11 @@ static bool setUpTrace()
        if (strcmp(k_categories[i].name, k_coreServiceCategory) == 0) {
        if (strcmp(k_categories[i].name, k_coreServiceCategory) == 0) {
            coreServicesTagEnabled = g_categoryEnables[i];
            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);
    std::string packageList(g_debugAppCmdLine);
@@ -803,6 +817,10 @@ static bool setUpTrace()
    ok &= pokeBinderServices();
    ok &= pokeBinderServices();
    pokeHalServices();
    pokeHalServices();


    if (g_tracePdx) {
        ok &= ServiceUtility::PokeServices();
    }

    // Disable all the sysfs enables.  This is done as a separate loop from
    // 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.
    // the enables to allow the same enable to exist in multiple categories.
    ok &= disableKernelTraceEvents();
    ok &= disableKernelTraceEvents();
@@ -840,6 +858,10 @@ static void cleanUpTrace()
    clearAppProperties();
    clearAppProperties();
    pokeBinderServices();
    pokeBinderServices();


    if (g_tracePdx) {
        ServiceUtility::PokeServices();
    }

    // Set the options back to their defaults.
    // Set the options back to their defaults.
    setTraceOverwriteEnable(true);
    setTraceOverwriteEnable(true);
    setTraceBufferSizeKB(1);
    setTraceBufferSizeKB(1);