From d1f14bcc50fc245d225f47d7012269a6621bebd5 Mon Sep 17 00:00:00 2001 From: nokyan Date: Fri, 24 Jan 2025 06:36:43 +0100 Subject: [PATCH] Trace contents of drm files when reading them --- src/utils/gpu/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/gpu/mod.rs b/src/utils/gpu/mod.rs index bfd652c..35b9c02 100644 --- a/src/utils/gpu/mod.rs +++ b/src/utils/gpu/mod.rs @@ -193,23 +193,28 @@ pub trait GpuImpl { fn read_sysfs_int + std::marker::Send>(&self, file: P) -> Result { let path = self.sysfs_path().join(file); - trace!("Reading {path:?}…"); + trace!("Reading {path:?} (parsing to int)…"); std::fs::read_to_string(&path)? .replace('\n', "") .parse::() + .inspect(|int| trace!("{path:?} → {int} (size)")) .with_context(|| format!("error parsing file {}", &path.to_string_lossy())) } fn read_device_file + std::marker::Send>(&self, file: P) -> Result { let path = self.sysfs_path().join("device").join(file); trace!("Reading {path:?}…"); - Ok(std::fs::read_to_string(path)?.replace('\n', "")) + std::fs::read_to_string(&path) + .map(|s| s.replace('\n', "")) + .inspect(|s| trace!("{path:?} → {s} (String)")) + .with_context(|| format!("error reading file {}", &path.to_string_lossy())) } fn read_device_int + std::marker::Send>(&self, file: P) -> Result { let path = self.sysfs_path().join("device").join(file); self.read_device_file(&path)? .parse::() + .inspect(|int| trace!("{path:?} → {int} (size)")) .with_context(|| format!("error parsing file {}", &path.to_string_lossy())) } @@ -219,6 +224,7 @@ pub trait GpuImpl { std::fs::read_to_string(&path)? .replace('\n', "") .parse::() + .inspect(|int| trace!("{path:?} → {int} (size)")) .with_context(|| format!("error parsing file {}", &path.to_string_lossy())) }