diff options
author | 2024-07-25 12:29:25 +0000 | |
---|---|---|
committer | 2024-07-25 12:29:25 +0000 | |
commit | 725f82805c174911e1cfbb2d1bea0001335af20c (patch) | |
tree | e190002ca41f9bf8dc9389ac1a41a34279cdeb85 | |
parent | b310760b09dccdccb76683a79b3cb2b88f0bbddc (diff) | |
parent | f7bdee44c0b6ea3802347f2eff3fea05b41adfe5 (diff) |
Merge "Use custom proto instead of debug string for perfetto traces" into main
-rw-r--r-- | cmds/servicemanager/ServiceManager.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp index d85182d915..c44e540c6d 100644 --- a/cmds/servicemanager/ServiceManager.cpp +++ b/cmds/servicemanager/ServiceManager.cpp @@ -29,6 +29,7 @@ #include <thread> #if !defined(VENDORSERVICEMANAGER) && !defined(__ANDROID_RECOVERY__) +#include "perfetto/public/protos/trace/android/android_track_event.pzc.h" #include "perfetto/public/te_category_macros.h" #include "perfetto/public/te_macros.h" #endif // !defined(VENDORSERVICEMANAGER) && !defined(__ANDROID_RECOVERY__) @@ -57,6 +58,12 @@ PERFETTO_TE_CATEGORIES_DEFINE(PERFETTO_SM_CATEGORIES); #define SM_PERFETTO_TRACE_FUNC(...) \ PERFETTO_TE_SCOPED(servicemanager, PERFETTO_TE_SLICE_BEGIN(__func__) __VA_OPT__(, ) __VA_ARGS__) +constexpr uint32_t kProtoServiceName = + perfetto_protos_AndroidTrackEvent_binder_service_name_field_number; +constexpr uint32_t kProtoInterfaceName = + perfetto_protos_AndroidTrackEvent_binder_interface_name_field_number; +constexpr uint32_t kProtoApexName = perfetto_protos_AndroidTrackEvent_apex_name_field_number; + #endif // !(defined(VENDORSERVICEMANAGER) || defined(__ANDROID_RECOVERY__)) bool is_multiuser_uid_isolated(uid_t uid) { @@ -386,7 +393,8 @@ ServiceManager::~ServiceManager() { } Status ServiceManager::getService(const std::string& name, os::Service* outService) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); *outService = tryGetService(name, true); // returns ok regardless of result for legacy reasons @@ -394,7 +402,8 @@ Status ServiceManager::getService(const std::string& name, os::Service* outServi } Status ServiceManager::checkService(const std::string& name, os::Service* outService) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); *outService = tryGetService(name, false); // returns ok regardless of result for legacy reasons @@ -419,7 +428,8 @@ os::Service ServiceManager::tryGetService(const std::string& name, bool startIfN } sp<IBinder> ServiceManager::tryGetBinder(const std::string& name, bool startIfNotFound) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -459,7 +469,8 @@ sp<IBinder> ServiceManager::tryGetBinder(const std::string& name, bool startIfNo } bool isValidServiceName(const std::string& name) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); if (name.size() == 0) return false; if (name.size() > 127) return false; @@ -476,7 +487,8 @@ bool isValidServiceName(const std::string& name) { } Status ServiceManager::addService(const std::string& name, const sp<IBinder>& binder, bool allowIsolated, int32_t dumpPriority) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -599,7 +611,8 @@ Status ServiceManager::listServices(int32_t dumpPriority, std::vector<std::strin Status ServiceManager::registerForNotifications( const std::string& name, const sp<IServiceCallback>& callback) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -650,7 +663,8 @@ Status ServiceManager::registerForNotifications( } Status ServiceManager::unregisterForNotifications( const std::string& name, const sp<IServiceCallback>& callback) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -676,7 +690,8 @@ Status ServiceManager::unregisterForNotifications( } Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -694,7 +709,8 @@ Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) { } binder::Status ServiceManager::getDeclaredInstances(const std::string& interface, std::vector<std::string>* outReturn) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("interface", interface.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoInterfaceName, interface.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -722,7 +738,8 @@ binder::Status ServiceManager::getDeclaredInstances(const std::string& interface Status ServiceManager::updatableViaApex(const std::string& name, std::optional<std::string>* outReturn) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -741,7 +758,8 @@ Status ServiceManager::updatableViaApex(const std::string& name, Status ServiceManager::getUpdatableNames([[maybe_unused]] const std::string& apexName, std::vector<std::string>* outReturn) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("apexName", apexName.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoApexName, apexName.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -767,7 +785,8 @@ Status ServiceManager::getUpdatableNames([[maybe_unused]] const std::string& ape Status ServiceManager::getConnectionInfo(const std::string& name, std::optional<ConnectionInfo>* outReturn) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); auto ctx = mAccess->getCallingContext(); @@ -852,7 +871,8 @@ void ServiceManager::tryStartService(const Access::CallingContext& ctx, const st Status ServiceManager::registerClientCallback(const std::string& name, const sp<IBinder>& service, const sp<IClientCallback>& cb) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); if (cb == nullptr) { return Status::fromExceptionCode(Status::EX_NULL_POINTER, "Callback null."); @@ -1014,7 +1034,8 @@ void ServiceManager::sendClientCallbackNotifications(const std::string& serviceN } Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IBinder>& binder) { - SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_ARG_STRING("name", name.c_str())); + SM_PERFETTO_TRACE_FUNC(PERFETTO_TE_PROTO_FIELDS( + PERFETTO_TE_PROTO_FIELD_CSTR(kProtoServiceName, name.c_str()))); if (binder == nullptr) { return Status::fromExceptionCode(Status::EX_NULL_POINTER, "Null service."); |