summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2023-05-04 17:33:20 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-05-04 17:33:20 +0000
commit5a1f39c470bd16ed69b97a691c0da9115c44e478 (patch)
tree76f9ccd803888364b498719a1b5f15a12fff693f
parent1582bf6ac86caaf706782071c87866f9e9776fa0 (diff)
parent4b4679021b76d71468bf6fc0197bb039cc086f7b (diff)
downloadextras-5a1f39c470bd16ed69b97a691c0da9115c44e478.tar.gz
profcollectd: Use --decode-etm when recording am: 4b4679021b
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/extras/+/23008010 Change-Id: I00f260cc3cbf86e57d32886193eb58761160e9b7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--profcollectd/libprofcollectd/logging_trace_provider.rs2
-rw-r--r--profcollectd/libprofcollectd/scheduler.rs8
-rw-r--r--profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs3
-rw-r--r--profcollectd/libprofcollectd/trace_provider.rs2
-rw-r--r--simpleperf/include/simpleperf_profcollect.hpp2
-rw-r--r--simpleperf/profcollect.cpp31
-rw-r--r--simpleperf/rust/lib.rs10
7 files changed, 36 insertions, 22 deletions
diff --git a/profcollectd/libprofcollectd/logging_trace_provider.rs b/profcollectd/libprofcollectd/logging_trace_provider.rs
index 0b9e36fc..d9fd35e9 100644
--- a/profcollectd/libprofcollectd/logging_trace_provider.rs
+++ b/profcollectd/libprofcollectd/logging_trace_provider.rs
@@ -36,7 +36,7 @@ impl TraceProvider for LoggingTraceProvider {
true
}
- fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration) {
+ fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration, binary_filter: &str) {
let trace_file = trace_provider::get_path(trace_dir, tag, LOGGING_TRACEFILE_EXTENSION);
log::info!(
diff --git a/profcollectd/libprofcollectd/scheduler.rs b/profcollectd/libprofcollectd/scheduler.rs
index c4d68805..5558f581 100644
--- a/profcollectd/libprofcollectd/scheduler.rs
+++ b/profcollectd/libprofcollectd/scheduler.rs
@@ -74,6 +74,7 @@ impl Scheduler {
&TRACE_OUTPUT_DIR,
"periodic",
&config.sampling_period,
+ &config.binary_filter,
);
}
}
@@ -96,7 +97,12 @@ impl Scheduler {
pub fn one_shot(&self, config: &Config, tag: &str) -> Result<()> {
let trace_provider = self.trace_provider.clone();
if check_space_limit(&TRACE_OUTPUT_DIR, config)? {
- trace_provider.lock().unwrap().trace(&TRACE_OUTPUT_DIR, tag, &config.sampling_period);
+ trace_provider.lock().unwrap().trace(
+ &TRACE_OUTPUT_DIR,
+ tag,
+ &config.sampling_period,
+ &config.binary_filter,
+ );
}
Ok(())
}
diff --git a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
index 6b326b4a..cb61802e 100644
--- a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
+++ b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs
@@ -38,12 +38,13 @@ impl TraceProvider for SimpleperfEtmTraceProvider {
simpleperf_profcollect::has_device_support()
}
- fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration) {
+ fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration, binary_filter: &str) {
let trace_file = trace_provider::get_path(trace_dir, tag, ETM_TRACEFILE_EXTENSION);
simpleperf_profcollect::record(
&trace_file,
sampling_period,
+ binary_filter,
simpleperf_profcollect::RecordScope::BOTH,
);
}
diff --git a/profcollectd/libprofcollectd/trace_provider.rs b/profcollectd/libprofcollectd/trace_provider.rs
index 704eb9cb..133fa5cb 100644
--- a/profcollectd/libprofcollectd/trace_provider.rs
+++ b/profcollectd/libprofcollectd/trace_provider.rs
@@ -30,7 +30,7 @@ use crate::logging_trace_provider::LoggingTraceProvider;
pub trait TraceProvider {
fn get_name(&self) -> &'static str;
fn is_ready(&self) -> bool;
- fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration);
+ fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration, binary_filter: &str);
fn process(&self, trace_dir: &Path, profile_dir: &Path, binary_filter: &str) -> Result<()>;
fn set_log_file(&self, filename: &Path);
fn reset_log_file(&self);
diff --git a/simpleperf/include/simpleperf_profcollect.hpp b/simpleperf/include/simpleperf_profcollect.hpp
index d06ac6b4..d1e6661a 100644
--- a/simpleperf/include/simpleperf_profcollect.hpp
+++ b/simpleperf/include/simpleperf_profcollect.hpp
@@ -18,7 +18,7 @@ extern "C" {
bool HasDriverSupport();
bool HasDeviceSupport();
-bool Record(const char* event_name, const char* output, float duration);
+bool Record(const char* event_name, const char* output, float duration, const char* binary_filter);
bool Inject(const char* traceInput, const char* profileOutput, const char* binary_filter);
void SetLogFile(const char* filename);
void ResetLogFile();
diff --git a/simpleperf/profcollect.cpp b/simpleperf/profcollect.cpp
index ee3a21e4..9cffbddc 100644
--- a/simpleperf/profcollect.cpp
+++ b/simpleperf/profcollect.cpp
@@ -52,8 +52,9 @@ bool HasDeviceSupport() {
return ret;
}
-bool Record(const char* event_name, const char* output, float duration) {
- LOG(INFO) << "Record " << event_name << ", duration " << duration << ", output " << output;
+bool Record(const char* event_name, const char* output, float duration, const char* binary_filter) {
+ LOG(INFO) << "Record " << event_name << ", duration " << duration << ", output " << output
+ << ", binary_filter " << binary_filter;
// The kernel may panic when trying to hibernate or hotplug CPUs while collecting
// ETM data. So get wakelock to keep the CPUs on.
auto wakelock = android::wakelock::WakeLock::tryGet("profcollectd");
@@ -62,11 +63,17 @@ bool Record(const char* event_name, const char* output, float duration) {
return false;
}
auto recordCmd = CreateCommandInstance("record");
- std::vector<std::string> args;
- args.push_back("-a");
- args.insert(args.end(), {"-e", event_name});
- args.insert(args.end(), {"--duration", std::to_string(duration)});
- args.insert(args.end(), {"-o", output});
+ std::vector<std::string> args = {"-a",
+ "-e",
+ event_name,
+ "--duration",
+ std::to_string(duration),
+ "--decode-etm",
+ "--exclude-perf",
+ "--binary",
+ binary_filter,
+ "-o",
+ output};
bool result = recordCmd->Run(args);
LOG(INFO) << "Record result " << result;
return result;
@@ -76,14 +83,8 @@ bool Inject(const char* traceInput, const char* profileOutput, const char* binar
LOG(INFO) << "Inject traceInput " << traceInput << ", profileOutput " << profileOutput
<< ", binary_filter " << binary_filter;
auto injectCmd = CreateCommandInstance("inject");
- std::vector<std::string> args;
- args.insert(args.end(), {"-i", traceInput});
- args.insert(args.end(), {"-o", profileOutput});
- if (binary_filter) {
- args.insert(args.end(), {"--binary", binary_filter});
- }
- args.insert(args.end(), {"--output", "branch-list"});
- args.emplace_back("--exclude-perf");
+ std::vector<std::string> args = {"-i", traceInput, "-o", profileOutput,
+ "--output", "branch-list", "--binary", binary_filter};
bool result = injectCmd->Run(args);
LOG(INFO) << "Inject result " << result;
return result;
diff --git a/simpleperf/rust/lib.rs b/simpleperf/rust/lib.rs
index c1f35e02..94ad8795 100644
--- a/simpleperf/rust/lib.rs
+++ b/simpleperf/rust/lib.rs
@@ -48,7 +48,7 @@ pub enum RecordScope {
}
/// Trigger an ETM trace event.
-pub fn record(trace_file: &Path, duration: &Duration, scope: RecordScope) {
+pub fn record(trace_file: &Path, duration: &Duration, binary_filter: &str, scope: RecordScope) {
let event_name: CString = match scope {
RecordScope::USERSPACE => CString::new("cs-etm:u").unwrap(),
RecordScope::KERNEL => CString::new("cs-etm:k").unwrap(),
@@ -56,9 +56,15 @@ pub fn record(trace_file: &Path, duration: &Duration, scope: RecordScope) {
};
let trace_file = path_to_cstr(trace_file);
let duration = duration.as_secs_f32();
+ let binary_filter = CString::new(binary_filter).unwrap();
unsafe {
- simpleperf_profcollect_bindgen::Record(event_name.as_ptr(), trace_file.as_ptr(), duration);
+ simpleperf_profcollect_bindgen::Record(
+ event_name.as_ptr(),
+ trace_file.as_ptr(),
+ duration,
+ binary_filter.as_ptr(),
+ );
}
}