diff --git a/services/pddb/src/api.rs b/services/pddb/src/api.rs index 43d28578a..3fab0e010 100644 --- a/services/pddb/src/api.rs +++ b/services/pddb/src/api.rs @@ -535,6 +535,7 @@ pub struct PddbDangerousDebug { pub enum DebugRequest { Dump = 0, Remount = 1, + Prune = 2, } #[cfg(test)] diff --git a/services/pddb/src/lib.rs b/services/pddb/src/lib.rs index 744c791ae..a652a6afc 100644 --- a/services/pddb/src/lib.rs +++ b/services/pddb/src/lib.rs @@ -1018,6 +1018,18 @@ impl Pddb { buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))).map(|_| ()) } + /// Forces a basis pruning, for testing the pruning and prune recovery code. + #[cfg(not(target_os = "xous"))] + pub fn dbg_prune(&self) -> Result<()> { + let ipc = PddbDangerousDebug { + request: DebugRequest::Prune, + dump_name: xous_ipc::String::new(), + }; + let buf = Buffer::into_buf(ipc) + .or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?; + buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap()) + .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))).map(|_| ()) + } #[cfg(all(feature="pddbtest", feature="autobasis"))] pub fn basis_testing(&self, config: &[Option; 32]) { diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index fd1284beb..537190a60 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -1817,6 +1817,13 @@ fn wrapped_main() -> ! { } else { log::info!("remount failed"); } + }, + DebugRequest::Prune => { + log::info!("initiating prune"); + log::set_max_level(log::LevelFilter::Debug); + basis_cache.cache_prune(&mut pddb_os, 262144); + log::set_max_level(log::LevelFilter::Info); + log::info!("prune finished"); } } }