chore(core/rust): drop dbg_println macros from trezor_lib crate
What changed, and why it matters
This commit removes internal debug-only printing helpers from the Trezor firmware's Rust code. It is a cleanup change with no security relevance: the removed macros were only active when a special 'debug' build feature was enabled, and they were not used in production code paths.
No security action required. Treat as routine code hygiene.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes core/embed/rust/src/debug.rs and removes the dbg_print!/dbg_println! macros from core/embed/rust/src/macros.rs. These macros were gated by #[cfg(feature = “debug”)] and routed output either to a Unix stdout write wrapper or to the MicroPython print function. Removing them eliminates a debug-only code path but does not change production firmware behavior or fix any vulnerability.
Changed components
core/embed/rust/src/debug.rscore/embed/rust/src/lib.rscore/embed/rust/src/macros.rsInspect captured patch +0 / −48
diff --git a/core/embed/rust/src/debug.rs b/core/embed/rust/src/debug.rs
deleted file mode 100644
index 94bf465a..00000000
--- a/core/embed/rust/src/debug.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-mod unix_ffi {
- const STDOUT_FILENO: cty::c_int = 1;
-
- extern "C" {
- pub fn write(fd: cty::c_int, buf: *const u8, count: cty::size_t) -> cty::ssize_t;
- }
-
- pub fn print(to_log: &str) {
- unsafe {
- write(STDOUT_FILENO, to_log.as_ptr(), to_log.len() as cty::size_t);
- }
- }
-}
-
-#[cfg(not(feature = "micropython"))]
-pub use unix_ffi::print;
-
-#[cfg(feature = "micropython")]
-use crate::micropython::print::print;
-
-pub struct DebugConsole;
-
-impl ufmt::uWrite for DebugConsole {
- type Error = core::convert::Infallible;
-
- fn write_str(&mut self, s: &str) -> Result<(), Self::Error> {
- print(s);
- Ok(())
- }
-}
diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs
index 7ca18819..1dd8bf1a 100644
--- a/core/embed/rust/src/lib.rs
+++ b/core/embed/rust/src/lib.rs
@@ -23,8 +23,6 @@ mod macros;
mod align;
#[cfg(feature = "debug")]
mod coverage;
-#[cfg(feature = "debug")]
-mod debug;
mod error;
mod io;
mod maybe_trace;
diff --git a/core/embed/rust/src/macros.rs b/core/embed/rust/src/macros.rs
index b6610b9d..2544cbf2 100644
--- a/core/embed/rust/src/macros.rs
+++ b/core/embed/rust/src/macros.rs
@@ -41,19 +41,3 @@ macro_rules! uformat {
uformat!(@crate::strutil::ShortString, $($tt)*)
};
}
-
-#[allow(unused_macros)] // Should be used only for debugging purposes
-macro_rules! dbg_print {
- ($($args:tt)*) => {
- #[cfg(feature = "debug")]
- ufmt::uwrite!($crate::debug::DebugConsole, $($args)*).ok();
- }
-}
-
-#[allow(unused_macros)] // Should be used only for debugging purposes
-macro_rules! dbg_println {
- ($($args:tt)*) => {
- #[cfg(feature = "debug")]
- ufmt::uwriteln!($crate::debug::DebugConsole, $($args)*).ok();
- }
-}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.