diff options
author | Yi Kong <yikong@google.com> | 2020-07-07 20:46:57 +0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2020-07-22 00:10:15 +0800 |
commit | ce96d59ccd0f04520962e9365b846fa614e9f944 (patch) | |
tree | 898d16f9099390cf591e53b6b346648f4125eb7d /profcollectd/libprofcollectd | |
parent | 9a615c405f3d7dc7316bad16733a7304a9aad7f4 (diff) | |
download | extras-ce96d59ccd0f04520962e9365b846fa614e9f944.tar.gz |
profcollectd: Add binder call to check the supported provider
This allows the forward service to avoid wasting resources if no
provider is available on the device.
Bug: 79161490
Test: build
Change-Id: Ic7cf646e9f8a4390440be824186deb7b2f256c82
Diffstat (limited to 'profcollectd/libprofcollectd')
-rw-r--r-- | profcollectd/libprofcollectd/binder_service.cpp | 4 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/binder_service.h | 1 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/hwtrace_provider.h | 5 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/scheduler.cpp | 5 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/scheduler.h | 1 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/simpleperf_etm_provider.cpp | 6 |
6 files changed, 22 insertions, 0 deletions
diff --git a/profcollectd/libprofcollectd/binder_service.cpp b/profcollectd/libprofcollectd/binder_service.cpp index 92446509..f43f40ee 100644 --- a/profcollectd/libprofcollectd/binder_service.cpp +++ b/profcollectd/libprofcollectd/binder_service.cpp @@ -67,5 +67,9 @@ Status ProfcollectdBinder::ProcessProfile() { return HandleIfError([=]() { return Scheduler->ProcessProfile(); }); } +Status ProfcollectdBinder::GetSupportedProvider(std::string* provider) { + return HandleIfError([=]() { return Scheduler->GetSupportedProvider(*provider); }); +} + } // namespace profcollectd } // namespace android diff --git a/profcollectd/libprofcollectd/binder_service.h b/profcollectd/libprofcollectd/binder_service.h index af272085..4434427c 100644 --- a/profcollectd/libprofcollectd/binder_service.h +++ b/profcollectd/libprofcollectd/binder_service.h @@ -37,6 +37,7 @@ class ProfcollectdBinder : public BinderService<ProfcollectdBinder>, binder::Status TerminateCollection() override; binder::Status TraceOnce(const std::string& tag) override; binder::Status ProcessProfile() override; + binder::Status GetSupportedProvider(std::string* provider) override; protected: inline static std::unique_ptr<ProfcollectdScheduler> Scheduler; diff --git a/profcollectd/libprofcollectd/hwtrace_provider.h b/profcollectd/libprofcollectd/hwtrace_provider.h index e60a87ff..8e10745f 100644 --- a/profcollectd/libprofcollectd/hwtrace_provider.h +++ b/profcollectd/libprofcollectd/hwtrace_provider.h @@ -28,6 +28,11 @@ class HwtraceProvider { virtual ~HwtraceProvider() = default; /** + * Get the name of the trace provider. + */ + virtual std::string GetName() = 0; + + /** * Trace for the given length of time. * * @param period Length of time to trace in seconds. diff --git a/profcollectd/libprofcollectd/scheduler.cpp b/profcollectd/libprofcollectd/scheduler.cpp index eb47d843..30a181aa 100644 --- a/profcollectd/libprofcollectd/scheduler.cpp +++ b/profcollectd/libprofcollectd/scheduler.cpp @@ -185,6 +185,11 @@ OptError ProfcollectdScheduler::ProcessProfile() { return std::nullopt; } +OptError ProfcollectdScheduler::GetSupportedProvider(std::string& provider) { + provider = hwtracer ? hwtracer->GetName() : ""; + return std::nullopt; +} + std::ostream& operator<<(std::ostream& os, const ProfcollectdScheduler::Config& config) { Json::Value root; const auto writer = std::make_unique<Json::StyledStreamWriter>(); diff --git a/profcollectd/libprofcollectd/scheduler.h b/profcollectd/libprofcollectd/scheduler.h index 31ffc5fb..492b4182 100644 --- a/profcollectd/libprofcollectd/scheduler.h +++ b/profcollectd/libprofcollectd/scheduler.h @@ -52,6 +52,7 @@ class ProfcollectdScheduler { OptError TerminateCollection(); OptError TraceOnce(const std::string& tag); OptError ProcessProfile(); + OptError GetSupportedProvider(std::string& provider); private: Config config; diff --git a/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp b/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp index 0d6491e6..5e8c55bc 100644 --- a/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp +++ b/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp @@ -49,6 +49,7 @@ namespace fs = std::filesystem; class SimpleperfETMProvider : public HwtraceProvider { public: static bool IsSupported(); + std::string GetName(); bool Trace(const fs::path& outputPath, const std::string& tag, std::chrono::duration<float> samplingPeriod) override; bool Process(const fs::path& inputPath, const fs::path& outputPath, @@ -59,6 +60,11 @@ bool SimpleperfETMProvider::IsSupported() { return simpleperf::etm::HasSupport(); } +std::string SimpleperfETMProvider::GetName() { + static constexpr const char* name = "simpleperf_etm"; + return name; +} + bool SimpleperfETMProvider::Trace(const fs::path& outputPath, const std::string& tag, std::chrono::duration<float> samplingPeriod) { const std::string timestamp = GetTimestamp(); |