diff options
Diffstat (limited to 'profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs')
-rw-r--r-- | profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs index f25f5ffc..2038a5be 100644 --- a/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs +++ b/profcollectd/libprofcollectd/simpleperf_etm_trace_provider.rs @@ -34,52 +34,46 @@ impl TraceProvider for SimpleperfEtmTraceProvider { "simpleperf_etm" } - fn is_ready(&self) -> bool { - simpleperf_profcollect::has_device_support() - } - fn trace(&self, trace_dir: &Path, tag: &str, sampling_period: &Duration) { - let trace_file = trace_provider::get_path(trace_dir, tag, ETM_TRACEFILE_EXTENSION); + let mut trace_file = PathBuf::from(trace_dir); + trace_file.push(trace_provider::construct_file_name(tag)); + trace_file.set_extension(ETM_TRACEFILE_EXTENSION); simpleperf_profcollect::record( - &*trace_file, + &trace_file, sampling_period, simpleperf_profcollect::RecordScope::BOTH, ); } - fn process(&self, trace_dir: &Path, profile_dir: &Path, binary_filter: &str) -> Result<()> { - let is_etm_extension = |file: &PathBuf| { - file.extension() - .and_then(|f| f.to_str()) - .filter(|ext| ext == &ETM_TRACEFILE_EXTENSION) - .is_some() - }; - - let process_trace_file = |trace_file: PathBuf| { - let mut profile_file = PathBuf::from(profile_dir); - profile_file.push( - trace_file - .file_name() - .ok_or_else(|| anyhow!("Malformed trace path: {}", trace_file.display()))?, - ); - profile_file.set_extension(ETM_PROFILE_EXTENSION); - simpleperf_profcollect::process(&trace_file, &profile_file, binary_filter); - remove_file(&trace_file)?; - Ok(()) - }; - + fn process(&self, trace_dir: &Path, profile_dir: &Path) -> Result<()> { read_dir(trace_dir)? .filter_map(|e| e.ok()) .map(|e| e.path()) - .filter(|e| e.is_file()) - .filter(is_etm_extension) - .try_for_each(process_trace_file) + .filter(|e| { + e.is_file() + && e.extension() + .and_then(|f| f.to_str()) + .filter(|ext| ext == &ETM_TRACEFILE_EXTENSION) + .is_some() + }) + .try_for_each(|trace_file| -> Result<()> { + let mut profile_file = PathBuf::from(profile_dir); + profile_file.push( + trace_file + .file_name() + .ok_or_else(|| anyhow!("Malformed trace path: {}", trace_file.display()))?, + ); + profile_file.set_extension(ETM_PROFILE_EXTENSION); + simpleperf_profcollect::process(&trace_file, &profile_file); + remove_file(&trace_file)?; + Ok(()) + }) } } impl SimpleperfEtmTraceProvider { pub fn supported() -> bool { - simpleperf_profcollect::has_driver_support() + simpleperf_profcollect::has_support() } } |