Wire up dynamic debug to work for the pr_debug!() macro.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
 rust/kernel/print.rs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
index 9ce52b9fa69f..9a0870c2df94 100644
--- a/rust/kernel/print.rs
+++ b/rust/kernel/print.rs
@@ -373,8 +373,7 @@ macro_rules! pr_info (
 ///
 /// Use this level for debug messages.
 ///
-/// Equivalent to the kernel's [`pr_debug`] macro, except that it doesn't 
support dynamic debug
-/// yet.
+/// Equivalent to the kernel's [`pr_debug`] macro.
 ///
 /// Mimics the interface of [`std::print!`]. See [`core::fmt`] and
 /// [`std::format!`] for information about the formatting syntax.
@@ -392,6 +391,13 @@ macro_rules! pr_info (
 #[doc(alias = "print")]
 macro_rules! pr_debug (
     ($($arg:tt)*) => (
+        // TODO: Switch to cfg_select!() when that is usable.
+        #[cfg(any(CONFIG_DYNAMIC_DEBUG, all(CONFIG_DYNAMIC_DEBUG_CORE, 
debug_assertions)))]
+        $crate::dynamic_func_call!($crate::__format_string!($($arg)+), || {
+            $crate::print_macro!($crate::print::format_strings::DEBUG, false, 
$($arg)*)
+        });
+
+        #[cfg(not(any(CONFIG_DYNAMIC_DEBUG, all(CONFIG_DYNAMIC_DEBUG_CORE, 
debug_assertions))))]
         if cfg!(debug_assertions) {
             $crate::print_macro!($crate::print::format_strings::DEBUG, false, 
$($arg)*)
         }

-- 
2.56.0


Reply via email to